Klaus Demo nginx / 690e2b3
Style: reuse one int variable in ngx_configure_listening_sockets(). No functional changes. Ruslan Ermilov 9 years ago
1 changed file(s) with 8 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
463463 void
464464 ngx_configure_listening_sockets(ngx_cycle_t *cycle)
465465 {
466 int keepalive;
466 int value;
467467 ngx_uint_t i;
468468 ngx_listening_t *ls;
469469
470470 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
471471 struct accept_filter_arg af;
472 #endif
473 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
474 int timeout;
475472 #endif
476473
477474 ls = cycle->listening.elts;
502499 }
503500
504501 if (ls[i].keepalive) {
505 keepalive = (ls[i].keepalive == 1) ? 1 : 0;
502 value = (ls[i].keepalive == 1) ? 1 : 0;
506503
507504 if (setsockopt(ls[i].fd, SOL_SOCKET, SO_KEEPALIVE,
508 (const void *) &keepalive, sizeof(int))
505 (const void *) &value, sizeof(int))
509506 == -1)
510507 {
511508 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
512509 "setsockopt(SO_KEEPALIVE, %d) %V failed, ignored",
513 keepalive, &ls[i].addr_text);
510 value, &ls[i].addr_text);
514511 }
515512 }
516513
647644 if (ls[i].add_deferred || ls[i].delete_deferred) {
648645
649646 if (ls[i].add_deferred) {
650 timeout = (int) (ls[i].post_accept_timeout / 1000);
647 value = (int) (ls[i].post_accept_timeout / 1000);
651648
652649 } else {
653 timeout = 0;
650 value = 0;
654651 }
655652
656653 if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_DEFER_ACCEPT,
657 &timeout, sizeof(int))
654 &value, sizeof(int))
658655 == -1)
659656 {
660657 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
661658 "setsockopt(TCP_DEFER_ACCEPT, %d) for %V failed, "
662659 "ignored",
663 timeout, &ls[i].addr_text);
660 value, &ls[i].addr_text);
664661
665662 continue;
666663 }