nginx-0.3.5-RELEASE import
*) Bugfix: the segmentation fault may occurred if the IMAP/POP3 login
was changed by authorization server; the bug had appeared in 0.2.2.
*) Bugfix: the accept mutex did not work and all connections were
handled by one process; the bug had appeared in 0.3.3.
*) Bugfix: the timeout did not work if the "rtsig" method and the
"timer_resolution" directive were used.
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 9071ae5..58f13c4 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -159,23 +159,18 @@
/* STUB: epoll edge */ c->write->handler = ngx_http_empty_handler;
+#if (NGX_STAT_STUB)
+ ngx_atomic_fetch_add(ngx_stat_reading, 1);
+#endif
+
if (rev->ready) {
/* the deferred accept(), rtsig, aio, iocp */
if (ngx_accept_mutex) {
-
ngx_post_event(rev, &ngx_posted_events);
-
-#if (NGX_STAT_STUB)
- ngx_atomic_fetch_add(ngx_stat_reading, 1);
-#endif
return;
}
-#if (NGX_STAT_STUB)
- ngx_atomic_fetch_add(ngx_stat_reading, 1);
-#endif
-
ngx_http_init_request(rev);
return;
}
@@ -183,14 +178,12 @@
ngx_add_timer(rev, c->listening->post_accept_timeout);
if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
+#if (NGX_STAT_STUB)
+ ngx_atomic_fetch_add(ngx_stat_reading, -1);
+#endif
ngx_http_close_connection(c);
return;
}
-
-#if (NGX_STAT_STUB)
- ngx_atomic_fetch_add(ngx_stat_reading, 1);
-#endif
-
}
@@ -213,35 +206,24 @@
ngx_http_ssl_srv_conf_t *sscf;
#endif
+#if (NGX_STAT_STUB)
+ ngx_atomic_fetch_add(ngx_stat_reading, -1);
+#endif
+
c = rev->data;
if (rev->timedout) {
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
-#if (NGX_STAT_STUB)
- ngx_atomic_fetch_add(ngx_stat_reading, -1);
-#endif
-
ngx_http_close_connection(c);
return;
}
hc = c->data;
- if (hc) {
-
-#if (NGX_STAT_STUB)
- ngx_atomic_fetch_add(ngx_stat_reading, 1);
-#endif
-
- } else {
+ if (hc == NULL) {
hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t));
if (hc == NULL) {
-
-#if (NGX_STAT_STUB)
- ngx_atomic_fetch_add(ngx_stat_reading, -1);
-#endif
-
ngx_http_close_connection(c);
return;
}
@@ -261,11 +243,6 @@
} else {
r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t));
if (r == NULL) {
-
-#if (NGX_STAT_STUB)
- ngx_atomic_fetch_add(ngx_stat_reading, -1);
-#endif
-
ngx_http_close_connection(c);
return;
}
@@ -273,10 +250,6 @@
hc->request = r;
}
-#if (NGX_STAT_STUB)
- ngx_atomic_fetch_add(ngx_stat_reading, -1);
-#endif
-
c->data = r;
r->http_connection = hc;
@@ -1652,8 +1625,15 @@
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT,
"client timed out");
c->timedout = 1;
- ngx_http_close_request(r, NGX_HTTP_REQUEST_TIME_OUT);
+
+#if 0
+ ngx_http_close_request(r->main, NGX_HTTP_REQUEST_TIME_OUT);
ngx_http_close_connection(c);
+#endif
+
+ c->closed = 1;
+ ngx_http_finalize_request(r, 0);
+
return;
}
@@ -1665,7 +1645,7 @@
ngx_add_timer(wev, clcf->send_timeout);
if (ngx_handle_write_event(wev, clcf->send_lowat) == NGX_ERROR) {
- ngx_http_close_request(r, 0);
+ ngx_http_close_request(r->main, 0);
ngx_http_close_connection(r->connection);
}
@@ -1680,7 +1660,7 @@
clcf = ngx_http_get_module_loc_conf(r->main, ngx_http_core_module);
if (ngx_handle_write_event(wev, clcf->send_lowat) == NGX_ERROR) {
- ngx_http_close_request(r, 0);
+ ngx_http_close_request(r->main, 0);
ngx_http_close_connection(r->connection);
}
@@ -1711,7 +1691,7 @@
}
if (ngx_handle_write_event(wev, clcf->send_lowat) == NGX_ERROR) {
- ngx_http_close_request(r, 0);
+ ngx_http_close_request(r->main, 0);
ngx_http_close_connection(r->connection);
}
@@ -1988,8 +1968,13 @@
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "pipelined request");
+#if (NGX_STAT_STUB)
+ ngx_atomic_fetch_add(ngx_stat_reading, 1);
+#endif
+
hc->pipeline = 1;
c->log->action = "reading client pipelined request line";
+
ngx_http_init_request(rev);
return;
}
@@ -2206,6 +2191,10 @@
b->last += n;
+#if (NGX_STAT_STUB)
+ ngx_atomic_fetch_add(ngx_stat_reading, 1);
+#endif
+
c->log->handler = ngx_http_log_error;
c->log->action = "reading client request line";
@@ -2388,6 +2377,7 @@
}
#if (NGX_STAT_STUB)
+
if (r->stat_reading) {
ngx_atomic_fetch_add(ngx_stat_reading, -1);
}
@@ -2395,6 +2385,7 @@
if (r->stat_writing) {
ngx_atomic_fetch_add(ngx_stat_writing, -1);
}
+
#endif
if (error && r->headers_out.status == 0) {