mirror of
https://github.com/nginx/nginx.git
synced 2026-08-04 14:58:20 +00:00
Events: validate descriptor before FD_SET()
The check in ngx_select_init_conf() can be insufficient because it doesn't cover descriptors for local files, which are not accounted for in cycle->connection_n. For instance, to reach this condition with new connections, no reusable connections must be available for recycling in ngx_get_connection(). The fix adopts a similar code from the win32 select module.
This commit is contained in:
parent
5e0deb7018
commit
0cb3d7fb13
1 changed files with 11 additions and 2 deletions
|
|
@ -146,6 +146,17 @@ ngx_select_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
|
|||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
/* disable warning: the default FD_SETSIZE is 1024U in FreeBSD 5.x-10.x */
|
||||
|
||||
if ((event == NGX_READ_EVENT || event == NGX_WRITE_EVENT)
|
||||
&& (unsigned) c->fd >= FD_SETSIZE)
|
||||
{
|
||||
ngx_log_error(NGX_LOG_ERR, ev->log, 0,
|
||||
"maximum number of descriptors "
|
||||
"supported by select() is %ud", FD_SETSIZE);
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (event == NGX_READ_EVENT) {
|
||||
FD_SET(c->fd, &master_read_fd_set);
|
||||
|
||||
|
|
@ -411,8 +422,6 @@ ngx_select_init_conf(ngx_cycle_t *cycle, void *conf)
|
|||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
/* disable warning: the default FD_SETSIZE is 1024U in FreeBSD 5.x */
|
||||
|
||||
if (cycle->connection_n > FD_SETSIZE) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
|
||||
"the maximum number of files "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue