I am new to linux server programming with epoll. I have 2 threads: Thread_Accept and Thread_epoll. The former is block accept loop, if new connection is coming, it will add the new fd with epoll_ctl(). The latter is a big epoll_wait() loop.
Now my question is: What if when Thread_Accept executing epoll_ctl() while the Thread_epoll is in the middle of epoll_wait? Will it got any side effect?
Thanks in advance.
regards, Martin
From the epoll_wait man page:
While one thread is blocked in a call to epoll_pwait(), it is possible for another thread to add a file descriptor to the waited-upon epoll instance. If the new file descriptor becomes ready, it will cause the epoll_wait() call to unblock.
So, no side effects when adding a new file descriptor :-)
(This man page note is the result of the bug mentioned by nathansizemore)