best way to get a 1-second timer-tick?

Neil Mckee at
Fri Apr 22 22:02:01 MSD 2011


I have written a module to implement sFlow in nginx  (   I'm simulating a 1-second timer-tick by assuming that the request handler will be called at least once per second.   That's probably a safe assumption for any server that would care about sFlow monitoring,  but I expect there's a better way...

I tried asking for a timer callback like this:

ngx_event_t *ev = ngx_pcalloc(pool, sizeof(ngx_event_t));
ev->hander = ngx_http_sflow_tick_event_hander;
ngx_add_timer(ev, 1000);

but (like most russian girls) the event never called me back.  It looks like I might have to hang this on a file-descriptor somehow,  but that's where I'm getting lost.  Any pointers would be most appreciated.


More information about the nginx-devel mailing list