diff options
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/ngx_http_event.c | 10 | ||||
| -rw-r--r-- | src/http/ngx_http_header_filter.c | 37 |
2 files changed, 40 insertions, 7 deletions
diff --git a/src/http/ngx_http_event.c b/src/http/ngx_http_event.c index b4a9ae97d..be6d3910a 100644 --- a/src/http/ngx_http_event.c +++ b/src/http/ngx_http_event.c @@ -1133,6 +1133,16 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r) ctx->action = "keepalive"; + if (c->tcp_nopush) { + if (ngx_tcp_push(c->fd) == NGX_ERROR) { + ngx_log_error(NGX_LOG_CRIT, c->log, ngx_socket_errno, + ngx_tcp_push_n " failed"); + ngx_http_close_connection(c); + return; + } + c->tcp_nopush = 0; + } + if ((ngx_event_flags & NGX_HAVE_AIO_EVENT) || blocked) { ngx_http_keepalive_handler(rev); } diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c index 8989f7c0a..0f7c95330 100644 --- a/src/http/ngx_http_header_filter.c +++ b/src/http/ngx_http_header_filter.c @@ -4,6 +4,12 @@ #include <ngx_http.h> #include <nginx.h> +/* STUB probably, needed for ngx_freebsd_tcp_nopush_flush */ +#ifdef __FreeBSD__ +#include <ngx_freebsd_init.h> +#endif + + static int ngx_http_header_filter_init(ngx_pool_t *pool); static int ngx_http_header_filter(ngx_http_request_t *r); @@ -94,6 +100,23 @@ static int ngx_http_header_filter(ngx_http_request_t *r) ngx_chain_t *ch; ngx_table_elt_t *header; +#ifdef __FreeBSD__ + + if (r->keepalive) { + if (ngx_freebsd_tcp_nopush_flush) { + r->connection->tcp_nopush_enabled = 1; + } + + } else { + r->connection->tcp_nopush_enabled = 1; + } + +#else + + r->connection->tcp_nopush_enabled = 1; + +#endif + if (r->http_version < NGX_HTTP_VERSION_10) { return NGX_OK; } @@ -219,12 +242,12 @@ static int ngx_http_header_filter(ngx_http_request_t *r) len += 28; } - if (r->keepalive == 0) { - /* "Connection: close\r\n" */ - len += 19; - } else { + if (r->keepalive) { /* "Connection: keep-alive\r\n" */ len += 24; + } else { + /* "Connection: close\r\n" */ + len += 19; } header = (ngx_table_elt_t *) r->headers_out.headers->elts; @@ -323,11 +346,11 @@ static int ngx_http_header_filter(ngx_http_request_t *r) h->last = ngx_cpymem(h->last, "Transfer-Encoding: chunked" CRLF, 28); } - if (r->keepalive == 0) { - h->last = ngx_cpymem(h->last, "Connection: close" CRLF, 19); + if (r->keepalive) { + h->last = ngx_cpymem(h->last, "Connection: keep-alive" CRLF, 24); } else { - h->last = ngx_cpymem(h->last, "Connection: keep-alive" CRLF, 24); + h->last = ngx_cpymem(h->last, "Connection: close" CRLF, 19); } for (i = 0; i < r->headers_out.headers->nelts; i++) { |
