Correctly pass watcher to another loop
2012-06-23 13:26:54 GMT
Greetings,
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
watcher.stop();
ev_unref(thread1_loop_pointer);
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.set(thread2_loop_pointer);
pClientData->watcher.set<&client_class::static_callback_fn>(pClientData);
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) failed)
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 thread/loop?
(I use Linux x86 with epoll backend)
Best regards, Vladimir
_______________________________________________ libev mailing list libev <at> lists.schmorp.de http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
RSS Feed