mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
CC3000: Fix a race condition in start-up of unsoliced_thread. From Jussi Kivilinna
This commit is contained in:
@@ -90,6 +90,7 @@ static struct
|
|||||||
cc3000_buffer_desc rx_buffer;
|
cc3000_buffer_desc rx_buffer;
|
||||||
mqd_t queue;
|
mqd_t queue;
|
||||||
sem_t *done;
|
sem_t *done;
|
||||||
|
sem_t unsoliced_thread_wakesem;
|
||||||
} spiconf;
|
} spiconf;
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
@@ -209,6 +210,8 @@ static void *unsoliced_thread_func(void *parameter)
|
|||||||
spiconf.done = sem_open(buff,O_RDONLY);
|
spiconf.done = sem_open(buff,O_RDONLY);
|
||||||
DEBUGASSERT(spiconf.done != (sem_t *)-1);
|
DEBUGASSERT(spiconf.done != (sem_t *)-1);
|
||||||
|
|
||||||
|
sem_post(&spiconf.unsoliced_thread_wakesem);
|
||||||
|
|
||||||
while (spiconf.run)
|
while (spiconf.run)
|
||||||
{
|
{
|
||||||
memset(&spiconf.rx_buffer,0,sizeof(spiconf.rx_buffer));
|
memset(&spiconf.rx_buffer,0,sizeof(spiconf.rx_buffer));
|
||||||
@@ -255,6 +258,8 @@ void cc3000_open(gcSpiHandleRx pfRxHandler)
|
|||||||
spiconf.cc3000fd = fd;
|
spiconf.cc3000fd = fd;
|
||||||
spiconf.run = true;
|
spiconf.run = true;
|
||||||
|
|
||||||
|
sem_init(&spiconf.unsoliced_thread_wakesem, 0, 0);
|
||||||
|
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
struct sched_param param;
|
struct sched_param param;
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
@@ -265,6 +270,13 @@ void cc3000_open(gcSpiHandleRx pfRxHandler)
|
|||||||
unsoliced_thread_func, NULL);
|
unsoliced_thread_func, NULL);
|
||||||
DEBUGASSERT(status == 0)
|
DEBUGASSERT(status == 0)
|
||||||
UNUSED(status);
|
UNUSED(status);
|
||||||
|
|
||||||
|
/* Wait unsoliced_thread to wake-up. */
|
||||||
|
|
||||||
|
while (sem_wait(&spiconf.unsoliced_thread_wakesem) != 0)
|
||||||
|
{
|
||||||
|
ASSERT(errno == EINTR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGASSERT(spiconf.cc3000fd);
|
DEBUGASSERT(spiconf.cc3000fd);
|
||||||
|
|||||||
Reference in New Issue
Block a user