Klaus Demo nginx / a14f89c
nginx-0.0.7-2004-07-13-21:59:12 import Igor Sysoev 18 years ago
12 changed file(s) with 98 addition(s) and 44 deletion(s). Raw diff Collapse all Expand all
162162 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \
163163 arg1, arg2, arg3, arg4, arg5, arg6)
164164
165 #define ngx_log_debug7(level, log, err, fmt, \
166 arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
167 if (log->log_level & level) \
168 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \
169 arg1, arg2, arg3, arg4, arg5, arg6, arg7)
170
165171 #else /* NO VARIADIC MACROS */
166172
167173 #define ngx_log_debug0(level, log, err, fmt) \
192198 arg1, arg2, arg3, arg4, arg5, arg6) \
193199 if (log->log_level & level) \
194200 ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
201
202 #define ngx_log_debug7(level, log, err, fmt, \
203 arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
204 if (log->log_level & level) \
205 ngx_log_debug_core(log, err, fmt, \
206 arg1, arg2, arg3, arg4, arg5, arg6, arg7)
195207
196208 #endif
197209
204216 #define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4)
205217 #define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)
206218 #define ngx_log_debug6(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
219 #define ngx_log_debug7(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6,
220 arg7)
207221
208222 #endif
209223
404404 ngx_time_update(tv.tv_sec);
405405
406406 delta = ngx_elapsed_msec;
407 ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
407 ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
408 + tv.tv_usec / 1000 - ngx_start_msec;
408409
409410 if (err) {
410411 ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
458458 ngx_time_update(tv.tv_sec);
459459
460460 delta = ngx_elapsed_msec;
461 ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
461 ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
462 + tv.tv_usec / 1000 - ngx_start_msec;
462463
463464 if (timer != NGX_TIMER_INFINITE) {
464465 delta = ngx_elapsed_msec - delta;
197197 "iocp: %d b:%d k:%d ov:" PTR_FMT, rc, bytes, key, ovlp);
198198
199199 delta = ngx_elapsed_msec;
200 ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
200 ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
201 + tv.tv_usec / 1000 - ngx_start_msec;
201202
202203 if (err) {
203204 if (ovlp == NULL) {
526526 ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
527527 + tv.tv_usec / 1000 - ngx_start_msec;
528528
529 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
530 "elapsed: %qd", ngx_elapsed_msec);
531
532529 if (err) {
533530 ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
534531 cycle->log, err, "kevent() failed");
340340 ngx_time_update(tv.tv_sec);
341341
342342 delta = ngx_elapsed_msec;
343 ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
343 ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
344 + tv.tv_usec / 1000 - ngx_start_msec;
344345
345346 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
346347 "poll ready %d of %d", ready, nevents);
388388 ngx_time_update(tv.tv_sec);
389389
390390 delta = ngx_elapsed_msec;
391 ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
391 ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
392 + tv.tv_usec / 1000 - ngx_start_msec;
392393
393394 if (err) {
394395 ngx_accept_mutex_unlock();
377377 ngx_time_update(tv.tv_sec);
378378 deltas = tv.tv_usec / 1000;
379379
380 ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000
381 - ngx_start_msec;
380 ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
381 + tv.tv_usec / 1000 - ngx_start_msec;
382382 } else {
383383 ngx_elapsed_msec += delta;
384384 }
391391 ngx_gettimeofday(&tv);
392392 ngx_time_update(tv.tv_sec);
393393
394 ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000
395 - ngx_start_msec;
394 ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
395 + tv.tv_usec / 1000 - ngx_start_msec;
396
396397 if (ready == 0) {
397398 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
398399 "select() returned no events without timeout");
147147 }
148148 #endif
149149
150 if (r->headers_out.content_type == NULL
151 || ngx_strncasecmp(r->headers_out.content_type->value.data,
150 if (r->headers_out.content_type == NULL) {
151 return ngx_http_next_header_filter(r);
152 }
153
154 if (ngx_strncasecmp(r->headers_out.content_type->value.data,
152155 "text/", 5) != 0
153 || ngx_strstr(r->headers_out.content_type->value.data, "charset")
154 != NULL
155 )
156 && ngx_strncasecmp(r->headers_out.content_type->value.data,
157 "application/x-javascript", 24) != 0)
158 {
159 return ngx_http_next_header_filter(r);
160 }
161
162 if (ngx_strstr(r->headers_out.content_type->value.data, "charset") != NULL)
156163 {
157164 return ngx_http_next_header_filter(r);
158165 }
124124 cc->value.data = (u_char *) "no-cache";
125125
126126 } else {
127 cc->value.data = ngx_palloc(r->pool, TIME_T_LEN + 1);
127 cc->value.data = ngx_palloc(r->pool,
128 sizeof("max-age=") + TIME_T_LEN + 1);
128129 if (cc->value.data == NULL) {
129130 return NGX_ERROR;
130131 }
1919 ngx_pid_t pid;
2020 ngx_int_t s;
2121
22 s = respawn >= 0 ? respawn : ngx_last_process;
22 if (respawn >= 0) {
23 s = respawn;
24
25 } else {
26 for (s = 0; s < ngx_last_process; s++) {
27 if (ngx_processes[s].pid == -1) {
28 break;
29 }
30 }
31
32 if (s == NGX_MAX_PROCESSES) {
33 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
34 "no more than %d processes can be spawned",
35 NGX_MAX_PROCESSES);
36 return NGX_ERROR;
37 }
38 }
2339
2440
2541 if (respawn != NGX_PROCESS_DETACHED) {
145161 break;
146162 }
147163
148 ngx_last_process++;
164 if (s == ngx_last_process) {
165 ngx_last_process++;
166 }
149167
150168 return pid;
151169 }
219237
220238
221239 one = 1;
222 process = "";
240 process = "unknown process";
223241
224242 for (i = 0; i < ngx_last_process; i++) {
225243 if (ngx_processes[i].pid == pid) {
230248 }
231249 }
232250
233 if (i == ngx_last_process) {
234 process = "unknown process";
235 }
236
237251 if (WTERMSIG(status)) {
238252 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
239253 "%s " PID_T_FMT " exited on signal %d%s",
305305 ch.slot = ngx_process_slot;
306306 ch.fd = ngx_processes[ngx_process_slot].channel[0];
307307
308 for (i = 0; i < ngx_last_process - 1; i++) {
309
310 ngx_log_debug4(NGX_LOG_DEBUG_CORE, cycle->log, 0,
311 "pass channel s: %d pid:" PID_T_FMT " fd:%d to:"
312 PID_T_FMT, ch.slot, ch.pid, ch.fd, ngx_processes[i].pid);
308 for (i = 0; i < ngx_last_process; i++) {
309
310 if (i == ngx_process_slot || ngx_processes[i].pid == -1) {
311 continue;
312 }
313
314 ngx_log_debug5(NGX_LOG_DEBUG_CORE, cycle->log, 0,
315 "pass channel s:%d pid:" PID_T_FMT
316 " fd:%d to s:%d pid:" PID_T_FMT,
317 ch.slot, ch.pid, ch.fd,
318 i, ngx_processes[i].pid);
313319
314320 /* TODO: NGX_AGAIN */
315321
366372
367373 for (i = 0; i < ngx_last_process; i++) {
368374
369 if (ngx_processes[i].detached) {
375 if (ngx_processes[i].detached || ngx_processes[i].pid == -1) {
370376 continue;
371377 }
372378
431437 live = 0;
432438 for (i = 0; i < ngx_last_process; i++) {
433439
434 ngx_log_debug6(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
435 "child: " PID_T_FMT " e:%d t:%d d:%d r:%d j:%d",
440 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
441 "child: %d " PID_T_FMT " e:%d t:%d d:%d r:%d j:%d",
442 i,
436443 ngx_processes[i].pid,
437444 ngx_processes[i].exiting,
438445 ngx_processes[i].exited,
440447 ngx_processes[i].respawn,
441448 ngx_processes[i].just_respawn);
442449
450 if (ngx_processes[i].pid == -1) {
451 continue;
452 }
453
443454 if (ngx_processes[i].exited) {
444455
445456 if (!ngx_processes[i].detached) {
453464
454465 for (n = 0; n < ngx_last_process; n++) {
455466 if (ngx_processes[n].exited
467 || ngx_processes[n].pid == -1
456468 || ngx_processes[n].channel[0] == -1)
457469 {
458470 continue;
459471 }
460472
461473 ngx_log_debug3(NGX_LOG_DEBUG_CORE, cycle->log, 0,
462 "pass close channel s: %d pid:" PID_T_FMT
474 "pass close channel s:%d pid:" PID_T_FMT
463475 " to:" PID_T_FMT, ch.slot, ch.pid, ngx_processes[n].pid);
464476
465477 /* TODO: NGX_AGAIN */
497509 }
498510 }
499511
500 if (i != --ngx_last_process) {
501 ngx_processes[i--] = ngx_processes[ngx_last_process];
512 if (i == ngx_last_process - 1) {
513 ngx_last_process--;
514
515 } else {
516 ngx_processes[i].pid = -1;
502517 }
503518
504519 } else if (ngx_processes[i].exiting || !ngx_processes[i].detached) {
592607 }
593608 }
594609
595 for (n = 0; n <= ngx_last_process; n++) {
596
597 if (n == ngx_process_slot) {
598 if (close(ngx_processes[n].channel[0]) == -1) {
599 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
600 "close() failed");
601 }
602
610 for (n = 0; n < ngx_last_process; n++) {
611
612 if (ngx_processes[n].pid == -1) {
603613 continue;
604614 }
605615
607617 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
608618 "close() failed");
609619 }
620 }
621
622 if (close(ngx_processes[ngx_process_slot].channel[0]) == -1) {
623 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
624 "close() failed");
610625 }
611626
612627 #if 0