comparison src/http/ngx_http_upstream.c @ 118:644a7935144b NGINX_0_3_6

nginx 0.3.6 *) Change: now the IMAP/POP3 proxy do not send the empty login to authorization server. *) Feature: the "log_format" supports the variables in the $name form. *) Bugfix: if at least in one server was no the "listen" directive, then nginx did not listen on the 80 port; bug appeared in 0.3.3. *) Bugfix: if the URI part is omitted in "proxy_pass" directive, the the 80 port was always used.
author Igor Sysoev <http://sysoev.ru>
date Mon, 24 Oct 2005 00:00:00 +0400
parents 408f195b3482
children d25a1d6034f1
comparison
equal deleted inserted replaced
117:0821ea4ccfc5 118:644a7935144b
27 static void ngx_http_upstream_process_downstream(ngx_http_request_t *r); 27 static void ngx_http_upstream_process_downstream(ngx_http_request_t *r);
28 static void ngx_http_upstream_process_body(ngx_event_t *ev); 28 static void ngx_http_upstream_process_body(ngx_event_t *ev);
29 static void ngx_http_upstream_dummy_handler(ngx_event_t *wev); 29 static void ngx_http_upstream_dummy_handler(ngx_event_t *wev);
30 static void ngx_http_upstream_next(ngx_http_request_t *r, 30 static void ngx_http_upstream_next(ngx_http_request_t *r,
31 ngx_http_upstream_t *u, ngx_uint_t ft_type); 31 ngx_http_upstream_t *u, ngx_uint_t ft_type);
32 static void ngx_http_upstream_cleanup(void *data);
32 static void ngx_http_upstream_finalize_request(ngx_http_request_t *r, 33 static void ngx_http_upstream_finalize_request(ngx_http_request_t *r,
33 ngx_http_upstream_t *u, ngx_int_t rc); 34 ngx_http_upstream_t *u, ngx_int_t rc);
34 35
35 static ngx_int_t ngx_http_upstream_process_header_line(ngx_http_request_t *r, 36 static ngx_int_t ngx_http_upstream_process_header_line(ngx_http_request_t *r,
36 ngx_table_elt_t *h, ngx_uint_t offset); 37 ngx_table_elt_t *h, ngx_uint_t offset);
221 void 222 void
222 ngx_http_upstream_init(ngx_http_request_t *r) 223 ngx_http_upstream_init(ngx_http_request_t *r)
223 { 224 {
224 ngx_time_t *tp; 225 ngx_time_t *tp;
225 ngx_connection_t *c; 226 ngx_connection_t *c;
227 ngx_http_cleanup_t *cln;
226 ngx_http_upstream_t *u; 228 ngx_http_upstream_t *u;
227 ngx_http_core_loc_conf_t *clcf; 229 ngx_http_core_loc_conf_t *clcf;
228 230
229 c = r->connection; 231 c = r->connection;
230 232
275 u->output.filter_ctx = &u->writer; 277 u->output.filter_ctx = &u->writer;
276 278
277 u->writer.pool = r->pool; 279 u->writer.pool = r->pool;
278 280
279 if (ngx_array_init(&u->states, r->pool, u->peer.peers->number, 281 if (ngx_array_init(&u->states, r->pool, u->peer.peers->number,
280 sizeof(ngx_http_upstream_state_t)) != NGX_OK) 282 sizeof(ngx_http_upstream_state_t))
283 != NGX_OK)
281 { 284 {
282 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 285 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
283 return; 286 return;
284 } 287 }
285 288
292 ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t)); 295 ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t));
293 296
294 tp = ngx_timeofday(); 297 tp = ngx_timeofday();
295 298
296 u->state->response_time = tp->sec * 1000 + tp->msec; 299 u->state->response_time = tp->sec * 1000 + tp->msec;
300
301 cln = ngx_http_cleanup_add(r, sizeof(void *));
302 if (cln == NULL) {
303 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
304 return;
305 }
306
307 cln->handler = ngx_http_upstream_cleanup;
308 cln->data = r;
309 u->cleanup = &cln->handler;
297 310
298 ngx_http_upstream_connect(r, u); 311 ngx_http_upstream_connect(r, u);
299 } 312 }
300 313
301 314
1377 default: 1390 default:
1378 status = NGX_HTTP_BAD_GATEWAY; 1391 status = NGX_HTTP_BAD_GATEWAY;
1379 } 1392 }
1380 } 1393 }
1381 1394
1382 if (r->connection->write->eof) { 1395 if (r->connection->closed) {
1383 r->connection->closed = 1;
1384 ngx_http_upstream_finalize_request(r, u, 1396 ngx_http_upstream_finalize_request(r, u,
1385 NGX_HTTP_CLIENT_CLOSED_REQUEST); 1397 NGX_HTTP_CLIENT_CLOSED_REQUEST);
1386 return; 1398 return;
1387 } 1399 }
1388 1400
1424 ngx_http_upstream_connect(r, u); 1436 ngx_http_upstream_connect(r, u);
1425 } 1437 }
1426 1438
1427 1439
1428 static void 1440 static void
1441 ngx_http_upstream_cleanup(void *data)
1442 {
1443 ngx_http_request_t *r = data;
1444
1445 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1446 "cleanup http upstream request: \"%V\"", &r->uri);
1447
1448 ngx_http_upstream_finalize_request(r, r->upstream, NGX_DONE);
1449 }
1450
1451
1452 static void
1429 ngx_http_upstream_finalize_request(ngx_http_request_t *r, 1453 ngx_http_upstream_finalize_request(ngx_http_request_t *r,
1430 ngx_http_upstream_t *u, ngx_int_t rc) 1454 ngx_http_upstream_t *u, ngx_int_t rc)
1431 { 1455 {
1432 ngx_time_t *tp; 1456 ngx_time_t *tp;
1433 1457
1434 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1458 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1435 "finalize http upstream request: %i", rc); 1459 "finalize http upstream request: %i", rc);
1460
1461 *u->cleanup = NULL;
1436 1462
1437 if (u->state->response_time) { 1463 if (u->state->response_time) {
1438 tp = ngx_timeofday(); 1464 tp = ngx_timeofday();
1439 u->state->response_time = tp->sec * 1000 + tp->msec 1465 u->state->response_time = tp->sec * 1000 + tp->msec
1440 - u->state->response_time; 1466 - u->state->response_time;
1862 u = r->upstream; 1888 u = r->upstream;
1863 peer = &u->peer; 1889 peer = &u->peer;
1864 1890
1865 p = ngx_snprintf(buf, len, 1891 p = ngx_snprintf(buf, len,
1866 ", server: %V, URL: \"%V\"," 1892 ", server: %V, URL: \"%V\","
1867 " upstream: %V%V%s%V", 1893 " upstream: \"%V%V%s%V\"",
1868 &r->server_name, 1894 &r->server_name,
1869 &r->unparsed_uri, 1895 &r->unparsed_uri,
1870 &u->conf->schema, 1896 &u->conf->schema,
1871 &peer->peers->peer[peer->cur_peer].name, 1897 &peer->peers->peer[peer->cur_peer].name,
1872 peer->peers->peer[peer->cur_peer].uri_separator, 1898 peer->peers->peer[peer->cur_peer].uri_separator,