Handle socket POLLERR/POLLHUP conditions properly.

Clear error field for OOB notifications.
This commit is contained in:
Ove Kaaven 2000-03-25 21:41:43 +00:00 committed by Alexandre Julliard
parent 65a0fa6e4e
commit 77c30552aa
1 changed files with 15 additions and 1 deletions

View File

@ -78,9 +78,19 @@ static const struct object_ops sock_ops =
static void sock_reselect( struct sock *sock )
{
int ev = sock_get_poll_events( &sock->obj );
struct pollfd pfd;
if (debug_level)
fprintf(stderr,"sock_reselect(%d): new mask %x\n", sock->obj.fd, ev);
set_select_events( &sock->obj, ev );
/* check whether condition is satisfied already */
pfd.fd = sock->obj.fd;
pfd.events = ev;
pfd.revents = 0;
poll( &pfd, 1, 0 );
if (pfd.revents & (POLLIN|POLLOUT|POLLPRI))
sock_poll_event( &sock->obj, pfd.revents);
}
inline static int sock_error(int s)
@ -163,6 +173,7 @@ static void sock_poll_event( struct object *obj, int event )
{
sock->pmask |= FD_OOB;
sock->hmask |= FD_OOB;
sock->errors[FD_OOB_BIT] = 0;
if (debug_level)
fprintf(stderr, "socket %d got OOB data\n", sock->obj.fd);
}
@ -178,6 +189,9 @@ static void sock_poll_event( struct object *obj, int event )
}
}
if (event & (POLLERR|POLLHUP))
set_select_events( &sock->obj, -1 );
else
sock_reselect( sock );
/* wake up anyone waiting for whatever just happened */
emask = sock->pmask & sock->mask;