aboutsummaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_rewrite_handler.c10
-rw-r--r--src/http/ngx_http_core_module.c14
-rw-r--r--src/http/ngx_http_core_module.h1
-rw-r--r--src/http/ngx_http_log_handler.h5
-rw-r--r--src/http/ngx_http_request.c22
5 files changed, 38 insertions, 14 deletions
diff --git a/src/http/modules/ngx_http_rewrite_handler.c b/src/http/modules/ngx_http_rewrite_handler.c
index 03414aad7..e06b54bf3 100644
--- a/src/http/modules/ngx_http_rewrite_handler.c
+++ b/src/http/modules/ngx_http_rewrite_handler.c
@@ -113,7 +113,7 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
if (rc == NGX_DECLINED) {
if (scf->log) {
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
- "\"%s\" is not matched", rule[i].re_name.data);
+ "\"%s\" does not match", rule[i].re_name.data);
}
continue;
@@ -129,7 +129,7 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
if (scf->log) {
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
- "\"%s\" matched", rule[i].re_name.data);
+ "\"%s\" matches", rule[i].re_name.data);
}
uri.len = rule[i].size;
@@ -301,8 +301,10 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
}
}
- rule->msize++;
- rule->msize *= 3;
+ if (rule->msize) {
+ rule->msize++;
+ rule->msize *= 3;
+ }
if (cf->args->nelts > 3) {
if (ngx_strcmp(value[3].data, "last") == 0) {
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 873267f40..46c90f8da 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -148,6 +148,13 @@ static ngx_command_t ngx_http_core_commands[] = {
offsetof(ngx_http_core_loc_conf_t, sendfile),
NULL },
+ { ngx_string("tcp_nopush"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_core_loc_conf_t, tcp_nopush),
+ NULL },
+
{ ngx_string("send_timeout"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_msec_slot,
@@ -505,6 +512,11 @@ int ngx_http_find_location_config(ngx_http_request_t *r)
r->sendfile = 1;
}
+ if (!clcf->tcp_nopush) {
+ /* disable TCP_NOPUSH/TCP_CORK use */
+ r->connection->tcp_nopush = -1;
+ }
+
if (auto_redirect) {
if (!(r->headers_out.location =
ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
@@ -1128,6 +1140,7 @@ static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf)
lcf->client_body_timeout = NGX_CONF_UNSET;
lcf->sendfile = NGX_CONF_UNSET;
+ lcf->tcp_nopush = NGX_CONF_UNSET;
lcf->send_timeout = NGX_CONF_UNSET;
lcf->send_lowat = NGX_CONF_UNSET;
lcf->discarded_buffer_size = NGX_CONF_UNSET;
@@ -1206,6 +1219,7 @@ static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
ngx_conf_merge_msec_value(conf->client_body_timeout,
prev->client_body_timeout, 10000);
ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0);
+ ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0);
ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 10000);
ngx_conf_merge_size_value(conf->send_lowat, prev->send_lowat, 0);
ngx_conf_merge_size_value(conf->discarded_buffer_size,
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 6673a18d5..78de144d1 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -122,6 +122,7 @@ typedef struct {
ngx_msec_t client_body_timeout; /* client_body_timeout */
int sendfile; /* sendfile */
+ int tcp_nopush; /* tcp_nopush */
ngx_msec_t send_timeout; /* send_timeout */
ssize_t send_lowat; /* send_lowat */
ssize_t discarded_buffer_size; /* discarded_buffer_size */
diff --git a/src/http/ngx_http_log_handler.h b/src/http/ngx_http_log_handler.h
index eb55f09f7..c67a01b6f 100644
--- a/src/http/ngx_http_log_handler.h
+++ b/src/http/ngx_http_log_handler.h
@@ -15,11 +15,6 @@ typedef char *(*ngx_http_log_op_pt) (ngx_http_request_t *r, char *buf,
#define NGX_HTTP_LOG_ARG (u_int) -1
-/* STUB */
-#define NGX_INT32_LEN sizeof("-2147483648") - 1
-#define NGX_TIME_T_LEN sizeof("-2147483648") - 1
-#define NGX_OFF_T_LEN sizeof("-9223372036854775808") - 1
-
typedef struct {
size_t len;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 6d11f4bbb..a8dfe0ef5 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -82,6 +82,7 @@ void ngx_http_init_connection(ngx_connection_t *c)
rev = c->read;
rev->event_handler = ngx_http_init_request;
+ rev->log_error = NGX_ERROR_INFO;
if (rev->ready) {
/* deferred accept, aio, iocp, epoll */
@@ -896,6 +897,17 @@ void ngx_http_finalize_request(ngx_http_request_t *r, int rc)
ngx_del_timer(r->connection->write);
}
+ if (r->connection->read->kq_eof) {
+#if (NGX_KQUEUE)
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log,
+ r->connection->read->kq_errno,
+ "kevent reported about closed connection by client");
+#endif
+ ngx_http_close_request(r, 0);
+ ngx_http_close_connection(r->connection);
+ return;
+ }
+
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
if (r->keepalive != 0 && clcf->keepalive_timeout > 0) {
@@ -1203,7 +1215,7 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
ctx->action = "keepalive";
- if (c->tcp_nopush) {
+ if (c->tcp_nopush == 1) {
if (ngx_tcp_push(c->fd) == NGX_ERROR) {
ngx_log_error(NGX_LOG_CRIT, c->log, ngx_socket_errno,
ngx_tcp_push_n " failed");
@@ -1239,10 +1251,10 @@ static void ngx_http_keepalive_handler(ngx_event_t *rev)
* so we ignore ECONNRESET here.
*/
- rev->ignore_econnreset = 1;
+ rev->log_error = NGX_ERROR_IGNORE_ECONNRESET;
ngx_set_socket_errno(0);
n = ngx_recv(c, c->buffer->last, c->buffer->end - c->buffer->last);
- rev->ignore_econnreset = 0;
+ rev->log_error = NGX_ERROR_INFO;
if (n == NGX_AGAIN) {
return;
@@ -1506,11 +1518,11 @@ void ngx_http_close_connection(ngx_connection_t *c)
ngx_del_conn(c);
} else {
- if (c->read->active) {
+ if (c->read->active || c->read->disabled) {
ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT);
}
- if (c->write->active) {
+ if (c->write->active || c->write->disabled) {
ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
}
}