aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_request.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2013-03-07 17:59:27 +0000
committerValentin Bartenev <vbart@nginx.com>2013-03-07 17:59:27 +0000
commit4815b3b2ee53687e60a6bf148aaf000a17a9a9b9 (patch)
tree064157cc270f40fd3517ddb81814a0ec66ecb455 /src/http/ngx_http_request.c
parent3e5aaee82878a3ddb0caa5af6375ea4c25e7bb13 (diff)
downloadnginx-4815b3b2ee53687e60a6bf148aaf000a17a9a9b9.tar.gz
nginx-4815b3b2ee53687e60a6bf148aaf000a17a9a9b9.zip
Respect the new behavior of TCP_DEFER_ACCEPT.
In Linux 2.6.32, TCP_DEFER_ACCEPT was changed to accept connections after the deferring period is finished without any data available. (Reading from the socket returns EAGAIN in this case.) Since in nginx TCP_DEFER_ACCEPT is set to "post_accept_timeout", we do not need to wait longer if deferred accept returns with no data.
Diffstat (limited to 'src/http/ngx_http_request.c')
-rw-r--r--src/http/ngx_http_request.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 68cb34562..ea053057b 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -416,6 +416,20 @@ ngx_http_wait_request_handler(ngx_event_t *rev)
if (n == NGX_AGAIN) {
+#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
+ if (c->listening->deferred_accept
+#if (NGX_HTTP_SSL)
+ && c->ssl == NULL
+#endif
+ )
+ {
+ ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT,
+ "client timed out in deferred accept");
+ ngx_http_close_connection(c);
+ return;
+ }
+#endif
+
if (!rev->timer_set) {
ngx_add_timer(rev, c->listening->post_accept_timeout);
}
@@ -617,6 +631,15 @@ ngx_http_ssl_handshake(ngx_event_t *rev)
if (n == -1) {
if (err == NGX_EAGAIN) {
+#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
+ if (c->listening->deferred_accept) {
+ ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT,
+ "client timed out in deferred accept");
+ ngx_http_close_connection(c);
+ return;
+ }
+#endif
+
if (!rev->timer_set) {
ngx_add_timer(rev, c->listening->post_accept_timeout);
}