diff options
| author | 2013-03-20 05:38:06 +0100 | |
|---|---|---|
| committer | 2013-03-20 05:38:06 +0100 | |
| commit | b2924a1549d874fb86deaad5fd2438e567c65bf4 (patch) | |
| tree | ead89f885a0492cdfc228a1c25326912e7d9b973 /src/sbservices.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 'src/sbservices.c')
| -rw-r--r-- | src/sbservices.c | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/src/sbservices.c b/src/sbservices.c index 00f2862..1cd17db 100644 --- a/src/sbservices.c +++ b/src/sbservices.c | |||
| @@ -36,11 +36,7 @@ | |||
| 36 | static void sbs_lock(sbservices_client_t client) | 36 | static void sbs_lock(sbservices_client_t client) |
| 37 | { | 37 | { |
| 38 | debug_info("SBServices: Locked"); | 38 | debug_info("SBServices: Locked"); |
| 39 | #ifdef WIN32 | 39 | mutex_lock(&client->mutex); |
| 40 | EnterCriticalSection(&client->mutex); | ||
| 41 | #else | ||
| 42 | pthread_mutex_lock(&client->mutex); | ||
| 43 | #endif | ||
| 44 | } | 40 | } |
| 45 | 41 | ||
| 46 | /** | 42 | /** |
| @@ -51,11 +47,7 @@ static void sbs_lock(sbservices_client_t client) | |||
| 51 | static void sbs_unlock(sbservices_client_t client) | 47 | static void sbs_unlock(sbservices_client_t client) |
| 52 | { | 48 | { |
| 53 | debug_info("SBServices: Unlocked"); | 49 | debug_info("SBServices: Unlocked"); |
| 54 | #ifdef WIN32 | 50 | mutex_unlock(&client->mutex); |
| 55 | LeaveCriticalSection(&client->mutex); | ||
| 56 | #else | ||
| 57 | pthread_mutex_unlock(&client->mutex); | ||
| 58 | #endif | ||
| 59 | } | 51 | } |
| 60 | 52 | ||
| 61 | /** | 53 | /** |
| @@ -105,11 +97,7 @@ sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_des | |||
| 105 | 97 | ||
| 106 | sbservices_client_t client_loc = (sbservices_client_t) malloc(sizeof(struct sbservices_client_private)); | 98 | sbservices_client_t client_loc = (sbservices_client_t) malloc(sizeof(struct sbservices_client_private)); |
| 107 | client_loc->parent = plistclient; | 99 | client_loc->parent = plistclient; |
| 108 | #ifdef WIN32 | 100 | mutex_init(&client_loc->mutex); |
| 109 | InitializeCriticalSection(&client_loc->mutex); | ||
| 110 | #else | ||
| 111 | pthread_mutex_init(&client_loc->mutex, NULL); | ||
| 112 | #endif | ||
| 113 | 101 | ||
| 114 | *client = client_loc; | 102 | *client = client_loc; |
| 115 | return SBSERVICES_E_SUCCESS; | 103 | return SBSERVICES_E_SUCCESS; |
| @@ -131,11 +119,7 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client) | |||
| 131 | 119 | ||
| 132 | sbservices_error_t err = sbservices_error(property_list_service_client_free(client->parent)); | 120 | sbservices_error_t err = sbservices_error(property_list_service_client_free(client->parent)); |
| 133 | client->parent = NULL; | 121 | client->parent = NULL; |
| 134 | #ifdef WIN32 | 122 | mutex_destroy(&client->mutex); |
| 135 | DeleteCriticalSection(&client->mutex); | ||
| 136 | #else | ||
| 137 | pthread_mutex_destroy(&client->mutex); | ||
| 138 | #endif | ||
| 139 | free(client); | 123 | free(client); |
| 140 | 124 | ||
| 141 | return err; | 125 | return err; |
