Accept cookies for analytics, social media, and advertising, or learn more and adjust your preferences. These cookies are on by default for visitors outside the UK and EEA. Privacy Notice.
ngx_event_t
¶An event structure which is to be added to the event loop
data
¶A pointer to data to pass to the event handler. Normally this is a pointer to ngx_connection_t
void (*ngx_event_handler_pt)(ngx_event_t *ev) handler
A handler function to be called when the event is triggered
ngx_add_timer
(ngx_event_t *ev, ngx_msec_t timer)¶Adds a timer to the NGINX event loop. Normally used for timeouts on a socket but can also be used as a generic timer.
Parameters: |
|
---|
Example:
This example will trigger a timer event after 5 seconds with a dummy connection
static ngx_event_t my_timer;
static ngx_connection_t dumb_con;
ngx_int_t ngx_my_init_process(ngx_cycle_t *cycle)
{
my_timer.handler = ngx_timer_fired;
my_timer.log = cycle->log;
my_timer.data = &dumb_con;
dumb.fd = (ngx_socket_t) -1;
}
void ngx_timer_fired(ngx_event_t *ev)
{
ngx_log_error(NGX_LOG_DEBUG, ev->log, 0, "Event fired!");
}
ngx_event_del_timer
(ngx_event_t *ev)¶Removes the timer from the NGINX event loop
Parameters: |
|
---|