comparison src/http/ngx_http_request.c @ 427:0d08eabe5c7b

nginx-0.0.10-2004-09-15-20:00:43 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 15 Sep 2004 16:00:43 +0000
parents 3f88935a02e8
children 694cd6cdb714
comparison
equal deleted inserted replaced
426:3f88935a02e8 427:0d08eabe5c7b
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 99
100 #if (NGX_STAT_STUB)
101 (*ngx_stat_reading)++;
102 #endif
103
104 if (!(ctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) { 100 if (!(ctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) {
105 ngx_http_close_connection(c); 101 ngx_http_close_connection(c);
106 return; 102 return;
107 } 103 }
108 104
131 127
132 ngx_mutex_unlock(ngx_posted_events_mutex); 128 ngx_mutex_unlock(ngx_posted_events_mutex);
133 return; 129 return;
134 } 130 }
135 131
132 #if (NGX_STAT_STUB)
133 (*ngx_stat_reading)++;
134 #endif
135
136 ngx_http_init_request(rev); 136 ngx_http_init_request(rev);
137 return; 137 return;
138 } 138 }
139 139
140 ngx_add_timer(rev, c->listening->post_accept_timeout); 140 ngx_add_timer(rev, c->listening->post_accept_timeout);
153 if (ngx_handle_write_event(c->write, 0) == NGX_ERROR) { 153 if (ngx_handle_write_event(c->write, 0) == NGX_ERROR) {
154 ngx_http_close_connection(c); 154 ngx_http_close_connection(c);
155 return; 155 return;
156 } 156 }
157 #endif 157 #endif
158
159 #if (NGX_STAT_STUB)
160 (*ngx_stat_reading)++;
161 #endif
162
158 } 163 }
159 164
160 165
161 static void ngx_http_init_request(ngx_event_t *rev) 166 static void ngx_http_init_request(ngx_event_t *rev)
162 { 167 {
176 181
177 c = rev->data; 182 c = rev->data;
178 183
179 if (rev->timedout) { 184 if (rev->timedout) {
180 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); 185 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
186
187 #if (NGX_STAT_STUB)
188 (*ngx_stat_reading)--;
189 #endif
190
181 ngx_http_close_connection(c); 191 ngx_http_close_connection(c);
182 return; 192 return;
183 } 193 }
184 194
185 if (c->data) { 195 if (c->data) {
186 r = c->data; 196 r = c->data;
187 ngx_memzero(r, sizeof(ngx_http_request_t)); 197 ngx_memzero(r, sizeof(ngx_http_request_t));
188 198
199 #if (NGX_STAT_STUB)
200 (*ngx_stat_reading)++;
201 #endif
202
189 } else { 203 } else {
190 if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) { 204 if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) {
205
206 #if (NGX_STAT_STUB)
207 (*ngx_stat_reading)--;
208 #endif
209
191 ngx_http_close_connection(c); 210 ngx_http_close_connection(c);
192 return; 211 return;
193 } 212 }
194 213
195 c->data = r; 214 c->data = r;
196 } 215 }
216
217 #if (NGX_STAT_STUB)
218 r->stat_reading = 1;
219 #endif
197 220
198 c->sent = 0; 221 c->sent = 0;
199 r->signature = NGX_HTTP_MODULE; 222 r->signature = NGX_HTTP_MODULE;
200 223
201 /* find the server configuration for the address:port */ 224 /* find the server configuration for the address:port */
867 ngx_del_timer(rev); 890 ngx_del_timer(rev);
868 } 891 }
869 892
870 #if (NGX_STAT_STUB) 893 #if (NGX_STAT_STUB)
871 (*ngx_stat_reading)--; 894 (*ngx_stat_reading)--;
895 r->stat_reading = 0;
872 (*ngx_stat_writing)++; 896 (*ngx_stat_writing)++;
897 r->stat_writing = 1;
873 #endif 898 #endif
874 899
875 rev->event_handler = ngx_http_block_read; 900 rev->event_handler = ngx_http_block_read;
876 ngx_http_handler(r); 901 ngx_http_handler(r);
877 return; 902 return;
1116 /* MSIE ignores the SSL "close notify" alert */ 1141 /* MSIE ignores the SSL "close notify" alert */
1117 1142
1118 ngx_ssl_set_nosendshut(r->connection->ssl); 1143 ngx_ssl_set_nosendshut(r->connection->ssl);
1119 #endif 1144 #endif
1120 } 1145 }
1146
1147 if (ngx_strstr(r->headers_in.user_agent->value.data, "Opera")) {
1148 r->headers_in.opera = 1;
1149 r->headers_in.msie = 0;
1150 r->headers_in.msie4 = 0;
1151 }
1121 } 1152 }
1122 1153
1123 return NGX_OK; 1154 return NGX_OK;
1124 } 1155 }
1125 1156
1146 if (r->connection->write->timer_set) { 1177 if (r->connection->write->timer_set) {
1147 ngx_del_timer(r->connection->write); 1178 ngx_del_timer(r->connection->write);
1148 } 1179 }
1149 1180
1150 if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) { 1181 if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) {
1151
1152 #if (NGX_STAT_STUB)
1153 (*ngx_stat_writing)--;
1154 #endif
1155
1156 ngx_http_close_request(r, 0); 1182 ngx_http_close_request(r, 0);
1157 ngx_http_close_connection(r->connection); 1183 ngx_http_close_connection(r->connection);
1158 return; 1184 return;
1159 } 1185 }
1160 1186
1161 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc)); 1187 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
1162 1188
1163 return; 1189 return;
1164 1190
1165 } else if (rc == NGX_ERROR) { 1191 } else if (rc == NGX_ERROR) {
1166
1167 #if (NGX_STAT_STUB)
1168 (*ngx_stat_writing)--;
1169 #endif
1170
1171 ngx_http_close_request(r, 0); 1192 ngx_http_close_request(r, 0);
1172 ngx_http_close_connection(r->connection); 1193 ngx_http_close_connection(r->connection);
1173 return; 1194 return;
1174 1195
1175 } else if (rc == NGX_AGAIN) { 1196 } else if (rc == NGX_AGAIN) {
1176 ngx_http_set_write_handler(r); 1197 ngx_http_set_write_handler(r);
1177 return; 1198 return;
1178 } 1199 }
1179
1180 #if (NGX_STAT_STUB)
1181 (*ngx_stat_writing)--;
1182 #endif
1183 1200
1184 if (r->connection->read->timer_set) { 1201 if (r->connection->read->timer_set) {
1185 ngx_del_timer(r->connection->read); 1202 ngx_del_timer(r->connection->read);
1186 } 1203 }
1187 1204
1797 if (r->pool == NULL) { 1814 if (r->pool == NULL) {
1798 ngx_log_error(NGX_LOG_ALERT, log, 0, 1815 ngx_log_error(NGX_LOG_ALERT, log, 0,
1799 "http request already closed"); 1816 "http request already closed");
1800 return; 1817 return;
1801 } 1818 }
1819
1820 #if (NGX_STAT_STUB)
1821 if (r->stat_reading) {
1822 (*ngx_stat_reading)--;
1823 }
1824
1825 if (r->stat_writing) {
1826 (*ngx_stat_writing)--;
1827 }
1828 #endif
1802 1829
1803 if (error && r->headers_out.status == 0) { 1830 if (error && r->headers_out.status == 0) {
1804 r->headers_out.status = error; 1831 r->headers_out.status = error;
1805 } 1832 }
1806 1833