mirror of
https://github.com/nginx/nginx.git
synced 2026-06-26 20:01:45 +00:00
do listen() just after bind() to exit early
This commit is contained in:
parent
9dd99aac66
commit
d4aa572c8d
1 changed files with 14 additions and 0 deletions
|
|
@ -325,6 +325,20 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (listen(s, ls[i].backlog) == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
||||
"listen() to %V, backlog %d failed",
|
||||
&ls[i].addr_text, ls[i].backlog);
|
||||
|
||||
if (ngx_close_socket(s) == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
||||
ngx_close_socket_n " %V failed",
|
||||
&ls[i].addr_text);
|
||||
}
|
||||
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
ls[i].listen = 1;
|
||||
|
||||
ls[i].fd = s;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue