comparison src/core/ngx_connection.c @ 5456:692afcea9d0d

Added support for TCP_FASTOPEN supported in Linux >= 3.7.1. --- auto/unix | 12 ++++++++++++ src/core/ngx_connection.c | 32 ++++++++++++++++++++++++++++++++ src/core/ngx_connection.h | 4 ++++ src/http/ngx_http.c | 4 ++++ src/http/ngx_http_core_module.c | 21 +++++++++++++++++++++ src/http/ngx_http_core_module.h | 3 +++ 6 files changed, 76 insertions(+)
author Mathew Rodley <mathew@rodley.com.au>
date Tue, 03 Dec 2013 22:07:03 +0400
parents 91bd62a9627e
children 1ab1cf63f885
comparison
equal deleted inserted replaced
5455:8f2c69418045 5456:692afcea9d0d
78 ls->rcvbuf = -1; 78 ls->rcvbuf = -1;
79 ls->sndbuf = -1; 79 ls->sndbuf = -1;
80 80
81 #if (NGX_HAVE_SETFIB) 81 #if (NGX_HAVE_SETFIB)
82 ls->setfib = -1; 82 ls->setfib = -1;
83 #endif
84
85 #if (NGX_HAVE_TCP_FASTOPEN)
86 ls->fastopen = -1;
83 #endif 87 #endif
84 88
85 return ls; 89 return ls;
86 } 90 }
87 91
207 } 211 }
208 212
209 #endif 213 #endif
210 #endif 214 #endif
211 215
216 #if (NGX_HAVE_TCP_FASTOPEN)
217
218 if (getsockopt(ls[i].fastopen, IPPROTO_TCP, TCP_FASTOPEN,
219 (void *) &ls[i].fastopen, &olen)
220 == -1)
221 {
222 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
223 "getsockopt(TCP_FASTOPEN) %V failed, ignored",
224 &ls[i].addr_text);
225
226 ls[i].fastopen = -1;
227 }
228
229 #endif
230
212 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) 231 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
213 232
214 ngx_memzero(&af, sizeof(struct accept_filter_arg)); 233 ngx_memzero(&af, sizeof(struct accept_filter_arg));
215 olen = sizeof(struct accept_filter_arg); 234 olen = sizeof(struct accept_filter_arg);
216 235
576 == -1) 595 == -1)
577 { 596 {
578 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno, 597 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
579 "setsockopt(SO_SETFIB, %d) %V failed, ignored", 598 "setsockopt(SO_SETFIB, %d) %V failed, ignored",
580 ls[i].setfib, &ls[i].addr_text); 599 ls[i].setfib, &ls[i].addr_text);
600 }
601 }
602 #endif
603
604 #if (NGX_HAVE_TCP_FASTOPEN)
605 if (ls[i].fastopen != -1) {
606 if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_FASTOPEN,
607 (const void *) &ls[i].fastopen, sizeof(int))
608 == -1)
609 {
610 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
611 "setsockopt(TCP_FASTOPEN, %d) %V failed, ignored",
612 ls[i].fastopen, &ls[i].addr_text);
581 } 613 }
582 } 614 }
583 #endif 615 #endif
584 616
585 #if 0 617 #if 0