Files
nginx/src/event/modules/ngx_devpoll_module.c

518 lines
13 KiB
C
Raw Normal View History

2003-05-20 15:37:55 +00:00
2002-12-23 06:29:22 +00:00
/*
* Copyright (C) Igor Sysoev
2002-12-23 06:29:22 +00:00
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_event.h>
2003-05-20 15:37:55 +00:00
#if (NGX_TEST_BUILD_DEVPOLL)
2003-05-20 15:37:55 +00:00
/* Solaris declarations */
#define POLLREMOVE 0x0800
#define DP_POLL 0xD001
struct dvpoll {
struct pollfd *dp_fds;
int dp_nfds;
int dp_timeout;
};
2002-12-23 06:29:22 +00:00
#endif
2003-05-20 15:37:55 +00:00
typedef struct {
2003-07-11 04:50:59 +00:00
u_int changes;
u_int events;
2003-05-20 15:37:55 +00:00
} ngx_devpoll_conf_t;
static ngx_int_t ngx_devpoll_init(ngx_cycle_t *cycle, ngx_msec_t timer);
2003-07-10 16:26:57 +00:00
static void ngx_devpoll_done(ngx_cycle_t *cycle);
static ngx_int_t ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags);
static ngx_int_t ngx_devpoll_process_events(ngx_cycle_t *cycle,
ngx_msec_t timer, ngx_uint_t flags);
2003-05-20 15:37:55 +00:00
2003-07-10 16:26:57 +00:00
static void *ngx_devpoll_create_conf(ngx_cycle_t *cycle);
static char *ngx_devpoll_init_conf(ngx_cycle_t *cycle, void *conf);
2002-12-24 17:30:59 +00:00
2003-10-30 16:51:33 +00:00
static int dp = -1;
2002-12-23 06:29:22 +00:00
static struct pollfd *change_list, *event_list;
2003-07-11 04:50:59 +00:00
static u_int nchanges, max_changes, nevents;
2002-12-24 17:30:59 +00:00
static ngx_event_t **change_index;
2002-12-23 06:29:22 +00:00
2003-05-20 15:37:55 +00:00
static ngx_str_t devpoll_name = ngx_string("/dev/poll");
static ngx_command_t ngx_devpoll_commands[] = {
{ ngx_string("devpoll_changes"),
NGX_EVENT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
0,
offsetof(ngx_devpoll_conf_t, changes),
NULL },
{ ngx_string("devpoll_events"),
NGX_EVENT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
0,
offsetof(ngx_devpoll_conf_t, events),
NULL },
ngx_null_command
2003-05-20 15:37:55 +00:00
};
ngx_event_module_t ngx_devpoll_module_ctx = {
&devpoll_name,
ngx_devpoll_create_conf, /* create configuration */
ngx_devpoll_init_conf, /* init configuration */
{
ngx_devpoll_add_event, /* add an event */
ngx_devpoll_del_event, /* delete an event */
ngx_devpoll_add_event, /* enable an event */
ngx_devpoll_del_event, /* disable an event */
NULL, /* add an connection */
NULL, /* delete an connection */
2004-07-07 06:15:04 +00:00
NULL, /* process the changes */
2003-05-20 15:37:55 +00:00
ngx_devpoll_process_events, /* process the events */
ngx_devpoll_init, /* init the events */
ngx_devpoll_done, /* done the events */
}
};
ngx_module_t ngx_devpoll_module = {
nginx-0.1.29-RELEASE import *) Feature: the ngx_http_ssi_module supports "include virtual" command. *) Feature: the ngx_http_ssi_module supports the condition command like 'if expr="$NAME"' and "else" and "endif" commands. Only one nested level is supported. *) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and DATE_GMT variables and "config timefmt" command. *) Feature: the "ssi_ignore_recycled_buffers" directive. *) Bugfix: the "echo" command did not show the default value for the empty QUERY_STRING variable. *) Change: the ngx_http_proxy_module was rewritten. *) Feature: the "proxy_redirect", "proxy_pass_request_headers", "proxy_pass_request_body", and "proxy_method" directives. *) Feature: the "proxy_set_header" directive. The "proxy_x_var" was canceled and must be replaced with the proxy_set_header directive. *) Change: the "proxy_preserve_host" is canceled and must be replaced with the "proxy_set_header Host $host" and the "proxy_redirect off" directives, the "proxy_set_header Host $host:$proxy_port" directive and the appropriate proxy_redirect directives. *) Change: the "proxy_set_x_real_ip" is canceled and must be replaced with the "proxy_set_header X-Real-IP $remote_addr" directive. *) Change: the "proxy_add_x_forwarded_for" is canceled and must be replaced with the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for" directive. *) Change: the "proxy_set_x_url" is canceled and must be replaced with the "proxy_set_header X-URL http://$host:$server_port$request_uri" directive. *) Feature: the "fastcgi_param" directive. *) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params" directive are canceled and must be replaced with the fastcgi_param directives. *) Feature: the "index" directive can use the variables. *) Feature: the "index" directive can be used at http and server levels. *) Change: the last index only in the "index" directive can be absolute. *) Feature: the "rewrite" directive can use the variables. *) Feature: the "internal" directive. *) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR, SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME, REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables. *) Change: nginx now passes the invalid lines in a client request headers or a backend response header. *) Bugfix: if the backend did not transfer response for a long time and the "send_timeout" was less than "proxy_read_timeout", then nginx returned the 408 response. *) Bugfix: the segmentation fault was occurred if the backend sent an invalid line in response header; the bug had appeared in 0.1.26. *) Bugfix: the segmentation fault may occurred in FastCGI fault tolerance configuration. *) Bugfix: the "expires" directive did not remove the previous "Expires" and "Cache-Control" headers. *) Bugfix: nginx did not take into account trailing dot in "Host" header line. *) Bugfix: the ngx_http_auth_module did not work under Linux. *) Bugfix: the rewrite directive worked incorrectly, if the arguments were in a request. *) Bugfix: nginx could not be built on MacOS X.
2005-05-12 14:58:06 +00:00
NGX_MODULE_V1,
2003-05-20 15:37:55 +00:00
&ngx_devpoll_module_ctx, /* module context */
ngx_devpoll_commands, /* module directives */
2003-05-27 12:18:54 +00:00
NGX_EVENT_MODULE, /* module type */
NULL, /* init master */
2003-07-11 04:50:59 +00:00
NULL, /* init module */
NULL, /* init process */
NULL, /* init thread */
NULL, /* exit thread */
NULL, /* exit process */
NULL, /* exit master */
NGX_MODULE_V1_PADDING
2003-05-20 15:37:55 +00:00
};
2002-12-23 06:29:22 +00:00
2003-05-20 15:37:55 +00:00
static ngx_int_t
ngx_devpoll_init(ngx_cycle_t *cycle, ngx_msec_t timer)
2002-12-23 06:29:22 +00:00
{
2003-11-21 06:30:49 +00:00
size_t n;
2003-05-20 15:37:55 +00:00
ngx_devpoll_conf_t *dpcf;
2003-07-10 16:26:57 +00:00
dpcf = ngx_event_get_conf(cycle->conf_ctx, ngx_devpoll_module);
2003-05-20 15:37:55 +00:00
2003-07-10 16:26:57 +00:00
if (dp == -1) {
dp = open("/dev/poll", O_RDWR);
2002-12-23 06:29:22 +00:00
2003-07-10 16:26:57 +00:00
if (dp == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"open(/dev/poll) failed");
return NGX_ERROR;
}
}
2002-12-23 06:29:22 +00:00
2003-07-10 16:26:57 +00:00
if (max_changes < dpcf->changes) {
if (nchanges) {
n = nchanges * sizeof(struct pollfd);
2004-01-29 21:45:01 +00:00
if (write(dp, change_list, n) != (ssize_t) n) {
2003-07-10 16:26:57 +00:00
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"write(/dev/poll) failed");
return NGX_ERROR;
}
nchanges = 0;
}
if (change_list) {
ngx_free(change_list);
}
change_list = ngx_alloc(sizeof(struct pollfd) * dpcf->changes,
cycle->log);
if (change_list == NULL) {
return NGX_ERROR;
}
2003-07-10 16:26:57 +00:00
if (change_index) {
ngx_free(change_index);
}
change_index = ngx_alloc(sizeof(ngx_event_t *) * dpcf->changes,
cycle->log);
if (change_index == NULL) {
return NGX_ERROR;
}
2002-12-23 06:29:22 +00:00
}
2003-07-10 16:26:57 +00:00
max_changes = dpcf->changes;
2003-05-20 15:37:55 +00:00
2003-07-10 16:26:57 +00:00
if (nevents < dpcf->events) {
if (event_list) {
ngx_free(event_list);
}
2003-05-20 15:37:55 +00:00
event_list = ngx_alloc(sizeof(struct pollfd) * dpcf->events,
cycle->log);
if (event_list == NULL) {
return NGX_ERROR;
}
2003-07-10 16:26:57 +00:00
}
2002-12-23 06:29:22 +00:00
2003-07-10 16:26:57 +00:00
nevents = dpcf->events;
ngx_io = ngx_os_io;
2003-05-20 15:37:55 +00:00
ngx_event_actions = ngx_devpoll_module_ctx.actions;
2003-07-10 16:26:57 +00:00
ngx_event_flags = NGX_USE_LEVEL_EVENT|NGX_USE_FD_EVENT;
2002-12-23 06:29:22 +00:00
return NGX_OK;
}
static void
ngx_devpoll_done(ngx_cycle_t *cycle)
2003-05-20 15:37:55 +00:00
{
if (close(dp) == -1) {
2003-07-10 16:26:57 +00:00
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"close(/dev/poll) failed");
2003-05-20 15:37:55 +00:00
}
2003-07-10 16:26:57 +00:00
dp = -1;
2003-05-20 15:37:55 +00:00
ngx_free(change_list);
ngx_free(event_list);
ngx_free(change_index);
2003-07-10 16:26:57 +00:00
change_list = NULL;
event_list = NULL;
change_index = NULL;
max_changes = 0;
nchanges = 0;
nevents = 0;
2003-05-20 15:37:55 +00:00
}
static ngx_int_t
ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags)
2002-12-23 06:29:22 +00:00
{
2004-01-29 21:45:01 +00:00
#if (NGX_DEBUG)
ngx_connection_t *c;
2002-12-23 06:29:22 +00:00
#endif
2002-12-24 17:30:59 +00:00
#if (NGX_READ_EVENT != POLLIN)
event = (event == NGX_READ_EVENT) ? POLLIN : POLLOUT;
2002-12-24 17:30:59 +00:00
#endif
2002-12-23 06:29:22 +00:00
2004-01-29 21:45:01 +00:00
#if (NGX_DEBUG)
c = ev->data;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"devpoll add event: fd:%d ev:%04Xd", c->fd, event);
2002-12-24 17:30:59 +00:00
#endif
2002-12-23 06:29:22 +00:00
2002-12-24 17:30:59 +00:00
ev->active = 1;
2002-12-24 17:30:59 +00:00
return ngx_devpoll_set_event(ev, event, 0);
2002-12-23 06:29:22 +00:00
}
static ngx_int_t
ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags)
2002-12-23 06:29:22 +00:00
{
2003-07-02 14:41:17 +00:00
ngx_event_t *e;
ngx_connection_t *c;
2002-12-23 06:29:22 +00:00
2003-07-02 18:51:41 +00:00
c = ev->data;
#if (NGX_READ_EVENT != POLLIN)
event = (event == NGX_READ_EVENT) ? POLLIN : POLLOUT;
#endif
2004-01-29 21:45:01 +00:00
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"devpoll del event: fd:%d ev:%04Xd", c->fd, event);
2002-12-23 06:29:22 +00:00
2002-12-24 17:30:59 +00:00
if (ngx_devpoll_set_event(ev, POLLREMOVE, flags) == NGX_ERROR) {
return NGX_ERROR;
2002-12-23 06:29:22 +00:00
}
2002-12-24 17:30:59 +00:00
ev->active = 0;
if (flags & NGX_CLOSE_EVENT) {
2002-12-23 06:29:22 +00:00
return NGX_OK;
2002-12-24 17:30:59 +00:00
}
/* restore the paired event if it exists */
2004-06-22 16:43:09 +00:00
if (event == POLLIN) {
2002-12-24 17:30:59 +00:00
e = c->write;
event = POLLOUT;
} else {
e = c->read;
event = POLLIN;
}
2002-12-23 06:29:22 +00:00
if (e && e->active) {
2002-12-24 17:30:59 +00:00
return ngx_devpoll_set_event(e, event, 0);
}
return NGX_OK;
2002-12-23 06:29:22 +00:00
}
static ngx_int_t
ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
2002-12-23 06:29:22 +00:00
{
2003-11-21 06:30:49 +00:00
size_t n;
2002-12-24 17:30:59 +00:00
ngx_connection_t *c;
2002-12-23 06:29:22 +00:00
2003-05-20 15:37:55 +00:00
c = ev->data;
2002-12-23 06:29:22 +00:00
2004-01-29 21:45:01 +00:00
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"devpoll fd:%d ev:%04Xd fl:%04Xd", c->fd, event, flags);
2002-12-23 06:29:22 +00:00
2003-05-20 15:37:55 +00:00
if (nchanges >= max_changes) {
2002-12-23 06:29:22 +00:00
ngx_log_error(NGX_LOG_WARN, ev->log, 0,
"/dev/pool change list is filled up");
n = nchanges * sizeof(struct pollfd);
2004-01-29 21:45:01 +00:00
if (write(dp, change_list, n) != (ssize_t) n) {
2002-12-24 17:30:59 +00:00
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
2002-12-23 06:29:22 +00:00
"write(/dev/poll) failed");
return NGX_ERROR;
}
nchanges = 0;
}
2002-12-24 17:30:59 +00:00
change_list[nchanges].fd = c->fd;
change_list[nchanges].events = event;
change_list[nchanges].revents = 0;
2002-12-23 06:29:22 +00:00
2002-12-24 17:30:59 +00:00
change_index[nchanges] = ev;
2002-12-23 06:29:22 +00:00
ev->index = nchanges;
nchanges++;
2002-12-24 17:30:59 +00:00
if (flags & NGX_CLOSE_EVENT) {
n = nchanges * sizeof(struct pollfd);
2004-01-29 21:45:01 +00:00
if (write(dp, change_list, n) != (ssize_t) n) {
2002-12-24 17:30:59 +00:00
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
"write(/dev/poll) failed");
return NGX_ERROR;
}
nchanges = 0;
}
2002-12-23 06:29:22 +00:00
return NGX_OK;
}
ngx_int_t
ngx_devpoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
ngx_uint_t flags)
2002-12-23 06:29:22 +00:00
{
int events, revents;
2003-11-21 06:30:49 +00:00
size_t n;
2003-07-10 16:26:57 +00:00
ngx_err_t err;
ngx_int_t i;
ngx_uint_t level;
ngx_event_t *rev, *wev, **queue;
2003-07-10 16:26:57 +00:00
ngx_connection_t *c;
struct dvpoll dvp;
2004-04-14 20:34:05 +00:00
/* NGX_TIMER_INFINITE == INFTIM */
2004-04-02 15:13:20 +00:00
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"devpoll timer: %M", timer);
2002-12-23 06:29:22 +00:00
2003-01-15 07:02:27 +00:00
if (nchanges) {
n = nchanges * sizeof(struct pollfd);
2004-01-29 21:45:01 +00:00
if (write(dp, change_list, n) != (ssize_t) n) {
2004-04-02 15:13:20 +00:00
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
2003-01-15 07:02:27 +00:00
"write(/dev/poll) failed");
return NGX_ERROR;
}
nchanges = 0;
2002-12-23 06:29:22 +00:00
}
2002-12-26 07:24:21 +00:00
dvp.dp_fds = event_list;
dvp.dp_nfds = nevents;
dvp.dp_timeout = timer;
events = ioctl(dp, DP_POLL, &dvp);
2002-12-23 06:29:22 +00:00
if (events == -1) {
2003-07-07 06:11:50 +00:00
err = ngx_errno;
} else {
err = 0;
2002-12-23 06:29:22 +00:00
}
if (flags & NGX_UPDATE_TIME) {
ngx_time_update(0, 0);
}
2003-11-10 21:09:22 +00:00
2004-01-30 17:39:00 +00:00
if (err) {
if (err == NGX_EINTR) {
if (ngx_event_timer_alarm) {
ngx_event_timer_alarm = 0;
return NGX_OK;
}
level = NGX_LOG_INFO;
} else {
level = NGX_LOG_ALERT;
}
ngx_log_error(level, cycle->log, err, "ioctl(DP_POLL) failed");
2004-01-30 17:39:00 +00:00
return NGX_ERROR;
}
if (events == 0) {
if (timer != NGX_TIMER_INFINITE) {
return NGX_OK;
2002-12-24 17:30:59 +00:00
}
2003-07-07 06:11:50 +00:00
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
"ioctl(DP_POLL) returned no events without timeout");
return NGX_ERROR;
2004-04-14 20:34:05 +00:00
}
ngx_mutex_lock(ngx_posted_events_mutex);
2004-04-14 20:34:05 +00:00
2002-12-23 06:29:22 +00:00
for (i = 0; i < events; i++) {
c = ngx_cycle->files[event_list[i].fd];
2003-07-10 16:26:57 +00:00
if (c->fd == -1) {
if (c->read->closed) {
continue;
}
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "unexpected event");
continue;
}
revents = event_list[i].revents;
2004-04-02 15:13:20 +00:00
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"devpoll: fd:%d, ev:%04Xd, rev:%04Xd",
event_list[i].fd, event_list[i].events, revents);
2002-12-23 06:29:22 +00:00
if (revents & (POLLERR|POLLHUP|POLLNVAL)) {
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"ioctl(DP_POLL) error fd:%d ev:%04Xd rev:%04Xd",
event_list[i].fd, event_list[i].events, revents);
2004-02-01 08:10:52 +00:00
}
if (revents & ~(POLLIN|POLLOUT|POLLERR|POLLHUP|POLLNVAL)) {
2004-04-02 15:13:20 +00:00
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
2004-02-01 08:10:52 +00:00
"strange ioctl(DP_POLL) events "
"fd:%d ev:%04Xd rev:%04Xd",
event_list[i].fd, event_list[i].events, revents);
}
if ((revents & (POLLERR|POLLHUP|POLLNVAL))
&& (revents & (POLLIN|POLLOUT)) == 0)
{
/*
* if the error events were returned without POLLIN or POLLOUT,
* then add these flags to handle the events at least in one
* active handler
*/
revents |= POLLIN|POLLOUT;
2004-02-01 08:10:52 +00:00
}
2002-12-24 17:30:59 +00:00
rev = c->read;
2004-07-07 15:01:00 +00:00
if ((revents & POLLIN) && rev->active) {
2004-04-14 20:34:05 +00:00
if ((flags & NGX_POST_THREAD_EVENTS) && !rev->accept) {
rev->posted_ready = 1;
2004-04-14 20:34:05 +00:00
} else {
rev->ready = 1;
2004-04-14 20:34:05 +00:00
}
if (flags & NGX_POST_EVENTS) {
queue = (ngx_event_t **) (rev->accept ?
&ngx_posted_accept_events : &ngx_posted_events);
2004-04-14 20:34:05 +00:00
ngx_locked_post_event(rev, queue);
2002-12-23 06:29:22 +00:00
} else {
nginx-0.1.29-RELEASE import *) Feature: the ngx_http_ssi_module supports "include virtual" command. *) Feature: the ngx_http_ssi_module supports the condition command like 'if expr="$NAME"' and "else" and "endif" commands. Only one nested level is supported. *) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and DATE_GMT variables and "config timefmt" command. *) Feature: the "ssi_ignore_recycled_buffers" directive. *) Bugfix: the "echo" command did not show the default value for the empty QUERY_STRING variable. *) Change: the ngx_http_proxy_module was rewritten. *) Feature: the "proxy_redirect", "proxy_pass_request_headers", "proxy_pass_request_body", and "proxy_method" directives. *) Feature: the "proxy_set_header" directive. The "proxy_x_var" was canceled and must be replaced with the proxy_set_header directive. *) Change: the "proxy_preserve_host" is canceled and must be replaced with the "proxy_set_header Host $host" and the "proxy_redirect off" directives, the "proxy_set_header Host $host:$proxy_port" directive and the appropriate proxy_redirect directives. *) Change: the "proxy_set_x_real_ip" is canceled and must be replaced with the "proxy_set_header X-Real-IP $remote_addr" directive. *) Change: the "proxy_add_x_forwarded_for" is canceled and must be replaced with the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for" directive. *) Change: the "proxy_set_x_url" is canceled and must be replaced with the "proxy_set_header X-URL http://$host:$server_port$request_uri" directive. *) Feature: the "fastcgi_param" directive. *) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params" directive are canceled and must be replaced with the fastcgi_param directives. *) Feature: the "index" directive can use the variables. *) Feature: the "index" directive can be used at http and server levels. *) Change: the last index only in the "index" directive can be absolute. *) Feature: the "rewrite" directive can use the variables. *) Feature: the "internal" directive. *) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR, SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME, REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables. *) Change: nginx now passes the invalid lines in a client request headers or a backend response header. *) Bugfix: if the backend did not transfer response for a long time and the "send_timeout" was less than "proxy_read_timeout", then nginx returned the 408 response. *) Bugfix: the segmentation fault was occurred if the backend sent an invalid line in response header; the bug had appeared in 0.1.26. *) Bugfix: the segmentation fault may occurred in FastCGI fault tolerance configuration. *) Bugfix: the "expires" directive did not remove the previous "Expires" and "Cache-Control" headers. *) Bugfix: nginx did not take into account trailing dot in "Host" header line. *) Bugfix: the ngx_http_auth_module did not work under Linux. *) Bugfix: the rewrite directive worked incorrectly, if the arguments were in a request. *) Bugfix: nginx could not be built on MacOS X.
2005-05-12 14:58:06 +00:00
rev->handler(rev);
}
}
2004-04-14 20:34:05 +00:00
wev = c->write;
2004-04-14 20:34:05 +00:00
if ((revents & POLLOUT) && wev->active) {
2004-04-14 20:34:05 +00:00
if (flags & NGX_POST_THREAD_EVENTS) {
wev->posted_ready = 1;
2004-04-14 20:34:05 +00:00
} else {
wev->ready = 1;
}
2004-04-21 18:54:33 +00:00
if (flags & NGX_POST_EVENTS) {
ngx_locked_post_event(wev, &ngx_posted_events);
2004-04-14 20:34:05 +00:00
} else {
wev->handler(wev);
2004-04-14 20:34:05 +00:00
}
2002-12-23 06:29:22 +00:00
}
}
ngx_mutex_unlock(ngx_posted_events_mutex);
2004-04-14 20:34:05 +00:00
2002-12-23 06:29:22 +00:00
return NGX_OK;
}
2003-05-20 15:37:55 +00:00
static void *
ngx_devpoll_create_conf(ngx_cycle_t *cycle)
2003-05-20 15:37:55 +00:00
{
ngx_devpoll_conf_t *dpcf;
dpcf = ngx_palloc(cycle->pool, sizeof(ngx_devpoll_conf_t));
if (dpcf == NULL) {
return NGX_CONF_ERROR;
}
2003-05-20 15:37:55 +00:00
dpcf->changes = NGX_CONF_UNSET;
dpcf->events = NGX_CONF_UNSET;
return dpcf;
}
static char *
ngx_devpoll_init_conf(ngx_cycle_t *cycle, void *conf)
2003-05-20 15:37:55 +00:00
{
ngx_devpoll_conf_t *dpcf = conf;
ngx_conf_init_uint_value(dpcf->changes, 32);
ngx_conf_init_uint_value(dpcf->events, 32);
2003-05-20 15:37:55 +00:00
return NGX_CONF_OK;
}