From f3c4db4f30731f6cfc2c37a39d5ce3501d42f45e Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 26 Dec 2014 12:23:52 +0100 Subject: thread: Introduce thread_new and thread_free to cover handle leaks on WIN32 --- src/installation_proxy.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/installation_proxy.c') 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 if (client->status_updater) { debug_info("joining status_updater"); thread_join(client->status_updater); + thread_free(client->status_updater); + client->status_updater = (thread_t)NULL; } mutex_destroy(&client->mutex); free(client); @@ -320,7 +322,7 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client, * @return Always NULL. */ static void* instproxy_status_updater(void* arg) -{ +{ struct instproxy_status_data *data = (struct instproxy_status_data*)arg; /* run until the operation is complete or an error occurs */ @@ -332,7 +334,10 @@ static void* instproxy_status_updater(void* arg) if (data->operation) { free(data->operation); } - data->client->status_updater = (thread_t)NULL; + if (data->client->status_updater) { + thread_free(data->client->status_updater); + data->client->status_updater = (thread_t)NULL; + } instproxy_unlock(data->client); free(data); @@ -367,7 +372,7 @@ static instproxy_error_t instproxy_create_status_updater(instproxy_client_t clie data->operation = strdup(operation); data->user_data = user_data; - if (thread_create(&client->status_updater, instproxy_status_updater, data) == 0) { + if (thread_new(&client->status_updater, instproxy_status_updater, data) == 0) { res = INSTPROXY_E_SUCCESS; } } -- cgit v1.1-32-gdbae