summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-21 14:17:11 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-21 14:17:11 +0000
commit6df34664393172bf2acd0be5a3a3ba796be653a8 (patch)
tree678b54db4e147eb7bfbb5710efd5980844226be5
parent28695c8508c93758792dd4ecfb884e108b87c48b (diff)
downloadnuttx-6df34664393172bf2acd0be5a3a3ba796be653a8.tar.gz
nuttx-6df34664393172bf2acd0be5a3a3ba796be653a8.tar.bz2
nuttx-6df34664393172bf2acd0be5a3a3ba796be653a8.zip
poll was not checking if the socket was still connected
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5543 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/net/net_poll.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/nuttx/net/net_poll.c b/nuttx/net/net_poll.c
index 815c6a71d..2e73bd73c 100644
--- a/nuttx/net/net_poll.c
+++ b/nuttx/net/net_poll.c
@@ -125,16 +125,22 @@ static uint16_t poll_interrupt(struct uip_driver_s *dev, FAR void *conn,
if ((flags & UIP_POLL) != 0)
{
- eventset |= POLLOUT & fds->events;
+ eventset |= (POLLOUT & fds->events);
}
- /* Check for a loss of connection events */
+ /* Check for a loss of connection events.
+ *
+ * REVISIT: Need to call net_lostconnection() here, but don't have
+ * the psock instance. What should we do?
+ */
if ((flags & (UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT)) != 0)
{
- eventset |= (POLLERR|POLLHUP);
+ eventset |= (POLLERR | POLLHUP);
}
+ /* Awaken the caller of poll() is requested event occurred. */
+
if (eventset)
{
fds->revents |= eventset;
@@ -192,9 +198,9 @@ static inline int net_pollsetup(FAR struct socket *psock, struct pollfd *fds)
goto errout_with_irq;
}
- /* Initialize the callbcack structure */
+ /* Initialize the callback structure */
- cb->flags = UIP_NEWDATA|UIP_BACKLOG|UIP_POLL|UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT;
+ cb->flags = (UIP_NEWDATA|UIP_BACKLOG|UIP_POLL|UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT);
cb->priv = (FAR void *)fds;
cb->event = poll_interrupt;
@@ -212,13 +218,23 @@ static inline int net_pollsetup(FAR struct socket *psock, struct pollfd *fds)
if (!sq_empty(&conn->readahead))
#endif
{
- fds->revents = fds->events & POLLIN;
- if (fds->revents != 0)
- {
- /* If data is available now, the signal the poll logic */
+ fds->revents |= (POLLOUT & fds->events);
+ }
- sem_post(fds->sem);
- }
+ /* Check for a loss of connection events */
+
+ if (!_SS_ISCONNECTED(psock->s_flags))
+ {
+ fds->revents |= (POLLERR | POLLHUP);
+ }
+
+ /* Check if any requested events are already in effect */
+
+ if (fds->revents != 0)
+ {
+ /* Yes.. then signal the poll logic */
+
+ sem_post(fds->sem);
}
uip_unlock(flags);