summaryrefslogtreecommitdiff
path: root/nuttx/examples/nx/nx_main.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-12-01 22:13:03 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-12-01 22:13:03 +0000
commit0f895f0ed4b2370af37d91c0ecb7649d914ed147 (patch)
tree0aed3e4de0338044be420062103f72c88a430fa3 /nuttx/examples/nx/nx_main.c
parent2e5d80f7a34c92e7182b549bd35e0b218fd100a4 (diff)
downloadpx4-nuttx-0f895f0ed4b2370af37d91c0ecb7649d914ed147.tar.gz
px4-nuttx-0f895f0ed4b2370af37d91c0ecb7649d914ed147.tar.bz2
px4-nuttx-0f895f0ed4b2370af37d91c0ecb7649d914ed147.zip
Fixed for multi-user NX mode
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1386 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/nx/nx_main.c')
-rw-r--r--nuttx/examples/nx/nx_main.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/nuttx/examples/nx/nx_main.c b/nuttx/examples/nx/nx_main.c
index 039b1645e..f30fef119 100644
--- a/nuttx/examples/nx/nx_main.c
+++ b/nuttx/examples/nx/nx_main.c
@@ -485,7 +485,28 @@ static inline int nxeg_muinitialize(void)
while (!g_connected)
{
- (void)sem_wait(&g_semevent);
+ /* Assuming that the incoming message queue is configured non-blocking,
+ * we can poll the event handler here. This accounts for the case where
+ * the server is higher prioirty than the client. In that case, the
+ * server will have already responded to the connection request BEFORE
+ * the nx_eventnotify was called.
+ */
+
+ ret = nx_eventhandler(g_hnx);
+ if (ret == 0)
+ {
+ /* If a message was received, then we are connected */
+
+ g_connected = TRUE;
+ }
+
+ /* Otherwise, we will have to wait for the event handler to wake up up
+ * when we really are connected.
+ */
+ else
+ {
+ (void)sem_wait(&g_semevent);
+ }
}
}
else