comparison src/http/ngx_http_request.c @ 426:3f88935a02e8

nginx-0.0.10-2004-09-14-23:39:54 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 14 Sep 2004 19:39:54 +0000
parents fda5987b188d
children 0d08eabe5c7b
comparison
equal deleted inserted replaced
425:bd39260a1383 426:3f88935a02e8
94 94
95 void ngx_http_init_connection(ngx_connection_t *c) 95 void ngx_http_init_connection(ngx_connection_t *c)
96 { 96 {
97 ngx_event_t *rev; 97 ngx_event_t *rev;
98 ngx_http_log_ctx_t *ctx; 98 ngx_http_log_ctx_t *ctx;
99
100 #if (NGX_STAT_STUB)
101 (*ngx_stat_reading)++;
102 #endif
99 103
100 if (!(ctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) { 104 if (!(ctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) {
101 ngx_http_close_connection(c); 105 ngx_http_close_connection(c);
102 return; 106 return;
103 } 107 }
311 if (!(r->pool = ngx_create_pool(cscf->request_pool_size, c->log))) { 315 if (!(r->pool = ngx_create_pool(cscf->request_pool_size, c->log))) {
312 ngx_http_close_connection(c); 316 ngx_http_close_connection(c);
313 return; 317 return;
314 } 318 }
315 319
316 r->cleanup.elts = ngx_palloc(r->pool, 5 * sizeof(ngx_http_cleanup_t)); 320 if (ngx_array_init(&r->cleanup, r->pool, 5, sizeof(ngx_http_cleanup_t))
317 if (r->cleanup.elts == NULL) { 321 == NGX_ERROR)
322 {
318 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 323 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
319 ngx_http_close_connection(c); 324 ngx_http_close_connection(c);
320 return; 325 return;
321 } 326 }
322
323 /*
324 * set by ngx_pcalloc():
325 *
326 * r->cleanup.nelts = 0;
327 */
328 r->cleanup.nalloc = 5;
329 r->cleanup.size = sizeof(ngx_http_cleanup_t);
330 r->cleanup.pool = r->pool;
331 327
332 328
333 if (ngx_list_init(&r->headers_out.headers, r->pool, 20, 329 if (ngx_list_init(&r->headers_out.headers, r->pool, 20,
334 sizeof(ngx_table_elt_t)) == NGX_ERROR) 330 sizeof(ngx_table_elt_t)) == NGX_ERROR)
335 { 331 {
357 r->headers_in.keep_alive_n = -1; 353 r->headers_in.keep_alive_n = -1;
358 r->headers_out.content_length_n = -1; 354 r->headers_out.content_length_n = -1;
359 r->headers_out.last_modified_time = -1; 355 r->headers_out.last_modified_time = -1;
360 356
361 r->http_state = NGX_HTTP_READING_REQUEST_STATE; 357 r->http_state = NGX_HTTP_READING_REQUEST_STATE;
358
359 #if (NGX_STAT_STUB)
360 (*ngx_stat_requests)++;
361 #endif
362 362
363 rev->event_handler(rev); 363 rev->event_handler(rev);
364 } 364 }
365 365
366 366
864 } 864 }
865 865
866 if (rev->timer_set) { 866 if (rev->timer_set) {
867 ngx_del_timer(rev); 867 ngx_del_timer(rev);
868 } 868 }
869
870 #if (NGX_STAT_STUB)
871 (*ngx_stat_reading)--;
872 (*ngx_stat_writing)++;
873 #endif
869 874
870 rev->event_handler = ngx_http_block_read; 875 rev->event_handler = ngx_http_block_read;
871 ngx_http_handler(r); 876 ngx_http_handler(r);
872 return; 877 return;
873 878
1141 if (r->connection->write->timer_set) { 1146 if (r->connection->write->timer_set) {
1142 ngx_del_timer(r->connection->write); 1147 ngx_del_timer(r->connection->write);
1143 } 1148 }
1144 1149
1145 if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) { 1150 if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) {
1151
1152 #if (NGX_STAT_STUB)
1153 (*ngx_stat_writing)--;
1154 #endif
1155
1146 ngx_http_close_request(r, 0); 1156 ngx_http_close_request(r, 0);
1147 ngx_http_close_connection(r->connection); 1157 ngx_http_close_connection(r->connection);
1148 return; 1158 return;
1149 } 1159 }
1150 1160
1151 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc)); 1161 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
1152 1162
1153 return; 1163 return;
1154 1164
1155 } else if (rc == NGX_ERROR) { 1165 } else if (rc == NGX_ERROR) {
1166
1167 #if (NGX_STAT_STUB)
1168 (*ngx_stat_writing)--;
1169 #endif
1170
1156 ngx_http_close_request(r, 0); 1171 ngx_http_close_request(r, 0);
1157 ngx_http_close_connection(r->connection); 1172 ngx_http_close_connection(r->connection);
1158 return; 1173 return;
1159 1174
1160 } else if (rc == NGX_AGAIN) { 1175 } else if (rc == NGX_AGAIN) {
1161 ngx_http_set_write_handler(r); 1176 ngx_http_set_write_handler(r);
1162 return; 1177 return;
1163 } 1178 }
1179
1180 #if (NGX_STAT_STUB)
1181 (*ngx_stat_writing)--;
1182 #endif
1164 1183
1165 if (r->connection->read->timer_set) { 1184 if (r->connection->read->timer_set) {
1166 ngx_del_timer(r->connection->read); 1185 ngx_del_timer(r->connection->read);
1167 } 1186 }
1168 1187
1885 void ngx_http_close_connection(ngx_connection_t *c) 1904 void ngx_http_close_connection(ngx_connection_t *c)
1886 { 1905 {
1887 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 1906 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
1888 "close http connection: %d", c->fd); 1907 "close http connection: %d", c->fd);
1889 1908
1909 #if (NGX_STAT_STUB)
1910 (*ngx_stat_active)--;
1911 #endif
1912
1890 ngx_close_connection(c); 1913 ngx_close_connection(c);
1891 } 1914 }
1892 1915
1893 1916
1894 static void ngx_http_client_error(ngx_http_request_t *r, 1917 static void ngx_http_client_error(ngx_http_request_t *r,