summaryrefslogtreecommitdiffstats
path: root/src/installation_proxy.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2011-09-03 02:07:09 +0200
committerGravatar Martin Szulecki2012-03-18 20:40:54 +0100
commit6a83ef58a1032e3b336587e2f3a19659ae325c25 (patch)
tree27e12297bc66bd22a0cfc86459413a49a0d998f2 /src/installation_proxy.c
parentb586203dbef26f9e94325b57867478eda504e5a1 (diff)
downloadlibimobiledevice-6a83ef58a1032e3b336587e2f3a19659ae325c25.tar.gz
libimobiledevice-6a83ef58a1032e3b336587e2f3a19659ae325c25.tar.bz2
Remove gthread dependency and use pthreads instead
Diffstat (limited to 'src/installation_proxy.c')
-rw-r--r--src/installation_proxy.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/installation_proxy.c b/src/installation_proxy.c
index 4a76dd2..e26a77d 100644
--- a/src/installation_proxy.c
+++ b/src/installation_proxy.c
@@ -43,7 +43,7 @@ struct instproxy_status_data {
43static void instproxy_lock(instproxy_client_t client) 43static void instproxy_lock(instproxy_client_t client)
44{ 44{
45 debug_info("InstallationProxy: Locked"); 45 debug_info("InstallationProxy: Locked");
46 g_mutex_lock(client->mutex); 46 pthread_mutex_lock(&client->mutex);
47} 47}
48 48
49/** 49/**
@@ -54,7 +54,7 @@ static void instproxy_lock(instproxy_client_t client)
54static void instproxy_unlock(instproxy_client_t client) 54static void instproxy_unlock(instproxy_client_t client)
55{ 55{
56 debug_info("InstallationProxy: Unlocked"); 56 debug_info("InstallationProxy: Unlocked");
57 g_mutex_unlock(client->mutex); 57 pthread_mutex_unlock(&client->mutex);
58} 58}
59 59
60/** 60/**
@@ -96,10 +96,6 @@ static instproxy_error_t instproxy_error(property_list_service_error_t err)
96 */ 96 */
97instproxy_error_t instproxy_client_new(idevice_t device, uint16_t port, instproxy_client_t *client) 97instproxy_error_t instproxy_client_new(idevice_t device, uint16_t port, instproxy_client_t *client)
98{ 98{
99 /* makes sure thread environment is available */
100 if (!g_thread_supported())
101 g_thread_init(NULL);
102
103 if (!device) 99 if (!device)
104 return INSTPROXY_E_INVALID_ARG; 100 return INSTPROXY_E_INVALID_ARG;
105 101
@@ -110,8 +106,8 @@ instproxy_error_t instproxy_client_new(idevice_t device, uint16_t port, instprox
110 106
111 instproxy_client_t client_loc = (instproxy_client_t) malloc(sizeof(struct instproxy_client_private)); 107 instproxy_client_t client_loc = (instproxy_client_t) malloc(sizeof(struct instproxy_client_private));
112 client_loc->parent = plistclient; 108 client_loc->parent = plistclient;
113 client_loc->mutex = g_mutex_new(); 109 pthread_mutex_init(&client_loc->mutex, NULL);
114 client_loc->status_updater = NULL; 110 client_loc->status_updater = (pthread_t)NULL;
115 111
116 *client = client_loc; 112 *client = client_loc;
117 return INSTPROXY_E_SUCCESS; 113 return INSTPROXY_E_SUCCESS;
@@ -135,11 +131,9 @@ instproxy_error_t instproxy_client_free(instproxy_client_t client)
135 client->parent = NULL; 131 client->parent = NULL;
136 if (client->status_updater) { 132 if (client->status_updater) {
137 debug_info("joining status_updater"); 133 debug_info("joining status_updater");
138 g_thread_join(client->status_updater); 134 pthread_join(client->status_updater, NULL);
139 }
140 if (client->mutex) {
141 g_mutex_free(client->mutex);
142 } 135 }
136 pthread_mutex_destroy(&client->mutex);
143 free(client); 137 free(client);
144 138
145 return INSTPROXY_E_SUCCESS; 139 return INSTPROXY_E_SUCCESS;
@@ -349,7 +343,7 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client,
349 * 343 *
350 * @return Always NULL. 344 * @return Always NULL.
351 */ 345 */
352static gpointer instproxy_status_updater(gpointer arg) 346static void* instproxy_status_updater(void* arg)
353{ 347{
354 struct instproxy_status_data *data = (struct instproxy_status_data*)arg; 348 struct instproxy_status_data *data = (struct instproxy_status_data*)arg;
355 349
@@ -362,7 +356,7 @@ static gpointer instproxy_status_updater(gpointer arg)
362 if (data->operation) { 356 if (data->operation) {
363 free(data->operation); 357 free(data->operation);
364 } 358 }
365 data->client->status_updater = NULL; 359 data->client->status_updater = (pthread_t)NULL;
366 instproxy_unlock(data->client); 360 instproxy_unlock(data->client);
367 free(data); 361 free(data);
368 362
@@ -397,8 +391,7 @@ static instproxy_error_t instproxy_create_status_updater(instproxy_client_t clie
397 data->operation = strdup(operation); 391 data->operation = strdup(operation);
398 data->user_data = user_data; 392 data->user_data = user_data;
399 393
400 client->status_updater = g_thread_create(instproxy_status_updater, data, TRUE, NULL); 394 if (pthread_create(&client->status_updater, NULL, instproxy_status_updater, data) == 0) {
401 if (client->status_updater) {
402 res = INSTPROXY_E_SUCCESS; 395 res = INSTPROXY_E_SUCCESS;
403 } 396 }
404 } 397 }