From 00761652fb55e16227508457da4bda82b19ef193 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 4 Aug 2016 21:27:45 +0200 Subject: tools: oping: Fix client cleanup --- src/tools/oping/oping_client.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c index 7693ce41..b47eee6c 100644 --- a/src/tools/oping/oping_client.c +++ b/src/tools/oping/oping_client.c @@ -132,12 +132,15 @@ void * writer(void * o) printf("Pinging %s with %d bytes of data:\n\n", client.s_apn, client.size); + pthread_cleanup_push((void (*) (void *)) free, buf); + while (client.sent < client.count) { nanosleep(&wait, NULL); msg->id = htonl(client.sent); if (flow_write(*fdp, buf, client.size) == -1) { printf("Failed to send SDU.\n"); flow_dealloc(*fdp); + free(buf); return (void *) -1; } @@ -148,6 +151,8 @@ void * writer(void * o) pthread_mutex_unlock(&client.lock); } + pthread_cleanup_pop(true); + return (void *) 0; } -- cgit v1.2.3