ngx_add_timer() 完成将一个超时管理加入红黑树,首先比较key字段记录的超时时刻,判断超时事件是否已经加入树,若已经加入则调用 ngx_del_timer() 删除节点,在调用 ngx_rbtree_insert() 将超时事件对象加入树。 对于树上超时节点的管理有两种方法, 使用哪种方法取决于配置指令 timer_resolution 当ngx_timer_resolutio...
ngx_int_t (*add_conn)(ngx_connection_t *c); ngx_int_t (*del_conn)(ngx_connection_t *c, ngx_uint_t flags); /* 向事件驱动机制中添加/移除一个新的连接,这意味着连接上的读写事件都添加到/移出事件驱动机制中了 */ ngx_int_t (*process_events)(ngx_cycle_t *cycle, ngx_msec_t timer...
timer->handler = ngx_http_dyups_read_msg; ngx_add_timer(timer, dmcf->read_msg_timeout); // 拿到全局的pool和sh shpool = ngx_dyups_global_ctx.shpool; sh = ngx_dyups_global_ctx.sh; ngx_shmtx_lock(&shpool->mutex); // 初始化的时候肯定是NULL,,申请对应数量进程数的内存 if (sh->st...
if (n == NGX_AGAIN) { if (!rev->timer_set) { cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); // 将读事件加入到定时器中 ngx_add_timer(rev, cscf->client_header_timeout); } // 将读事件加入到epoll中 if (ngx_handle_read_event(rev, 0) != NGX_OK) { ngx_ht...
ngx_add_timer(timer, dmcf->read_msg_timeout); // 拿到全局的pool和sh shpool = ngx_dyups_global_ctx.shpool; sh = ngx_dyups_global_ctx.sh; ngx_shmtx_lock(&shpool->mutex); // 初始化的时候肯定是NULL,,申请对应数量进程数的内存
ngx_add_timer(r->connection->write, delay); return NGX_AGAIN; } // NGX_BUSY 严重超配,已经超出burst阈值,需要返回错误码 // NGX_OK 本规则超配,需要延迟处理。 // NGX_AGAIN 本规则没有超配,要检测下一个规则。 static ngx_int_t ngx_http_limit_req_lookup(ngx_http_limit_req_limit_t *limi...
ngx_add_timer(c->write, s->timeout); if (ngx_handle_write_event(c->write, 0) != NGX_OK) { ngx_rtmp_finalize_session(s); } return; } if (n < 0) { ngx_rtmp_finalize_session(s); return; } s->out_bytes += n; s->ping_reset = 1; ngx_rtmp_update_ban...
(NGX_LOG_ERR, c->log, 0, "http_auth_ldap: Unable to connect to LDAP server \"%V\".", &addr->name); ngx_add_timer(&c->reconnect_event, c->server->reconnect_timeout); return; } conn = pconn->connection; conn->data = c; #if (NGX_OPENSSL) conn->pool = c->pool; #endif...
ngx_add_timer(s->connection->write, s->timeout); return NGX_OK; } static ngx_int_t ngx_rtmp_cmd_play2_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, ngx_chain_t *in) { static ngx_rtmp_play_t v; static ngx_rtmp_close_stream_t vc; static ngx_rtmp_amf_el...
src/event/ngx_event.c void ngx_process_events_and_timers(ngx_cycle_t *cycle) { ngx_uint_t flags; ngx_msec_t timer, delta; if (ngx_timer_resolution) { timer = NGX_TIMER_INFINITE; flags = 0; } else { timer = ngx_event_find_timer(); flags = NGX_UPDATE_TIME; } /* ngx_use_...