diff options
author | Nikias Bassen | 2013-03-20 05:38:06 +0100 |
---|---|---|
committer | Nikias Bassen | 2013-03-20 05:38:06 +0100 |
commit | b2924a1549d874fb86deaad5fd2438e567c65bf4 (patch) | |
tree | ead89f885a0492cdfc228a1c25326912e7d9b973 /tools/idevicesyslog.c | |
parent | efca491e4c19868a68a099638552f9ba431dca4b (diff) | |
download | libimobiledevice-b2924a1549d874fb86deaad5fd2438e567c65bf4.tar.gz libimobiledevice-b2924a1549d874fb86deaad5fd2438e567c65bf4.tar.bz2 |
use new internal common code for thread, mutex, and socket operations
Diffstat (limited to 'tools/idevicesyslog.c')
-rw-r--r-- | tools/idevicesyslog.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c index 32163e6..3dd2257 100644 --- a/tools/idevicesyslog.c +++ b/tools/idevicesyslog.c @@ -29,13 +29,13 @@ #ifdef WIN32 #include <windows.h> #define sleep(x) Sleep(x*1000) -#else -#include <pthread.h> #endif #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> -#include "../src/service.h" + +#include "src/service.h" +#include "common/thread.h" static int quit_flag = 0; @@ -46,11 +46,7 @@ static char* udid = NULL; static idevice_t device = NULL; static service_client_t syslog = NULL; -#ifdef WIN32 -HANDLE worker = NULL; -#else -pthread_t worker; -#endif +thread_t worker = NULL; static int logging = 0; @@ -100,19 +96,10 @@ static int start_logging() /* start worker thread */ logging = 1; -#ifdef WIN32 - worker = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)syslog_worker, NULL, 0, NULL); - if (worker == INVALID_HANDLE_VALUE) { + if (thread_create(&worker, syslog_worker, NULL) != 0) { logging = 0; return -1; } -#else - if (pthread_create(&worker, NULL, syslog_worker, NULL) != 0) { - logging = 0; - return -1; - } -#endif - return 0; } @@ -127,11 +114,7 @@ static void stop_logging() } /* wait for thread to complete */ -#ifdef WIN32 - WaitForSingleObject(worker, INFINITE); -#else - pthread_join(worker, NULL); -#endif + thread_join(worker); } if (device) { |