do listen() just after bind() to exit early
This commit is contained in:
parent
d3484d108c
commit
a9f6f42376
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…
Reference in a new issue