diff options
| author | 2013-03-20 05:38:06 +0100 | |
|---|---|---|
| committer | 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 @@ | |||
| 29 | #ifdef WIN32 | 29 | #ifdef WIN32 |
| 30 | #include <windows.h> | 30 | #include <windows.h> |
| 31 | #define sleep(x) Sleep(x*1000) | 31 | #define sleep(x) Sleep(x*1000) |
| 32 | #else | ||
| 33 | #include <pthread.h> | ||
| 34 | #endif | 32 | #endif |
| 35 | 33 | ||
| 36 | #include <libimobiledevice/libimobiledevice.h> | 34 | #include <libimobiledevice/libimobiledevice.h> |
| 37 | #include <libimobiledevice/lockdown.h> | 35 | #include <libimobiledevice/lockdown.h> |
| 38 | #include "../src/service.h" | 36 | |
| 37 | #include "src/service.h" | ||
| 38 | #include "common/thread.h" | ||
| 39 | 39 | ||
| 40 | static int quit_flag = 0; | 40 | static int quit_flag = 0; |
| 41 | 41 | ||
| @@ -46,11 +46,7 @@ static char* udid = NULL; | |||
| 46 | static idevice_t device = NULL; | 46 | static idevice_t device = NULL; |
| 47 | static service_client_t syslog = NULL; | 47 | static service_client_t syslog = NULL; |
| 48 | 48 | ||
| 49 | #ifdef WIN32 | 49 | thread_t worker = NULL; |
| 50 | HANDLE worker = NULL; | ||
| 51 | #else | ||
| 52 | pthread_t worker; | ||
| 53 | #endif | ||
| 54 | 50 | ||
| 55 | static int logging = 0; | 51 | static int logging = 0; |
| 56 | 52 | ||
| @@ -100,19 +96,10 @@ static int start_logging() | |||
| 100 | 96 | ||
| 101 | /* start worker thread */ | 97 | /* start worker thread */ |
| 102 | logging = 1; | 98 | logging = 1; |
| 103 | #ifdef WIN32 | 99 | if (thread_create(&worker, syslog_worker, NULL) != 0) { |
| 104 | worker = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)syslog_worker, NULL, 0, NULL); | ||
| 105 | if (worker == INVALID_HANDLE_VALUE) { | ||
| 106 | logging = 0; | 100 | logging = 0; |
| 107 | return -1; | 101 | return -1; |
| 108 | } | 102 | } |
| 109 | #else | ||
| 110 | if (pthread_create(&worker, NULL, syslog_worker, NULL) != 0) { | ||
| 111 | logging = 0; | ||
| 112 | return -1; | ||
| 113 | } | ||
| 114 | #endif | ||
| 115 | |||
| 116 | return 0; | 103 | return 0; |
| 117 | } | 104 | } |
| 118 | 105 | ||
| @@ -127,11 +114,7 @@ static void stop_logging() | |||
| 127 | } | 114 | } |
| 128 | 115 | ||
| 129 | /* wait for thread to complete */ | 116 | /* wait for thread to complete */ |
| 130 | #ifdef WIN32 | 117 | thread_join(worker); |
| 131 | WaitForSingleObject(worker, INFINITE); | ||
| 132 | #else | ||
| 133 | pthread_join(worker, NULL); | ||
| 134 | #endif | ||
| 135 | } | 118 | } |
| 136 | 119 | ||
| 137 | if (device) { | 120 | if (device) { |
