comparison src/core/ngx_connection.c @ 5283:6d73e0dc4f64

On DragonFlyBSD, TCP_KEEPIDLE and TCP_KEEPINTVL are in msecs. Based on a patch by Sepherosa Ziehau.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 25 Jul 2013 12:46:03 +0400
parents 31690d934175
children 3d2d3e1cf427
comparison
equal deleted inserted replaced
5282:31690d934175 5283:6d73e0dc4f64
513 } 513 }
514 514
515 #if (NGX_HAVE_KEEPALIVE_TUNABLE) 515 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
516 516
517 if (ls[i].keepidle) { 517 if (ls[i].keepidle) {
518 value = ls[i].keepidle;
519
520 #if (NGX_KEEPALIVE_FACTOR)
521 value *= NGX_KEEPALIVE_FACTOR;
522 #endif
523
518 if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPIDLE, 524 if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPIDLE,
519 (const void *) &ls[i].keepidle, sizeof(int)) 525 (const void *) &value, sizeof(int))
520 == -1) 526 == -1)
521 { 527 {
522 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, 528 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
523 "setsockopt(TCP_KEEPIDLE, %d) %V failed, ignored", 529 "setsockopt(TCP_KEEPIDLE, %d) %V failed, ignored",
524 ls[i].keepidle, &ls[i].addr_text); 530 value, &ls[i].addr_text);
525 } 531 }
526 } 532 }
527 533
528 if (ls[i].keepintvl) { 534 if (ls[i].keepintvl) {
535 value = ls[i].keepintvl;
536
537 #if (NGX_KEEPALIVE_FACTOR)
538 value *= NGX_KEEPALIVE_FACTOR;
539 #endif
540
529 if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPINTVL, 541 if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPINTVL,
530 (const void *) &ls[i].keepintvl, sizeof(int)) 542 (const void *) &value, sizeof(int))
531 == -1) 543 == -1)
532 { 544 {
533 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, 545 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
534 "setsockopt(TCP_KEEPINTVL, %d) %V failed, ignored", 546 "setsockopt(TCP_KEEPINTVL, %d) %V failed, ignored",
535 ls[i].keepintvl, &ls[i].addr_text); 547 value, &ls[i].addr_text);
536 } 548 }
537 } 549 }
538 550
539 if (ls[i].keepcnt) { 551 if (ls[i].keepcnt) {
540 if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPCNT, 552 if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPCNT,