summaryrefslogtreecommitdiffstats
path: root/src/preflight.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2014-02-15 19:15:58 +0100
committerGravatar Nikias Bassen2014-02-15 19:15:58 +0100
commit592782336ebb56fa31148f8c8b29c797c82185e9 (patch)
tree19cb727bf70ded4528c1ddb36d7adc438912762b /src/preflight.c
parent2d2ee31546b9bf5fb4bc3d0862d4f1f8bccd0015 (diff)
downloadusbmuxd-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.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
#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