Re: Thread safety for epoll/libaio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2006-02-28 at 15:36 -0500, Li, Peng wrote:

> Thread B:  while(1) { epoll_wait();  ... }
> // same as thread A
> Thread D:  ... epoll_ctl(); ....
> 
> Suppose thread B calls epoll_wait and blocks before thread D calls
> epoll_ctl.  Is it safe to do so? Will thread B be notified for the
> event submitted by thread D? 

Hello,

I have some (more) expirience with epoll and threads and it seem to work
well. If you have epoll_wait() in one thread and another thread do
epoll_ctl to add a handle, epoll_wait will wake up as soon as the handle
is ready for operation (most of the time instantly, when operation is
write). 

epoll man page states:

              Q6     Will the close of an fd cause it to be removed from
all epoll sets automatically?

              A6     Yes.
but I was experiencing some (rare) segfaults with my application while
benchmarking it when I just closing my descriptors. Debugging showed,
that I'm getting events for destroyed objects (with closed descriptors).
Adding epoll_ctl(..., EPOLL_CTL_DEL, ...) fixed this.



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux