mirror of
https://github.com/nginx/nginx.git
synced 2025-06-06 00:42:40 +08:00
Win32: detection of connect() errors in select().
On Windows, connect() errors are only reported via exceptfds descriptor set from select(). Previously exceptfds was set to NULL, and connect() errors were not detected at all, so connects to closed ports were waiting till a timeout occurred. Since ongoing connect() means that there will be a write event active, except descriptor set is copied from the write one. While it is possible to construct except descriptor set as a concatenation of both read and write descriptor sets, this looks unneeded. With this change, connect() errors are properly detected now when using select(). Note well that it is not possible to detect connect() errors with WSAPoll() (see https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/).
This commit is contained in:
parent
f2cfcc09a0
commit
38196b8ba6
@ -26,6 +26,7 @@ static fd_set master_read_fd_set;
|
||||
static fd_set master_write_fd_set;
|
||||
static fd_set work_read_fd_set;
|
||||
static fd_set work_write_fd_set;
|
||||
static fd_set work_except_fd_set;
|
||||
|
||||
static ngx_uint_t max_read;
|
||||
static ngx_uint_t max_write;
|
||||
@ -251,9 +252,11 @@ ngx_select_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
|
||||
|
||||
work_read_fd_set = master_read_fd_set;
|
||||
work_write_fd_set = master_write_fd_set;
|
||||
work_except_fd_set = master_write_fd_set;
|
||||
|
||||
if (max_read || max_write) {
|
||||
ready = select(0, &work_read_fd_set, &work_write_fd_set, NULL, tp);
|
||||
ready = select(0, &work_read_fd_set, &work_write_fd_set,
|
||||
&work_except_fd_set, tp);
|
||||
|
||||
} else {
|
||||
|
||||
@ -306,14 +309,20 @@ ngx_select_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
|
||||
|
||||
if (ev->write) {
|
||||
if (FD_ISSET(c->fd, &work_write_fd_set)) {
|
||||
found = 1;
|
||||
found++;
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"select write %d", c->fd);
|
||||
}
|
||||
|
||||
if (FD_ISSET(c->fd, &work_except_fd_set)) {
|
||||
found++;
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"select except %d", c->fd);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (FD_ISSET(c->fd, &work_read_fd_set)) {
|
||||
found = 1;
|
||||
found++;
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"select read %d", c->fd);
|
||||
}
|
||||
@ -327,7 +336,7 @@ ngx_select_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
|
||||
|
||||
ngx_post_event(ev, queue);
|
||||
|
||||
nready++;
|
||||
nready += found;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user