Not to terminate ev_loop

Sandeep sandeep at
Sun Jan 8 07:25:33 CET 2012



I am very new to libev and I have to use libev only for very few features in
my project hence could not get to go through the libev manual completely. 

Hence I would request you to kindly give me pointers on the below questions:


I have a server thread which works on specific requests and I have other
threads which post requests to the server thread. I am using libev in the
server thread, where as the client thread/threads do not have any knowledge
about libev mechanisms.

My client threads will send requests to the server thread using some API
mechanism and would expect the response to be sent from server thread
asynchronously. My server thread is using libev in the following way: it
creates a ev_loop and initializes it to ev_default_loop. Then registers a
timer variable using ev_timer_init with specified timer values. Also I am
using ev_io_init/start/stop to track some events on specific socket
connection. What is happening is when I call ev_loop(loop,0) all my requests
associated with the sockets that are currently active are served and once
all the requests are over, my thread (server thread) is getting
automatically terminated (by ev_loop(loop,0) if my understanding is correct)
though I am explicitly running my thread all the time in a run loop.


Having said that, my requirement is such that, my server thread should be
all the time running irrespective of whether the server has any outstanding
requests or not. What I mean is, when there are no requests, server must be
simple idle, but when request is there it must server. But as I said, if I
call ev_loop(loop, 0), my thread gets terminated as soon as there are no
requests or all the requests are completed. I even tried not calling
ev_loop(loop, 0), in which case everything is messed up and no events are


Kindly help me as I have very limited understanding of libev and my
requirement is very specific in my project.


Thanks and Regards,

-Sandeep A

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the libev mailing list