socket: fix EPOLLONESHOT semantics

When EPOLLONESHOT is specified, rather than deleting the socket, just
clear it's event mask.
This commit is contained in:
Bert Belder 2017-09-14 00:21:50 +02:00
parent 530da04ede
commit 153bc1138a
2 changed files with 3 additions and 3 deletions

View File

@ -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) {

View File

@ -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;