diff options
author | 2014-11-12 21:58:30 +0100 | |
---|---|---|
committer | 2014-12-02 19:22:25 +0100 | |
commit | a25009872304f17514089afb48a3e860e7cb9cfe (patch) | |
tree | 5a431f341c94b5de628fac67cbdc43de244fe5a7 /src/preflight.c | |
parent | 34e6eeef656a205d4f65f128cb17bc81cca3b4d3 (diff) | |
download | usbmuxd-a25009872304f17514089afb48a3e860e7cb9cfe.tar.gz usbmuxd-a25009872304f17514089afb48a3e860e7cb9cfe.tar.bz2 |
common: Add thread+mutex implementation and use it where applicablerefactor
Diffstat (limited to 'src/preflight.c')
-rw-r--r-- | src/preflight.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/preflight.c b/src/preflight.c index c74e49d..f83c8b6 100644 --- a/src/preflight.c +++ b/src/preflight.c @@ -26,8 +26,6 @@ #include <unistd.h> #include <errno.h> -#include <pthread.h> - #include <sys/time.h> #ifdef HAVE_LIBIMOBILEDEVICE @@ -42,6 +40,8 @@ #include "conf.h" #include "log.h" +#include "common/thread.h" + #ifdef HAVE_LIBIMOBILEDEVICE enum connection_type { CONNECTION_USBMUXD = 1 @@ -344,18 +344,14 @@ void preflight_worker_device_add(struct device_info* info) memcpy(infocopy, info, sizeof(struct device_info)); - pthread_t th; - pthread_attr_t attr; - - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - int perr = pthread_create(&th, &attr, preflight_worker_handle_device_add, infocopy); + thread_t th; + int perr = thread_create(&th, preflight_worker_handle_device_add, infocopy); if (perr != 0) { free(infocopy); 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); client_device_add(info); } + thread_detach(th); #else client_device_add(info); #endif |