diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-05-21 07:32:32 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-05-21 07:32:32 -0600 |
commit | a258fb9f8de2309b0de77c9674b63ffda4cbe8ea (patch) | |
tree | f62308d03507dfb5090224e1c0fd2418d0e28755 | |
parent | b48c5ace4fff8cd1eeb65a76ae058f78e037bd49 (diff) | |
download | nuttx-a258fb9f8de2309b0de77c9674b63ffda4cbe8ea.tar.gz nuttx-a258fb9f8de2309b0de77c9674b63ffda4cbe8ea.tar.bz2 nuttx-a258fb9f8de2309b0de77c9674b63ffda4cbe8ea.zip |
CC3000: Fix a race condition in start-up of unsoliced_thread. From Jussi Kivilinna
-rw-r--r-- | nuttx/drivers/wireless/cc3000/cc3000drv.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/nuttx/drivers/wireless/cc3000/cc3000drv.c b/nuttx/drivers/wireless/cc3000/cc3000drv.c index d8921fdad..948a98657 100644 --- a/nuttx/drivers/wireless/cc3000/cc3000drv.c +++ b/nuttx/drivers/wireless/cc3000/cc3000drv.c @@ -90,6 +90,7 @@ static struct cc3000_buffer_desc rx_buffer; mqd_t queue; sem_t *done; + sem_t unsoliced_thread_wakesem; } spiconf; /***************************************************************************** @@ -209,6 +210,8 @@ static void *unsoliced_thread_func(void *parameter) spiconf.done = sem_open(buff,O_RDONLY); DEBUGASSERT(spiconf.done != (sem_t *)-1); + sem_post(&spiconf.unsoliced_thread_wakesem); + while (spiconf.run) { memset(&spiconf.rx_buffer,0,sizeof(spiconf.rx_buffer)); @@ -255,6 +258,8 @@ void cc3000_open(gcSpiHandleRx pfRxHandler) spiconf.cc3000fd = fd; spiconf.run = true; + sem_init(&spiconf.unsoliced_thread_wakesem, 0, 0); + pthread_attr_t attr; struct sched_param param; pthread_attr_init(&attr); @@ -265,6 +270,13 @@ void cc3000_open(gcSpiHandleRx pfRxHandler) unsoliced_thread_func, NULL); DEBUGASSERT(status == 0) UNUSED(status); + + /* Wait unsoliced_thread to wake-up. */ + + while (sem_wait(&spiconf.unsoliced_thread_wakesem) != 0) + { + ASSERT(errno == EINTR); + } } DEBUGASSERT(spiconf.cc3000fd); |