Correctly pass watcher to another loop

Vladimir Afinello at
Sat Jun 23 15:26:54 CEST 2012


I have several threads in my program, each running an event loop.
After some period of time I need to pass one client (socket fd) from one
loop to another (and stop monitoring it in the current loop)

In the current loop/thread I perform
then pass the client data to second thread (using some kind of blocking
fifo) and then wake the secon thread using ev_async watcher
In second thread I perform:
pClientData->watcher.start(pClientData->fd, ev::READ);

sometimes it works, but in general the program breaks on
watcher.start(pClientData->fd, ev::READ) with:
ev.c:3250: ev_io_stop: Assertion ("libev: ev_io_stop called with illegal fd
(must stay constant after start!), w->fd >= 0 && w->fd <= ((loop)->anfdmax)

Howether I still can see in the debugger, that the fd is a valid int.

What is the correct way to pass the watcher from one thread/loop to another
(I use Linux x86 with epoll backend)

Best regards, Vladimir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the libev mailing list