summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/preflight.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/preflight.c b/src/preflight.c
index 5c4474a..88e6700 100644
--- a/src/preflight.c
+++ b/src/preflight.c
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25#include <stdlib.h> 25#include <stdlib.h>
26#include <string.h> 26#include <string.h>
27#include <unistd.h> 27#include <unistd.h>
28#include <errno.h>
28 29
29#include <pthread.h> 30#include <pthread.h>
30 31
@@ -343,7 +344,17 @@ void preflight_worker_device_add(struct device_info* info)
343 memcpy(infocopy, info, sizeof(struct device_info)); 344 memcpy(infocopy, info, sizeof(struct device_info));
344 345
345 pthread_t th; 346 pthread_t th;
346 pthread_create(&th, NULL, preflight_worker_handle_device_add, infocopy); 347 pthread_attr_t attr;
348
349 pthread_attr_init(&attr);
350 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
351
352 int perr = pthread_create(&th, &attr, preflight_worker_handle_device_add, infocopy);
353 if (perr != 0) {
354 free(infocopy);
355 usbmuxd_log(LL_ERROR, "ERROR: failed to start preflight worker thread for device %s: %s (%d). Invoking client_device_add() directly but things might not work as expected.", info->serial, strerror(perr), perr);
356 client_device_add(info);
357 }
347#else 358#else
348 client_device_add(info); 359 client_device_add(info);
349#endif 360#endif