1
struct epoll_event ev, events[20];
ev.events = EPOLLOUT | EPOLLONESHOT;
ev.data.sock = some_socket;
epoll_ctl(epfd, EPOLL_CTL_ADD, some_socket, &ev);
// then the EPOLLOUT event has triggered by epoll_wait
epoll_ctl(epfd, EPOLL_CTL_DEL, some_socket, NULL); // should it be called? will it cause error?

after the EPOLLOUT event has been triggered, the MAN page said the event has now been disabled and will not triggered. I don't know if it's completely same as EPOLL_CTL_DEL. Do I need to manually call EPOLL_CTL_DEL when closing the socket if EPOLLOUT | EPOLLONESHOT is the only event that has been triggered?

benrush
  • 43
  • 4

1 Answers1

0

"When closing the socket" implies you do not need epoll_ctl with EPOLL_CTL_DEL unless there other fine moments. Did you duplicate the fd? No? Then you don't need to. Yes? May depend on the program logic: whether or not you need that socket to close now or it is still monitored. For details please read here: Epoll: does it silently remove fds?

Alexander V
  • 8,351
  • 4
  • 38
  • 47