summaryrefslogtreecommitdiffstats
path: root/src/installation_proxy.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2014-12-26 12:23:52 +0100
committerGravatar Martin Szulecki2015-01-13 00:14:55 +0100
commitf3c4db4f30731f6cfc2c37a39d5ce3501d42f45e (patch)
treecaa0ffcfdd84a31c945408e9e7ccd56b72318e2e /src/installation_proxy.c
parentaa14c053bc909c56d31c12799f13013f845ddb71 (diff)
downloadlibimobiledevice-f3c4db4f30731f6cfc2c37a39d5ce3501d42f45e.tar.gz
libimobiledevice-f3c4db4f30731f6cfc2c37a39d5ce3501d42f45e.tar.bz2
thread: Introduce thread_new and thread_free to cover handle leaks on WIN32
Diffstat (limited to 'src/installation_proxy.c')
-rw-r--r--src/installation_proxy.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/installation_proxy.c b/src/installation_proxy.c
index d17d6c5..9a11e36 100644
--- a/src/installation_proxy.c
+++ b/src/installation_proxy.c
@@ -120,6 +120,8 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_free(instproxy_client_t
120 if (client->status_updater) { 120 if (client->status_updater) {
121 debug_info("joining status_updater"); 121 debug_info("joining status_updater");
122 thread_join(client->status_updater); 122 thread_join(client->status_updater);
123 thread_free(client->status_updater);
124 client->status_updater = (thread_t)NULL;
123 } 125 }
124 mutex_destroy(&client->mutex); 126 mutex_destroy(&client->mutex);
125 free(client); 127 free(client);
@@ -320,7 +322,7 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client,
320 * @return Always NULL. 322 * @return Always NULL.
321 */ 323 */
322static void* instproxy_status_updater(void* arg) 324static void* instproxy_status_updater(void* arg)
323{ 325{
324 struct instproxy_status_data *data = (struct instproxy_status_data*)arg; 326 struct instproxy_status_data *data = (struct instproxy_status_data*)arg;
325 327
326 /* run until the operation is complete or an error occurs */ 328 /* run until the operation is complete or an error occurs */
@@ -332,7 +334,10 @@ static void* instproxy_status_updater(void* arg)
332 if (data->operation) { 334 if (data->operation) {
333 free(data->operation); 335 free(data->operation);
334 } 336 }
335 data->client->status_updater = (thread_t)NULL; 337 if (data->client->status_updater) {
338 thread_free(data->client->status_updater);
339 data->client->status_updater = (thread_t)NULL;
340 }
336 instproxy_unlock(data->client); 341 instproxy_unlock(data->client);
337 free(data); 342 free(data);
338 343
@@ -367,7 +372,7 @@ static instproxy_error_t instproxy_create_status_updater(instproxy_client_t clie
367 data->operation = strdup(operation); 372 data->operation = strdup(operation);
368 data->user_data = user_data; 373 data->user_data = user_data;
369 374
370 if (thread_create(&client->status_updater, instproxy_status_updater, data) == 0) { 375 if (thread_new(&client->status_updater, instproxy_status_updater, data) == 0) {
371 res = INSTPROXY_E_SUCCESS; 376 res = INSTPROXY_E_SUCCESS;
372 } 377 }
373 } 378 }