Style: reuse one int variable in ngx_configure_listening_sockets().
No functional changes.
This commit is contained in:
parent
223a4e7c37
commit
8028c23764
1 changed files with 8 additions and 11 deletions
|
@ -464,16 +464,13 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
|
||||||
void
|
void
|
||||||
ngx_configure_listening_sockets(ngx_cycle_t *cycle)
|
ngx_configure_listening_sockets(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
int keepalive;
|
int value;
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
ngx_listening_t *ls;
|
ngx_listening_t *ls;
|
||||||
|
|
||||||
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
|
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
|
||||||
struct accept_filter_arg af;
|
struct accept_filter_arg af;
|
||||||
#endif
|
#endif
|
||||||
#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
|
|
||||||
int timeout;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ls = cycle->listening.elts;
|
ls = cycle->listening.elts;
|
||||||
for (i = 0; i < cycle->listening.nelts; i++) {
|
for (i = 0; i < cycle->listening.nelts; i++) {
|
||||||
|
@ -503,15 +500,15 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ls[i].keepalive) {
|
if (ls[i].keepalive) {
|
||||||
keepalive = (ls[i].keepalive == 1) ? 1 : 0;
|
value = (ls[i].keepalive == 1) ? 1 : 0;
|
||||||
|
|
||||||
if (setsockopt(ls[i].fd, SOL_SOCKET, SO_KEEPALIVE,
|
if (setsockopt(ls[i].fd, SOL_SOCKET, SO_KEEPALIVE,
|
||||||
(const void *) &keepalive, sizeof(int))
|
(const void *) &value, sizeof(int))
|
||||||
== -1)
|
== -1)
|
||||||
{
|
{
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
|
||||||
"setsockopt(SO_KEEPALIVE, %d) %V failed, ignored",
|
"setsockopt(SO_KEEPALIVE, %d) %V failed, ignored",
|
||||||
keepalive, &ls[i].addr_text);
|
value, &ls[i].addr_text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,20 +645,20 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
|
||||||
if (ls[i].add_deferred || ls[i].delete_deferred) {
|
if (ls[i].add_deferred || ls[i].delete_deferred) {
|
||||||
|
|
||||||
if (ls[i].add_deferred) {
|
if (ls[i].add_deferred) {
|
||||||
timeout = (int) (ls[i].post_accept_timeout / 1000);
|
value = (int) (ls[i].post_accept_timeout / 1000);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
timeout = 0;
|
value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_DEFER_ACCEPT,
|
if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_DEFER_ACCEPT,
|
||||||
&timeout, sizeof(int))
|
&value, sizeof(int))
|
||||||
== -1)
|
== -1)
|
||||||
{
|
{
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
"setsockopt(TCP_DEFER_ACCEPT, %d) for %V failed, "
|
"setsockopt(TCP_DEFER_ACCEPT, %d) for %V failed, "
|
||||||
"ignored",
|
"ignored",
|
||||||
timeout, &ls[i].addr_text);
|
value, &ls[i].addr_text);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue