diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-12-18 16:02:44 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2005-12-18 16:02:44 +0000 |
commit | 43f279dc9c57673ffdf6058590ee16f798fb0b24 (patch) | |
tree | 70f1073e0a266f1888469712709df3817dc2df1b /src/http/ngx_http_upstream.c | |
parent | d10f2fb86f787f8e5bffd5877f2a0cf72afb1d55 (diff) | |
download | nginx-release-0.3.17.tar.gz nginx-release-0.3.17.zip |
nginx-0.3.17-RELEASE importrelease-0.3.17
*) Change: now on Linux configure checks the presence of epoll and
sendfile64() in kernel.
*) Feature: the "map" directive supports domain names in the
".domain.tld" form.
*) Bugfix: the timeouts were not used in SSL handshake; the bug had
appeared in 0.2.4.
*) Bugfix: in the HTTPS protocol in the "proxy_pass" directive.
*) Bugfix: when the HTTPS protocol was used in the "proxy_pass"
directive the port 80 was used by default.
Diffstat (limited to 'src/http/ngx_http_upstream.c')
-rw-r--r-- | src/http/ngx_http_upstream.c | 88 |
1 files changed, 53 insertions, 35 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index fc57fe47b..5711b4abf 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -90,6 +90,8 @@ static void *ngx_http_upstream_create_main_conf(ngx_conf_t *cf); static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf); #if (NGX_HTTP_SSL) +static void ngx_http_upstream_ssl_init_connection(ngx_http_request_t *, + ngx_http_upstream_t *u, ngx_connection_t *c); static void ngx_http_upstream_ssl_handshake(ngx_connection_t *c); static void ngx_http_upstream_ssl_shutdown(ngx_connection_t *c, ngx_peer_t *peer); @@ -498,9 +500,8 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r, static void ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u) { - ngx_int_t rc; - ngx_peer_t *peer; - ngx_connection_t *c; + ngx_int_t rc; + ngx_connection_t *c; r->connection->log->action = "connecting to upstream"; @@ -517,8 +518,7 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u) return; } - peer = &u->peer.peers->peer[u->peer.cur_peer]; - u->state->peer = &peer->name; + u->state->peer = &u->peer.peers->peer[u->peer.cur_peer].name; if (rc == NGX_BUSY) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no live upstreams"); @@ -534,6 +534,7 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u) c = u->peer.connection; c->data = r; + c->write->handler = ngx_http_upstream_send_request_handler; c->read->handler = ngx_http_upstream_process_header; @@ -587,50 +588,57 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u) return; } - /* rc == NGX_OK */ - #if (NGX_HTTP_SSL) - if (u->conf->ssl) { - if (c->ssl == NULL) { + if (u->conf->ssl && c->ssl == NULL) { + ngx_http_upstream_ssl_init_connection(r, u, c); + return; + } - if (ngx_ssl_create_connection(u->conf->ssl, c, - NGX_SSL_BUFFER|NGX_SSL_CLIENT) - == NGX_ERROR) - { - ngx_http_upstream_finalize_request(r, u, - NGX_HTTP_INTERNAL_SERVER_ERROR); - return; - } +#endif - c->sendfile = 0; - } + ngx_http_upstream_send_request(r, u); +} - if (ngx_ssl_set_session(c, peer->ssl_session) != NGX_OK) { - ngx_http_upstream_finalize_request(r, u, - NGX_HTTP_INTERNAL_SERVER_ERROR); - return; - } - rc = ngx_ssl_handshake(c); +#if (NGX_HTTP_SSL) - if (rc == NGX_AGAIN) { - c->ssl->handler = ngx_http_upstream_ssl_handshake; - return; - } +static void +ngx_http_upstream_ssl_init_connection(ngx_http_request_t *r, + ngx_http_upstream_t *u, ngx_connection_t *c) +{ + ngx_int_t rc; + ngx_peer_t *peer; - ngx_http_upstream_ssl_handshake(c); + if (ngx_ssl_create_connection(u->conf->ssl, c, + NGX_SSL_BUFFER|NGX_SSL_CLIENT) + == NGX_ERROR) + { + ngx_http_upstream_finalize_request(r, u, + NGX_HTTP_INTERNAL_SERVER_ERROR); + return; + } + + c->sendfile = 0; + peer = &u->peer.peers->peer[u->peer.cur_peer]; + + if (ngx_ssl_set_session(c, peer->ssl_session) != NGX_OK) { + ngx_http_upstream_finalize_request(r, u, + NGX_HTTP_INTERNAL_SERVER_ERROR); return; } -#endif + rc = ngx_ssl_handshake(c); - ngx_http_upstream_send_request(r, u); -} + if (rc == NGX_AGAIN) { + c->ssl->handler = ngx_http_upstream_ssl_handshake; + return; + } + ngx_http_upstream_ssl_handshake(c); +} -#if (NGX_HTTP_SSL) static void ngx_http_upstream_ssl_handshake(ngx_connection_t *c) @@ -671,7 +679,8 @@ ngx_http_upstream_reinit(ngx_http_request_t *r, ngx_http_upstream_t *u) sizeof(ngx_http_upstream_headers_in_t)); if (ngx_list_init(&r->upstream->headers_in.headers, r->pool, 8, - sizeof(ngx_table_elt_t)) != NGX_OK) + sizeof(ngx_table_elt_t)) + != NGX_OK) { return NGX_ERROR; } @@ -851,6 +860,15 @@ ngx_http_upstream_send_request_handler(ngx_event_t *wev) return; } +#if (NGX_HTTP_SSL) + + if (u->conf->ssl && c->ssl == NULL) { + ngx_http_upstream_ssl_init_connection(r, u, c); + return; + } + +#endif + ngx_http_upstream_send_request(r, u); } |