diff --git a/server/include/path.h b/server/include/path.h index 040dce01a..ce51ebd40 100644 --- a/server/include/path.h +++ b/server/include/path.h @@ -58,6 +58,8 @@ struct path /** Counter for dropped messages due to reordering */ unsigned int dropped; + /** A timer used for fixed rate transmission. */ + timer_t timer; /** The thread id for this path */ pthread_t recv_tid; /** A second thread id for fixed rate sending thread */ diff --git a/server/src/path.c b/server/src/path.c index 7a2a29b33..1cb8aea56 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -26,9 +26,9 @@ struct list paths; /** Send messages asynchronously */ static void * path_send(void *arg) { + struct path *p = arg; + int sig; - struct path *p = (struct path *) arg; - timer_t tmr; sigset_t set; struct sigevent sev = { @@ -47,10 +47,10 @@ static void * path_send(void *arg) if(pthread_sigmask(SIG_BLOCK, &set, NULL)) serror("Set signal mask"); - if (timer_create(CLOCK_REALTIME, &sev, &tmr)) + if (timer_create(CLOCK_REALTIME, &sev, &p->timer)) serror("Failed to create timer"); - if (timer_settime(tmr, 0, &its, NULL)) + if (timer_settime(p->timer, 0, &its, NULL)) serror("Failed to start timer"); while (1) { @@ -178,6 +178,8 @@ int path_stop(struct path *p) if (p->rate) { pthread_cancel(p->sent_tid); pthread_join(p->sent_tid, NULL); + + timer_delete(p->timer); } if (p->sent || p->received) {