mirror of
https://github.com/nginx/nginx.git
synced 2024-12-20 06:03:31 -06:00
nginx-0.0.1-2003-01-21-20:36:01 import
This commit is contained in:
parent
de8fcead5e
commit
6b7cfab3a6
33
src/event/ngx_event_timer.c
Normal file
33
src/event/ngx_event_timer.c
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
void ngx_add_timer(ngx_event_t *ev, ngx_msec_t timer)
|
||||
{
|
||||
ngx_event_t *e;
|
||||
|
||||
#if (NGX_DEBUG_EVENT)
|
||||
ngx_connection_t *c = (ngx_connection_t *) ev->data;
|
||||
ngx_log_debug(ev->log, "set timer: %d:%d" _ c->fd _ timer);
|
||||
#endif
|
||||
|
||||
if (ev->timer_next || ev->timer_prev) {
|
||||
ngx_log_error(NGX_LOG_ALERT, ev->log, 0, "timer already set");
|
||||
return;
|
||||
}
|
||||
|
||||
n = timer % ngx_timer_hash_size;
|
||||
|
||||
for (e = timer_queue[n].timer_next;
|
||||
e != &timer_queue[n] && timer > e->timer_delta;
|
||||
e = e->timer_next)
|
||||
{
|
||||
timer -= e->timer_delta;
|
||||
}
|
||||
|
||||
ev->timer_delta = timer;
|
||||
|
||||
ev->timer_next = e;
|
||||
ev->timer_prev = e->timer_prev;
|
||||
|
||||
e->timer_prev->timer_next = ev;
|
||||
e->timer_prev = ev;
|
||||
}
|
Loading…
Reference in New Issue
Block a user