Commit ccbc17c9 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

server: Add a helper to post socket events.

parent 9fd8a298
...@@ -612,50 +612,40 @@ static int sock_dispatch_asyncs( struct sock *sock, int event, int error ) ...@@ -612,50 +612,40 @@ static int sock_dispatch_asyncs( struct sock *sock, int event, int error )
return event; return event;
} }
static void post_socket_event( struct sock *sock, unsigned int event_bit, unsigned int error )
{
unsigned int event = (1 << event_bit);
sock->pmask |= event;
sock->hmask |= event;
sock->errors[event_bit] = error;
}
static void sock_dispatch_events( struct sock *sock, int prevstate, int event, int error ) static void sock_dispatch_events( struct sock *sock, int prevstate, int event, int error )
{ {
if (prevstate & FD_CONNECT) if (prevstate & FD_CONNECT)
{ {
sock->pmask |= FD_CONNECT; post_socket_event( sock, FD_CONNECT_BIT, sock_get_error( error ) );
sock->hmask |= FD_CONNECT;
sock->errors[FD_CONNECT_BIT] = sock_get_error( error );
goto end; goto end;
} }
if (prevstate & FD_WINE_LISTENING) if (prevstate & FD_WINE_LISTENING)
{ {
sock->pmask |= FD_ACCEPT; post_socket_event( sock, FD_ACCEPT_BIT, sock_get_error( error ) );
sock->hmask |= FD_ACCEPT;
sock->errors[FD_ACCEPT_BIT] = sock_get_error( error );
goto end; goto end;
} }
if (event & POLLIN) if (event & POLLIN)
{ post_socket_event( sock, FD_READ_BIT, 0 );
sock->pmask |= FD_READ;
sock->hmask |= FD_READ;
sock->errors[FD_READ_BIT] = 0;
}
if (event & POLLOUT) if (event & POLLOUT)
{ post_socket_event( sock, FD_WRITE_BIT, 0 );
sock->pmask |= FD_WRITE;
sock->hmask |= FD_WRITE;
sock->errors[FD_WRITE_BIT] = 0;
}
if (event & POLLPRI) if (event & POLLPRI)
{ post_socket_event( sock, FD_OOB_BIT, 0 );
sock->pmask |= FD_OOB;
sock->hmask |= FD_OOB;
sock->errors[FD_OOB_BIT] = 0;
}
if (event & (POLLERR|POLLHUP)) if (event & (POLLERR|POLLHUP))
{ post_socket_event( sock, FD_CLOSE_BIT, sock_get_error( error ) );
sock->pmask |= FD_CLOSE;
sock->hmask |= FD_CLOSE;
sock->errors[FD_CLOSE_BIT] = sock_get_error( error );
}
end: end:
sock_wake_up( sock ); sock_wake_up( sock );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment