The end user might expect the lxi_connect() call to return synchronously; however, the separate connection thread may still be alive although already cancelled when the user calls lxi_connect() again.
pthread_cancel()'ing the child thread sends a termination signal, which is handled by the child. The parent should wait for the child to be fully terminated before returning. This does not notably block the call, but avoids creating more and more child threads when retrying to connect.
The end user might expect the lxi_connect() call to return synchronously; however, the separate connection thread may still be alive although already cancelled when the user calls lxi_connect() again. pthread_cancel()'ing the child thread sends a termination signal, which is handled by the child. The parent should wait for the child to be fully terminated before returning. This does not notably block the call, but avoids creating more and more child threads when retrying to connect.