Klaus Demo nginx / dc3b2a7
nginx-0.0.10-2004-09-14-23:39:54 import Igor Sysoev 17 years ago
9 changed file(s) with 108 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
222222 #define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4)
223223 #define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)
224224 #define ngx_log_debug6(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
225 #define ngx_log_debug7(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6,
226 arg7)
225 #define ngx_log_debug7(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, \
226 arg6, arg7)
227227
228228 #endif
229229
8585 }
8686 }
8787
88 /* alloc a new pool block */
88 /* allocate a new pool block */
8989
9090 if (!(n = ngx_create_pool((size_t) (p->end - (char *) p), p->log))) {
9191 return NULL;
9898 return m;
9999 }
100100
101 /* alloc a large block */
101 /* allocate a large block */
102102
103103 large = NULL;
104104 last = NULL;
6161 ngx_uint_t ngx_accept_mutex_held;
6262 ngx_msec_t ngx_accept_mutex_delay;
6363 ngx_int_t ngx_accept_disabled;
64
65
66 #if (NGX_STAT_STUB)
67
68 ngx_atomic_t ngx_stat_accepted0;
69 ngx_atomic_t *ngx_stat_accepted = &ngx_stat_accepted0;
70 ngx_atomic_t ngx_stat_requests0;
71 ngx_atomic_t *ngx_stat_requests = &ngx_stat_requests0;
72 ngx_atomic_t ngx_stat_active0;
73 ngx_atomic_t *ngx_stat_active = &ngx_stat_active0;
74 ngx_atomic_t ngx_stat_reading0;
75 ngx_atomic_t *ngx_stat_reading = &ngx_stat_reading0;
76 ngx_atomic_t ngx_stat_writing0;
77 ngx_atomic_t *ngx_stat_writing = &ngx_stat_reading0;
78
79 #endif
6480
6581
6682
186202 size = 128 /* ngx_accept_mutex */
187203 + 128; /* ngx_connection_counter */
188204
205 #if (NGX_STAT_STUB)
206
207 size += 128 /* ngx_stat_accepted */
208 + 128 /* ngx_stat_requests */
209 + 128 /* ngx_stat_active */
210 + 128 /* ngx_stat_reading */
211 + 128; /* ngx_stat_writing */
212
213 #endif
214
189215 if (!(shared = ngx_create_shared_memory(size, cycle->log))) {
190216 return NGX_ERROR;
191217 }
192218
193219 ngx_accept_mutex_ptr = (ngx_atomic_t *) shared;
194220 ngx_connection_counter = (ngx_atomic_t *) (shared + 128);
221
222 #if (NGX_STAT_STUB)
223
224 ngx_stat_accepted = (ngx_atomic_t *) (shared + 2 * 128);
225 ngx_stat_requests = (ngx_atomic_t *) (shared + 3 * 128);
226 ngx_stat_active = (ngx_atomic_t *) (shared + 4 * 128);
227 ngx_stat_reading = (ngx_atomic_t *) (shared + 5 * 128);
228 ngx_stat_writing = (ngx_atomic_t *) (shared + 6 * 128);
229
230 #endif
195231
196232 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
197233 "counter: " PTR_FMT ", %d",
432432 extern ngx_int_t ngx_accept_disabled;
433433
434434
435 #if (NGX_STAT_STUB)
436
437 extern ngx_atomic_t *ngx_stat_accepted;
438 extern ngx_atomic_t *ngx_stat_requests;
439 extern ngx_atomic_t *ngx_stat_active;
440 extern ngx_atomic_t *ngx_stat_reading;
441 extern ngx_atomic_t *ngx_stat_writing;
442
443 #endif
444
445
446
435447 #define ngx_accept_mutex_unlock() \
436448 if (ngx_accept_mutex_held) { \
437449 *ngx_accept_mutex = 0; \
126126 return;
127127 }
128128
129 #if (NGX_STAT_STUB)
130 (*ngx_stat_accepted)++;
131 (*ngx_stat_active)++;
132 #endif
129133
130134 ngx_accept_disabled = (ngx_uint_t) s + NGX_ACCEPT_THRESHOLD
131135 - ecf->connections;
11771177 ngx_http_type_t *type;
11781178
11791179 if (lcf->types == NULL) {
1180 ngx_test_null(lcf->types,
1181 ngx_palloc(cf->pool, NGX_HTTP_TYPES_HASH_PRIME
1182 * sizeof(ngx_array_t)),
1183 NGX_CONF_ERROR);
1180 lcf->types = ngx_palloc(cf->pool, NGX_HTTP_TYPES_HASH_PRIME
1181 * sizeof(ngx_array_t));
1182 if (lcf->types == NULL) {
1183 return NGX_CONF_ERROR;
1184 }
11841185
11851186 for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) {
1186 ngx_init_array(lcf->types[i], cf->pool, 5, sizeof(ngx_http_type_t),
1187 NGX_CONF_ERROR);
1187 if (ngx_array_init(&lcf->types[i], cf->pool, 5,
1188 sizeof(ngx_http_type_t)) == NGX_ERROR)
1189 {
1190 return NGX_CONF_ERROR;
1191 }
11881192 }
11891193 }
11901194
11931197 for (i = 1; i < cf->args->nelts; i++) {
11941198 ngx_http_types_hash_key(key, args[i]);
11951199
1196 ngx_test_null(type, ngx_push_array(&lcf->types[key]), NGX_CONF_ERROR);
1200 if (!(type = ngx_array_push(&lcf->types[key]))) {
1201 return NGX_CONF_ERROR;
1202 }
1203
11971204 type->exten = args[i];
11981205 type->type = args[0];
11991206 }
9595 {
9696 ngx_event_t *rev;
9797 ngx_http_log_ctx_t *ctx;
98
99 #if (NGX_STAT_STUB)
100 (*ngx_stat_reading)++;
101 #endif
98102
99103 if (!(ctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) {
100104 ngx_http_close_connection(c);
312316 return;
313317 }
314318
315 r->cleanup.elts = ngx_palloc(r->pool, 5 * sizeof(ngx_http_cleanup_t));
316 if (r->cleanup.elts == NULL) {
319 if (ngx_array_init(&r->cleanup, r->pool, 5, sizeof(ngx_http_cleanup_t))
320 == NGX_ERROR)
321 {
317322 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
318323 ngx_http_close_connection(c);
319324 return;
320325 }
321
322 /*
323 * set by ngx_pcalloc():
324 *
325 * r->cleanup.nelts = 0;
326 */
327 r->cleanup.nalloc = 5;
328 r->cleanup.size = sizeof(ngx_http_cleanup_t);
329 r->cleanup.pool = r->pool;
330326
331327
332328 if (ngx_list_init(&r->headers_out.headers, r->pool, 20,
358354 r->headers_out.last_modified_time = -1;
359355
360356 r->http_state = NGX_HTTP_READING_REQUEST_STATE;
357
358 #if (NGX_STAT_STUB)
359 (*ngx_stat_requests)++;
360 #endif
361361
362362 rev->event_handler(rev);
363363 }
865865 if (rev->timer_set) {
866866 ngx_del_timer(rev);
867867 }
868
869 #if (NGX_STAT_STUB)
870 (*ngx_stat_reading)--;
871 (*ngx_stat_writing)++;
872 #endif
868873
869874 rev->event_handler = ngx_http_block_read;
870875 ngx_http_handler(r);
11421147 }
11431148
11441149 if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) {
1150
1151 #if (NGX_STAT_STUB)
1152 (*ngx_stat_writing)--;
1153 #endif
1154
11451155 ngx_http_close_request(r, 0);
11461156 ngx_http_close_connection(r->connection);
11471157 return;
11521162 return;
11531163
11541164 } else if (rc == NGX_ERROR) {
1165
1166 #if (NGX_STAT_STUB)
1167 (*ngx_stat_writing)--;
1168 #endif
1169
11551170 ngx_http_close_request(r, 0);
11561171 ngx_http_close_connection(r->connection);
11571172 return;
11601175 ngx_http_set_write_handler(r);
11611176 return;
11621177 }
1178
1179 #if (NGX_STAT_STUB)
1180 (*ngx_stat_writing)--;
1181 #endif
11631182
11641183 if (r->connection->read->timer_set) {
11651184 ngx_del_timer(r->connection->read);
18861905 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
18871906 "close http connection: %d", c->fd);
18881907
1908 #if (NGX_STAT_STUB)
1909 (*ngx_stat_active)--;
1910 #endif
1911
18891912 ngx_close_connection(c);
18901913 }
18911914
145145 size_t connection_type;
146146 ssize_t keep_alive_n;
147147
148 unsigned msie;
149 unsigned msie4;
148 unsigned msie:1;
149 unsigned msie4:1;
150150 } ngx_http_headers_in_t;
151151
152152
4343 #if 0
4444 peers->peers[0].addr = inet_addr("81.19.69.70");
4545 peers->peers[0].addr_port_text.len = sizeof("81.19.69.70:110") - 1;
46 peers->peers[0].addr_port_text.data = "81.19.69.70:110";
46 peers->peers[0].addr_port_text.data = (u_char *) "81.19.69.70:110";
4747 peers->peers[0].port = htons(110);
4848 #else
4949 peers->peers[0].addr = inet_addr("81.19.64.101");
5050 peers->peers[0].addr_port_text.len = sizeof("81.19.64.101:110") - 1;
51 peers->peers[0].addr_port_text.data = "81.19.64.101:110";
51 peers->peers[0].addr_port_text.data = (u_char *) "81.19.64.101:110";
5252 peers->peers[0].port = htons(110);
5353 #endif
5454