Mercurial > hg > nginx-vendor-0-5
comparison src/http/ngx_http_upstream.c @ 112:408f195b3482 NGINX_0_3_3
nginx 0.3.3
*) Change: the "bl" and "af" parameters of the "listen" directive was
renamed to the "backlog" and "accept_filter".
*) Feature: the "rcvbuf" and "sndbuf" parameters of the "listen"
directive.
*) Change: the "$msec" log parameter does not require now the
additional the gettimeofday() system call.
*) Feature: the -t switch now tests the "listen" directives.
*) Bugfix: if the invalid address was specified in the "listen"
directive, then after the -HUP signal nginx left an open socket in
the CLOSED state.
*) Bugfix: the mime type may be incorrectly set to default value for
index file with variable in the name; bug appeared in 0.3.0.
*) Feature: the "timer_resolution" directive.
*) Feature: the millisecond "$upstream_response_time" log parameter.
*) Bugfix: a temporary file with client request body now is removed
just after the response header was transferred to a client.
*) Bugfix: OpenSSL 0.9.6 compatibility.
*) Bugfix: the SSL certificate and key file paths could not be relative.
*) Bugfix: the "ssl_prefer_server_ciphers" directive did not work in
the ngx_imap_ssl_module.
*) Bugfix: the "ssl_protocols" directive allowed to specify the single
protocol only.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 19 Oct 2005 00:00:00 +0400 |
parents | dad2fe8ecf08 |
children | 644a7935144b |
comparison
equal
deleted
inserted
replaced
111:a175b609c76d | 112:408f195b3482 |
---|---|
64 | 64 |
65 static size_t ngx_http_upstream_log_status_getlen(ngx_http_request_t *r, | 65 static size_t ngx_http_upstream_log_status_getlen(ngx_http_request_t *r, |
66 uintptr_t data); | 66 uintptr_t data); |
67 static u_char *ngx_http_upstream_log_status(ngx_http_request_t *r, | 67 static u_char *ngx_http_upstream_log_status(ngx_http_request_t *r, |
68 u_char *buf, ngx_http_log_op_t *op); | 68 u_char *buf, ngx_http_log_op_t *op); |
69 static u_char *ngx_http_upstream_log_response_time(ngx_http_request_t *r, | |
70 u_char *buf, ngx_http_log_op_t *op); | |
69 | 71 |
70 static u_char *ngx_http_upstream_log_error(ngx_http_request_t *r, u_char *buf, | 72 static u_char *ngx_http_upstream_log_error(ngx_http_request_t *r, u_char *buf, |
71 size_t len); | 73 size_t len); |
72 static ngx_int_t ngx_http_upstream_add_log_formats(ngx_conf_t *cf); | 74 static ngx_int_t ngx_http_upstream_add_log_formats(ngx_conf_t *cf); |
73 static void *ngx_http_upstream_create_main_conf(ngx_conf_t *cf); | 75 static void *ngx_http_upstream_create_main_conf(ngx_conf_t *cf); |
202 | 204 |
203 static ngx_http_log_op_name_t ngx_http_upstream_log_fmt_ops[] = { | 205 static ngx_http_log_op_name_t ngx_http_upstream_log_fmt_ops[] = { |
204 { ngx_string("upstream_status"), 0, NULL, | 206 { ngx_string("upstream_status"), 0, NULL, |
205 ngx_http_upstream_log_status_getlen, | 207 ngx_http_upstream_log_status_getlen, |
206 ngx_http_upstream_log_status }, | 208 ngx_http_upstream_log_status }, |
209 { ngx_string("upstream_response_time"), NGX_TIME_T_LEN + 4, NULL, NULL, | |
210 ngx_http_upstream_log_response_time }, | |
207 { ngx_null_string, 0, NULL, NULL, NULL } | 211 { ngx_null_string, 0, NULL, NULL, NULL } |
208 }; | 212 }; |
209 | 213 |
210 | 214 |
211 char *ngx_http_upstream_header_errors[] = { | 215 char *ngx_http_upstream_header_errors[] = { |
215 | 219 |
216 | 220 |
217 void | 221 void |
218 ngx_http_upstream_init(ngx_http_request_t *r) | 222 ngx_http_upstream_init(ngx_http_request_t *r) |
219 { | 223 { |
224 ngx_time_t *tp; | |
220 ngx_connection_t *c; | 225 ngx_connection_t *c; |
221 ngx_http_upstream_t *u; | 226 ngx_http_upstream_t *u; |
222 ngx_http_core_loc_conf_t *clcf; | 227 ngx_http_core_loc_conf_t *clcf; |
223 | 228 |
224 c = r->connection; | 229 c = r->connection; |
283 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 288 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
284 return; | 289 return; |
285 } | 290 } |
286 | 291 |
287 ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t)); | 292 ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t)); |
293 | |
294 tp = ngx_timeofday(); | |
295 | |
296 u->state->response_time = tp->sec * 1000 + tp->msec; | |
288 | 297 |
289 ngx_http_upstream_connect(r, u); | 298 ngx_http_upstream_connect(r, u); |
290 } | 299 } |
291 | 300 |
292 | 301 |
976 ngx_int_t rc; | 985 ngx_int_t rc; |
977 ngx_uint_t i, key; | 986 ngx_uint_t i, key; |
978 ngx_list_part_t *part; | 987 ngx_list_part_t *part; |
979 ngx_table_elt_t *h; | 988 ngx_table_elt_t *h; |
980 ngx_event_pipe_t *p; | 989 ngx_event_pipe_t *p; |
990 ngx_pool_cleanup_t *cl; | |
991 ngx_pool_cleanup_file_t *clf; | |
981 ngx_http_core_loc_conf_t *clcf; | 992 ngx_http_core_loc_conf_t *clcf; |
982 ngx_http_upstream_header_t *hh; | 993 ngx_http_upstream_header_t *hh; |
983 ngx_http_upstream_main_conf_t *umcf; | 994 ngx_http_upstream_main_conf_t *umcf; |
984 | 995 |
985 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); | 996 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); |
1030 ngx_http_upstream_finalize_request(r, u, rc); | 1041 ngx_http_upstream_finalize_request(r, u, rc); |
1031 return; | 1042 return; |
1032 } | 1043 } |
1033 | 1044 |
1034 u->header_sent = 1; | 1045 u->header_sent = 1; |
1046 | |
1047 if (r->request_body->temp_file) { | |
1048 for (cl = r->pool->cleanup; cl; cl = cl->next) { | |
1049 if (cl->handler == ngx_pool_cleanup_file) { | |
1050 clf = cl->data; | |
1051 | |
1052 if (clf->fd == r->request_body->temp_file->file.fd) { | |
1053 cl->handler(clf); | |
1054 cl->handler = NULL; | |
1055 break; | |
1056 } | |
1057 } | |
1058 } | |
1059 } | |
1035 | 1060 |
1036 /* TODO: preallocate event_pipe bufs, look "Content-Length" */ | 1061 /* TODO: preallocate event_pipe bufs, look "Content-Length" */ |
1037 | 1062 |
1038 #if 0 | 1063 #if 0 |
1039 | 1064 |
1402 | 1427 |
1403 static void | 1428 static void |
1404 ngx_http_upstream_finalize_request(ngx_http_request_t *r, | 1429 ngx_http_upstream_finalize_request(ngx_http_request_t *r, |
1405 ngx_http_upstream_t *u, ngx_int_t rc) | 1430 ngx_http_upstream_t *u, ngx_int_t rc) |
1406 { | 1431 { |
1432 ngx_time_t *tp; | |
1433 | |
1407 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 1434 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1408 "finalize http upstream request: %i", rc); | 1435 "finalize http upstream request: %i", rc); |
1436 | |
1437 if (u->state->response_time) { | |
1438 tp = ngx_timeofday(); | |
1439 u->state->response_time = tp->sec * 1000 + tp->msec | |
1440 - u->state->response_time; | |
1441 } | |
1409 | 1442 |
1410 u->finalize_request(r, rc); | 1443 u->finalize_request(r, rc); |
1411 | 1444 |
1412 if (u->peer.connection) { | 1445 if (u->peer.connection) { |
1413 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 1446 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1417 ngx_close_connection(u->peer.connection); | 1450 ngx_close_connection(u->peer.connection); |
1418 } | 1451 } |
1419 | 1452 |
1420 u->peer.connection = NULL; | 1453 u->peer.connection = NULL; |
1421 | 1454 |
1422 if (u->header_sent | 1455 if (u->header_sent && (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE)) |
1423 && (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE)) | |
1424 { | 1456 { |
1425 rc = 0; | 1457 rc = 0; |
1426 } | 1458 } |
1427 | 1459 |
1428 if (u->pipe.temp_file) { | 1460 if (u->pipe.temp_file) { |
1768 if (state[i].status == 0) { | 1800 if (state[i].status == 0) { |
1769 *buf++ = '-'; | 1801 *buf++ = '-'; |
1770 | 1802 |
1771 } else { | 1803 } else { |
1772 buf = ngx_sprintf(buf, "%ui", state[i].status); | 1804 buf = ngx_sprintf(buf, "%ui", state[i].status); |
1805 } | |
1806 | |
1807 if (++i == u->states.nelts) { | |
1808 return buf; | |
1809 } | |
1810 | |
1811 *buf++ = ','; | |
1812 *buf++ = ' '; | |
1813 } | |
1814 } | |
1815 | |
1816 | |
1817 static u_char * | |
1818 ngx_http_upstream_log_response_time(ngx_http_request_t *r, u_char *buf, | |
1819 ngx_http_log_op_t *op) | |
1820 { | |
1821 ngx_uint_t i; | |
1822 ngx_http_upstream_t *u; | |
1823 ngx_http_upstream_state_t *state; | |
1824 | |
1825 u = r->upstream; | |
1826 | |
1827 if (u == NULL) { | |
1828 *buf = '-'; | |
1829 return buf + 1; | |
1830 } | |
1831 | |
1832 i = 0; | |
1833 state = u->states.elts; | |
1834 | |
1835 for ( ;; ) { | |
1836 if (state[i].status == 0) { | |
1837 *buf++ = '-'; | |
1838 | |
1839 } else { | |
1840 buf = ngx_sprintf(buf, "%d.%03d", | |
1841 state[i].response_time / 1000, | |
1842 state[i].response_time % 1000); | |
1773 } | 1843 } |
1774 | 1844 |
1775 if (++i == u->states.nelts) { | 1845 if (++i == u->states.nelts) { |
1776 return buf; | 1846 return buf; |
1777 } | 1847 } |