summaryrefslogtreecommitdiff
path: root/src/tools/oping/oping_client.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-08-08 10:29:06 +0200
committerSander Vrijders <[email protected]>2016-08-08 10:29:06 +0200
commitc1e1831ded0330771fd175f1c8138ed82c90f9f8 (patch)
tree617e3002ffa5addb364c01d5cd925d8c609b12b5 /src/tools/oping/oping_client.c
parentd5b71449bc18116444720257ba640e3c597ff6e9 (diff)
parent8450af0e2950e5a1415e38702d6169cc8a732294 (diff)
downloadouroboros-c1e1831ded0330771fd175f1c8138ed82c90f9f8.tar.gz
ouroboros-c1e1831ded0330771fd175f1c8138ed82c90f9f8.zip
Merged in dstaesse/ouroboros/be-bugfixing (pull request #187)
bugfixes
Diffstat (limited to 'src/tools/oping/oping_client.c')
-rw-r--r--src/tools/oping/oping_client.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c
index 7693ce41..0d4a10af 100644
--- a/src/tools/oping/oping_client.c
+++ b/src/tools/oping/oping_client.c
@@ -115,7 +115,8 @@ void * writer(void * o)
{
int * fdp = (int *) o;
struct timespec now;
- struct timespec wait = {client.interval / 1000, client.interval % 1000};
+ struct timespec wait = {client.interval / 1000,
+ (client.interval % 1000) * MILLION};
struct oping_msg * msg;
char * buf = malloc(client.size);
@@ -132,12 +133,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 +152,8 @@ void * writer(void * o)
pthread_mutex_unlock(&client.lock);
}
+ pthread_cleanup_pop(true);
+
return (void *) 0;
}