diff options
author | Martin Szulecki | 2014-12-26 12:23:52 +0100 |
---|---|---|
committer | Martin Szulecki | 2015-01-13 00:14:55 +0100 |
commit | f3c4db4f30731f6cfc2c37a39d5ce3501d42f45e (patch) | |
tree | caa0ffcfdd84a31c945408e9e7ccd56b72318e2e /tools | |
parent | aa14c053bc909c56d31c12799f13013f845ddb71 (diff) | |
download | libimobiledevice-f3c4db4f30731f6cfc2c37a39d5ce3501d42f45e.tar.gz libimobiledevice-f3c4db4f30731f6cfc2c37a39d5ce3501d42f45e.tar.bz2 |
thread: Introduce thread_new and thread_free to cover handle leaks on WIN32
Diffstat (limited to 'tools')
-rw-r--r-- | tools/idevicedebugserverproxy.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/idevicedebugserverproxy.c b/tools/idevicedebugserverproxy.c index 9ccb3c3..475749f 100644 --- a/tools/idevicedebugserverproxy.c +++ b/tools/idevicedebugserverproxy.c @@ -139,7 +139,7 @@ static void *thread_client_to_device(void *data) /* spawn server to client thread */ socket_info->stop_dtoc = 0; - if (thread_create(&dtoc, thread_device_to_client, data) != 0) { + if (thread_new(&dtoc, thread_device_to_client, data) != 0) { fprintf(stderr, "Failed to start device to client thread...\n"); } @@ -187,6 +187,7 @@ static void *thread_client_to_device(void *data) /* join other thread to allow it to stop */ thread_join(dtoc); + thread_free(dtoc); return NULL; } @@ -200,12 +201,13 @@ static void* connection_handler(void* data) /* spawn client to device thread */ socket_info->stop_ctod = 0; - if (thread_create(&ctod, thread_client_to_device, data) != 0) { + if (thread_new(&ctod, thread_client_to_device, data) != 0) { fprintf(stderr, "Failed to start client to device thread...\n"); } /* join the fun */ thread_join(ctod); + thread_free(ctod); /* shutdown client socket */ socket_shutdown(socket_info->client_fd, SHUT_RDWR); @@ -348,11 +350,15 @@ int main(int argc, char *argv[]) debug("%s: Handling new client connection...\n", __func__); - if (thread_create(&th, connection_handler, (void*)&socket_info) != 0) { + if (thread_new(&th, connection_handler, (void*)&socket_info) != 0) { fprintf(stderr, "Could not start connection handler.\n"); socket_shutdown(socket_info.server_fd, SHUT_RDWR); socket_close(socket_info.server_fd); + continue; } + + /* we do not need it anymore */ + thread_free(th); } debug("%s: Shutting down debugserver proxy...\n", __func__); |