aboutsummaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-04-13 15:08:48 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-04-13 15:08:48 +0000
commit3d54061602b20fa5a6fdf55b11cb333285d61d03 (patch)
treedc7cb2320ba0f21cda2cd87096481c0731074296 /src/http
parenta21e30b91900dbbde5ea7fbc5ed4b2ec59969de7 (diff)
downloadnginx-3d54061602b20fa5a6fdf55b11cb333285d61d03.tar.gz
nginx-3d54061602b20fa5a6fdf55b11cb333285d61d03.zip
nginx-0.0.3-2004-04-13-19:08:48 import
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.c9
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_upstream.c43
-rw-r--r--src/http/ngx_http_headers.c1
-rw-r--r--src/http/ngx_http_request.c7
-rw-r--r--src/http/ngx_http_request.h1
5 files changed, 38 insertions, 23 deletions
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 017d7c8d0..0fd89c139 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -425,7 +425,9 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *ev)
n = recv(c->fd, buf, 1, MSG_PEEK);
- if (ev->write && n >= 0) {
+ err = ngx_socket_errno;
+
+ if (ev->write && (n >= 0 || err == NGX_EAGAIN)) {
return;
}
@@ -443,7 +445,6 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *ev)
ev->eof = 1;
if (n == -1) {
- err = ngx_socket_errno;
if (err == NGX_EAGAIN) {
return;
}
@@ -634,11 +635,11 @@ void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p)
ngx_del_conn(c, NGX_CLOSE_EVENT);
} else {
- if (c->read->active) {
+ if (c->read->active || c->read->posted) {
ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT);
}
- if (c->write->active) {
+ if (c->write->active || c->read->posted) {
ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
}
}
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index d27975919..760d8d629 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -327,19 +327,20 @@ static void ngx_http_proxy_init_upstream(void *data)
r->connection->read->event_handler = ngx_http_proxy_check_broken_connection;
- if ((ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_HAVE_KQUEUE_EVENT))
- && !r->connection->write->active)
- {
+ if (ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_HAVE_KQUEUE_EVENT)) {
+
/* kqueue allows to detect when client closes prematurely connection */
r->connection->write->event_handler =
ngx_http_proxy_check_broken_connection;
- if (ngx_add_event(r->connection->write, NGX_WRITE_EVENT,
+ if (!r->connection->write->active) {
+ if (ngx_add_event(r->connection->write, NGX_WRITE_EVENT,
NGX_CLEAR_EVENT) == NGX_ERROR)
- {
- ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
- return;
+ {
+ ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
}
}
@@ -560,6 +561,9 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
rc = ngx_event_connect_peer(&p->upstream->peer);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0,
+ "http proxy connect: %d", rc);
+
if (rc == NGX_ERROR) {
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
return;
@@ -573,14 +577,13 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
return;
}
- p->upstream->peer.connection->data = p;
- p->upstream->peer.connection->write->event_handler =
- ngx_http_proxy_send_request_handler;
- p->upstream->peer.connection->read->event_handler =
- ngx_http_proxy_process_upstream_status_line;
-
r = p->request;
c = p->upstream->peer.connection;
+
+ c->data = p;
+ c->write->event_handler = ngx_http_proxy_send_request_handler;
+ c->read->event_handler = ngx_http_proxy_process_upstream_status_line;
+
c->pool = r->pool;
c->read->log = c->write->log = c->log = r->connection->log;
@@ -613,6 +616,11 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
if (rc == NGX_AGAIN) {
ngx_add_timer(c->write, p->lcf->connect_timeout);
+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "http proxy connect handler: " PTR_FMT,
+ c->write->event_handler);
+
return;
}
@@ -638,6 +646,9 @@ static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p)
c = p->upstream->peer.connection;
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "http proxy send request");
+
#if (HAVE_KQUEUE)
if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)
@@ -715,8 +726,7 @@ static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p)
}
#endif
- p->upstream->peer.connection->write->event_handler =
- ngx_http_proxy_dummy_handler;
+ c->write->event_handler = ngx_http_proxy_dummy_handler;
if (ngx_handle_level_write_event(c->write) == NGX_ERROR) {
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -733,6 +743,9 @@ static void ngx_http_proxy_send_request_handler(ngx_event_t *wev)
c = wev->data;
p = c->data;
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0,
+ "http proxy send request handler");
+
if (wev->timedout) {
p->action = "sending request to upstream";
ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_TIMEOUT);
diff --git a/src/http/ngx_http_headers.c b/src/http/ngx_http_headers.c
index 57413afae..8c925be21 100644
--- a/src/http/ngx_http_headers.c
+++ b/src/http/ngx_http_headers.c
@@ -22,6 +22,7 @@ ngx_http_header_t ngx_http_headers_in[] = {
#if (NGX_HTTP_GZIP)
{ ngx_string("Accept-Encoding"),
offsetof(ngx_http_headers_in_t, accept_encoding) },
+ { ngx_string("Via"), offsetof(ngx_http_headers_in_t, via) },
#endif
{ ngx_string("Authorization"),
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 9233f89d8..976475e5e 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -97,8 +97,7 @@ void ngx_http_init_connection(ngx_connection_t *c)
return;
}
- rev->next = (ngx_event_t *) ngx_posted_events;
- ngx_posted_events = rev;
+ ngx_post_event(rev);
ngx_mutex_unlock(ngx_posted_events_mutex);
return;
@@ -1613,11 +1612,11 @@ void ngx_http_close_connection(ngx_connection_t *c)
ngx_del_conn(c, NGX_CLOSE_EVENT);
} else {
- if (c->read->active || c->read->disabled) {
+ if (c->read->active || c->read->posted || c->read->disabled) {
ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT);
}
- if (c->write->active || c->write->disabled) {
+ if (c->write->active || c->write->posted || c->write->disabled) {
ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
}
}
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 5e127e8fc..215dedfe8 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -100,6 +100,7 @@ typedef struct {
#if (NGX_HTTP_GZIP)
ngx_table_elt_t *accept_encoding;
+ ngx_table_elt_t *via;
#endif
ngx_table_elt_t *authorization;