diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-07 18:43:03 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-07 18:43:03 +0000 |
commit | 62bccf6b7538cafa63e0ea91ccb603f58417a49a (patch) | |
tree | 286f2aede6b0e5e1d6e68af582ac8c61836d1c09 /nuttx/net | |
parent | 76494a2d103c88d1c3888a6f0348a6b7e31b564d (diff) | |
download | px4-nuttx-62bccf6b7538cafa63e0ea91ccb603f58417a49a.tar.gz px4-nuttx-62bccf6b7538cafa63e0ea91ccb603f58417a49a.tar.bz2 px4-nuttx-62bccf6b7538cafa63e0ea91ccb603f58417a49a.zip |
Fix a whole in the logic from the previous check-in
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5718 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net')
-rw-r--r-- | nuttx/net/net_poll.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/nuttx/net/net_poll.c b/nuttx/net/net_poll.c index 583d469a7..55ede320d 100644 --- a/nuttx/net/net_poll.c +++ b/nuttx/net/net_poll.c @@ -258,20 +258,48 @@ static inline int net_pollsetup(FAR struct socket *psock, * * 1) The socket is connected and we are waiting for data availability * events. + * + * __SS_ISCONNECTED(f) == true + * __SS_ISLISTENING(f) == false + * __SS_ISCLOSED(f) == false + * + * Action: Wait for data availability events + * * 2) This is a listener socket that was never connected and we are * waiting for connection events. + * + * __SS_ISCONNECTED(f) == false + * __SS_ISLISTENING(f) == true + * __SS_ISCLOSED(f) == false + * + * Action: Wait for connection events + * * 3) This socket was previously connected, but the peer has gracefully * closed the connection. + * + * __SS_ISCONNECTED(f) == false + * __SS_ISLISTENING(f) == false + * __SS_ISCLOSED(f) == true + * + * Action: Return with POLLHUP|POLLERR events + * * 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. + * __SS_ISCONNECTED(f) == false + * __SS_ISLISTENING(f) == false + * __SS_ISCLOSED(f) == false + * + * Action: Return with POLLHUP|POLLERR events */ - if (_SS_ISCLOSED(psock->s_flags)) + if (!_SS_ISCONNECTED(psock->s_flags) && !_SS_ISLISTENING(psock->s_flags)) { + /* We were previously connected but lost the connection either due + * to a graceful shutdown by the remote peer or because of some + * exceptional event. + */ + fds->revents |= (POLLERR | POLLHUP); } |