This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
losing events with EPOLLONESHOT and cancellation
- From: Eric Wong <normalperson at yhbt dot net>
- To: libc-help at sourceware dot org
- Date: Wed, 12 Jun 2013 00:38:48 +0000
- Subject: losing events with EPOLLONESHOT and cancellation
I seem to be encountering lost events with epoll_wait/epoll_pwait when
using EPOLLONESHOT and pthreads cancellation.
Based on my reading of sysdeps/unix/sysv/linux/epoll_pwait.c; if the
result of epoll_pwait is greater than 0 (events are available), it is
still possible for LIBC_CANCEL_RESET to cancel the thread and cause
result to never be returned (to other, uncancelled threads running
epoll_pwait).
Is my observation correct?
relevant code in sysdeps/unix/sysv/linux/epoll_pwait.c
---------------------------------8<--------------------------------
int oldtype = LIBC_CANCEL_ASYNC ();
int result = INLINE_SYSCALL (epoll_pwait, 6, epfd, events, maxevents,
timeout, set, _NSIG / 8);
LIBC_CANCEL_RESET (oldtype);
return result;
---------------------------------8<--------------------------------
Similarly, ports/sysdeps/unix/sysv/linux/generic/recv.c implements
identical logic for recv, so am I correct data could be lost (and not
readable by another, non-cancelled thread) if a recv caller is
cancelled when recv is successful?
Thanks in advance for any help.