summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-04-19 19:22:45 +0200
committerGravatar Nikias Bassen2013-04-19 19:22:45 +0200
commit01e1f489ebff5e6044bb90eeaaa26052fdc5fece (patch)
tree1157332058412b183cf67a794cfc1ee63c965343
parent3969b90cdeabe09028266c8b3a28c9ffcec82cec (diff)
downloadusbmuxd-01e1f489ebff5e6044bb90eeaaa26052fdc5fece.tar.gz
usbmuxd-01e1f489ebff5e6044bb90eeaaa26052fdc5fece.tar.bz2
libusbmuxd: use status variable instead of waiting fixed amount in initialization
-rw-r--r--libusbmuxd/libusbmuxd.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libusbmuxd/libusbmuxd.c b/libusbmuxd/libusbmuxd.c
index 6721fe6..01d67e0 100644
--- a/libusbmuxd/libusbmuxd.c
+++ b/libusbmuxd/libusbmuxd.c
@@ -70,6 +70,7 @@ static int libusbmuxd_debug = 0;
#define DEBUG(x, y, ...) if (x <= libusbmuxd_debug) fprintf(stderr, (y), __VA_ARGS__);
static int libusbmuxd_initialized = 0;
+static int first_lookup = 0;
static struct collection devices;
static int handle_events = 0;
@@ -633,6 +634,7 @@ static void *device_monitor(void *data)
while (handle_events) {
listenfd = usbmuxd_listen();
+ first_lookup = 1;
if (listenfd < 0) {
continue;
}
@@ -665,8 +667,10 @@ int usbmuxd_init()
mutex_unlock(&init_mutex);
return res;
}
- struct timespec ts = {0, 250000000};
- nanosleep(&ts, NULL);
+ struct timespec ts = {0, 100000000};
+ while (!first_lookup) {
+ nanosleep(&ts, NULL);
+ }
libusbmuxd_initialized = 1;
mutex_unlock(&init_mutex);
return 0;
@@ -684,6 +688,7 @@ int usbmuxd_deinit()
thread_join(devmon);
}
libusbmuxd_initialized = 0;
+ first_lookup = 0;
mutex_unlock(&init_mutex);
return 0;
}