diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-07 17:59:21 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-07 17:59:21 +0000 |
commit | 76494a2d103c88d1c3888a6f0348a6b7e31b564d (patch) | |
tree | 14e5b1ce78a004bf1154cb1091782f32f19fb8b5 /nuttx/net | |
parent | 24151ccd83ce2d0d75bb9c45b137215c24c821c3 (diff) | |
download | px4-nuttx-76494a2d103c88d1c3888a6f0348a6b7e31b564d.tar.gz px4-nuttx-76494a2d103c88d1c3888a6f0348a6b7e31b564d.tar.bz2 px4-nuttx-76494a2d103c88d1c3888a6f0348a6b7e31b564d.zip |
Fix network poll() issue: don't interrupt poll if socket not connected. Listen sockets are not connected and the poll() is waiting for connection events.
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5717 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net')
-rw-r--r-- | nuttx/net/net_poll.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/nuttx/net/net_poll.c b/nuttx/net/net_poll.c index 1838f541e..583d469a7 100644 --- a/nuttx/net/net_poll.c +++ b/nuttx/net/net_poll.c @@ -253,9 +253,24 @@ static inline int net_pollsetup(FAR struct socket *psock, fds->revents |= (POLLOUT & fds->events); } - /* Check for a loss of connection events */ + /* Check for a loss of connection events. We need to be careful here. + * There are four possibilities: + * + * 1) The socket is connected and we are waiting for data availability + * events. + * 2) This is a listener socket that was never connected and we are + * waiting for connection events. + * 3) This socket was previously connected, but the peer has gracefully + * closed the connection. + * 4) This socket was previously connected, but we lost the connection + * due to some exceptional event. + * + * We can detect 1) and 3), but 2) and 4) appear the same. So we + * do the best we can for now: We will report POLLHUP if the socket + * has been gracefully closed. + */ - if (!_SS_ISCONNECTED(psock->s_flags)) + if (_SS_ISCLOSED(psock->s_flags)) { fds->revents |= (POLLERR | POLLHUP); } |