do listen() just after bind() to exit early

This commit is contained in:
Igor Sysoev 2007-05-30 13:23:48 +00:00
parent d3484d108c
commit a9f6f42376

View file

@ -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;