diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-10-24 09:09:40 +0000 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-10-24 09:09:40 +0000 |
commit | b05290df28e380ddc789fd5e7eada95e9adef389 (patch) | |
tree | 016e36503f658e209f76e2b6bfc8d37bb23fc04c /src/tools/oping/oping_client.c | |
parent | 1c06b9ff80a2bf7ee6042534fee6098f7e452b59 (diff) | |
parent | c4d765b68047176fb83ebc5a7462a68a5d051008 (diff) | |
download | ouroboros-b05290df28e380ddc789fd5e7eada95e9adef389.tar.gz ouroboros-b05290df28e380ddc789fd5e7eada95e9adef389.zip |
Merged in dstaesse/ouroboros/be-oping (pull request #277)
tools: Fix memory leaks in oping
Diffstat (limited to 'src/tools/oping/oping_client.c')
-rw-r--r-- | src/tools/oping/oping_client.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c index 9f49a1df..85cb2880 100644 --- a/src/tools/oping/oping_client.c +++ b/src/tools/oping/oping_client.c @@ -64,16 +64,14 @@ void * reader(void * o) int msg_len = 0; double ms = 0; double d = 0; - fqueue_t * fq = fqueue_create(); - if (fq == NULL) - return (void *) 1; (void) o; /* FIXME: use flow timeout option once we have it */ while (client.rcvd != client.count - && flow_event_wait(client.flows, fq, &timeout) != -ETIMEDOUT) { - while ((fd = fqueue_next(fq)) >= 0) { + && (flow_event_wait(client.flows, client.fq, &timeout) + != -ETIMEDOUT)) { + while ((fd = fqueue_next(client.fq)) >= 0) { msg_len = flow_read(fd, buf, OPING_BUF_SIZE); if (msg_len < 0) continue; @@ -175,7 +173,13 @@ int client_main(void) client.flows = flow_set_create(); if (client.flows == NULL) - return 0; + return -1; + + client.fq = fqueue_create(); + if (client.fq == NULL) { + flow_set_destroy(client.flows); + return -1; + } fd = flow_alloc(client.s_apn, NULL, NULL); if (fd < 0) { @@ -251,6 +255,8 @@ int client_main(void) pthread_mutex_lock(&client.lock); free(client.times); + flow_set_destroy(client.flows); + fqueue_destroy(client.fq); pthread_mutex_unlock(&client.lock); pthread_mutex_destroy(&client.lock); |