Mixing async and sync after a fork

Bo Lorentsen bl at lue.dk
Thu Jan 10 17:05:25 CET 2013


Hi ...

I have been playing with libev (ev++ in C++11) for a while now in a pure 
async setup for a while, and I have to say libev is a small but really 
nice peace of work, so thanks Mark :-)

I needed to implement a set of long poll like function in some existing 
code base that uses, normal synchronous worker threads as the base of 
operation. These worker threads also works using database connections 
(PG), and other things (curl).

The thing is ... this works amazingly, until I try to startup this app 
as a daemon (fork). And yes, when i start it as i daemon i make sure to 
call ev::post_fork(), and my default loop starts up as it is supposed to 
(but later or lazy really), without any problems (in its own libev 
thread), but it seems like any socket connections made after the fork 
between ev::post_fork() and ev::default_loop().run() are invalid after 
calling run.

Is something happening inside ev::default_loop().run(), what may hurt 
existing sockets when using ev::post_fork() ?

Are there something obvious I am missing ?

Regards

/BL



More information about the libev mailing list