ccnl: prevent race condition on teardown

This commit is contained in:
Christian Mehlis 2014-07-06 17:23:16 +02:00
parent 9b5eedeea8
commit 7c10101e83
2 changed files with 7 additions and 2 deletions

View File

@ -413,19 +413,23 @@ void ccnl_riot_relay_start(void)
ccnl_core_cleanup(theRelay); ccnl_core_cleanup(theRelay);
mutex_lock(&theRelay->stop_lock);
ccnl_free(theRelay); ccnl_free(theRelay);
} }
void ccnl_riot_relay_helper_start(void) void ccnl_riot_relay_helper_start(void)
{ {
unsigned long us = CCNL_CHECK_RETRANSMIT_USEC; unsigned long us = CCNL_CHECK_RETRANSMIT_USEC;
mutex_lock(&theRelay->stop_lock);
while (!theRelay->halt_flag) { while (!theRelay->halt_flag) {
vtimer_usleep(us);
mutex_lock(&theRelay->global_lock); mutex_lock(&theRelay->global_lock);
ccnl_run_events(); ccnl_run_events();
mutex_unlock(&theRelay->global_lock); mutex_unlock(&theRelay->global_lock);
vtimer_usleep(us);
} }
mutex_unlock(&theRelay->stop_lock);
} }
// eof // eof

View File

@ -107,6 +107,7 @@ struct ccnl_relay_s {
int riot_pid; int riot_pid;
int riot_helper_pid; int riot_helper_pid;
mutex_t global_lock; mutex_t global_lock;
mutex_t stop_lock;
}; };
struct ccnl_buf_s { struct ccnl_buf_s {