diff options
author | Nikias Bassen | 2014-02-15 19:15:58 +0100 |
---|---|---|
committer | Nikias Bassen | 2014-02-15 19:15:58 +0100 |
commit | 592782336ebb56fa31148f8c8b29c797c82185e9 (patch) | |
tree | 19cb727bf70ded4528c1ddb36d7adc438912762b /src/preflight.c | |
parent | 2d2ee31546b9bf5fb4bc3d0862d4f1f8bccd0015 (diff) | |
download | usbmuxd-592782336ebb56fa31148f8c8b29c797c82185e9.tar.gz usbmuxd-592782336ebb56fa31148f8c8b29c797c82185e9.tar.bz2 |
preflight: create preflight worker as detached thread and handle errors
Diffstat (limited to 'src/preflight.c')
-rw-r--r-- | src/preflight.c | 13 |
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 #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <errno.h> #include <pthread.h> @@ -343,7 +344,17 @@ void preflight_worker_device_add(struct device_info* info) memcpy(infocopy, info, sizeof(struct device_info)); pthread_t th; - pthread_create(&th, NULL, preflight_worker_handle_device_add, infocopy); + 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); + 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); + } #else client_device_add(info); #endif |