socket: fix EPOLLONESHOT semantics
When EPOLLONESHOT is specified, rather than deleting the socket, just clear it's event mask.
This commit is contained in:
parent
530da04ede
commit
153bc1138a
@ -286,10 +286,10 @@ int ep_sock_feed_event(ep_port_t* port_info,
|
||||
/* Filter events that the user didn't ask for. */
|
||||
epoll_events &= sock_private->user_events;
|
||||
|
||||
/* Drop the socket if the EPOLLONESHOT flag is set and there are any events
|
||||
/* Clear the event mask if EPOLLONESHOT is set and there are any events
|
||||
* to report. */
|
||||
if (epoll_events != 0 && (sock_private->user_events & EPOLLONESHOT))
|
||||
drop_socket = true;
|
||||
sock_private->user_events = EPOLLERR | EPOLLHUP;
|
||||
|
||||
/* Fill the ev structure if there are any events to report. */
|
||||
if (epoll_events != 0) {
|
||||
|
||||
@ -165,7 +165,7 @@ int main(int argc, char* argv[]) {
|
||||
struct epoll_event e;
|
||||
e.data.sock = sock;
|
||||
e.events = rev;
|
||||
if (epoll_ctl(epoll_hnd, EPOLL_CTL_ADD, sock, &e) < 0)
|
||||
if (epoll_ctl(epoll_hnd, EPOLL_CTL_MOD, sock, &e) < 0)
|
||||
abort();
|
||||
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user