mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
pollnotify: we should send poll events before semaphore incrementes.
There is a good case on sim platform: When we input some cmd and click enter key to start application in terminal, this context will change to application from IDLE loop. Althrough entey key '\r' has been received to recv buffer and complete post semaphore of reader, but pollnotify may not be called because context change. So when application run poll function, because no events happend and poll enter wait, context will again change to IDLE loop, this pollnotify of IDLE loop will run to send poll events, poll function of applicaton will wake up. It's wrong! Change-Id: I812a889f2e90781a9c3cb4b0251cccc4d32bebd1 Signed-off-by: dongjiuzhu <dongjiuzhu1@xiaomi.com>
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
13e10504c9
commit
d452a05910
+13
-13
@@ -224,19 +224,6 @@ static void ft5x06_notify(FAR struct ft5x06_dev_s *priv)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* If there are threads waiting for read data, then signal one of them
|
||||
* that the read data is available.
|
||||
*/
|
||||
|
||||
if (priv->nwaiters > 0)
|
||||
{
|
||||
/* After posting this semaphore, we need to exit because the FT5x06
|
||||
* is no longer available.
|
||||
*/
|
||||
|
||||
nxsem_post(&priv->waitsem);
|
||||
}
|
||||
|
||||
/* If there are threads waiting on poll() for FT5x06 data to become
|
||||
* available, then wake them up now. NOTE: we wake up all waiting threads
|
||||
* because we do not know that they are going to do. If they all try to
|
||||
@@ -253,6 +240,19 @@ static void ft5x06_notify(FAR struct ft5x06_dev_s *priv)
|
||||
nxsem_post(fds->sem);
|
||||
}
|
||||
}
|
||||
|
||||
/* If there are threads waiting for read data, then signal one of them
|
||||
* that the read data is available.
|
||||
*/
|
||||
|
||||
if (priv->nwaiters > 0)
|
||||
{
|
||||
/* After posting this semaphore, we need to exit because the FT5x06
|
||||
* is no longer available.
|
||||
*/
|
||||
|
||||
nxsem_post(&priv->waitsem);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user