comparison src/event/ngx_event_posted.c @ 306:6b91bfbc4123

nginx-0.0.3-2004-04-05-00:32:09 import
author Igor Sysoev <igor@sysoev.ru>
date Sun, 04 Apr 2004 20:32:09 +0000
parents
children 98f1a8028067
comparison
equal deleted inserted replaced
305:4b1a3a4acc60 306:6b91bfbc4123
1
2 #include <ngx_config.h>
3 #include <ngx_core.h>
4 #include <ngx_event.h>
5
6
7 ngx_thread_volatile ngx_event_t *ngx_posted_events;
8 #if (NGX_THREADS)
9 ngx_mutex_t *ngx_posted_events_mutex;
10 #endif
11
12
13 void ngx_event_process_posted(ngx_cycle_t *cycle)
14 {
15 ngx_event_t *ev;
16
17 for ( ;; ) {
18
19 ev = (ngx_event_t *) ngx_posted_events;
20
21 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
22 "posted event " PTR_FMT, ev);
23
24 if (ev == NULL) {
25 return;
26 }
27
28 ngx_posted_events = ev->next;
29
30 if ((!ev->posted && !ev->active)
31 || (ev->use_instance && ev->instance != ev->returned_instance))
32 {
33 /*
34 * the stale event from a file descriptor
35 * that was just closed in this iteration
36 */
37
38 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
39 "stale posted event " PTR_FMT, ev);
40 continue;
41 }
42
43 if (ev->posted) {
44 ev->posted = 0;
45 }
46
47 ev->event_handler(ev);
48 }
49 }
50
51
52 #if (NGX_THREADS)
53
54 void ngx_event_thread_handler(ngx_event_t *ev)
55 {
56 if ((!ev->posted && !ev->active)
57 || (ev->use_instance && ev->instance != ev->returned_instance))
58 {
59 /*
60 * the stale event from a file descriptor
61 * that was just closed in this iteration
62 */
63
64 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0,
65 "kevent: stale event " PTR_FMT, ev);
66 return;
67 }
68
69 if (ev->posted) {
70 ev->posted = 0;
71 }
72
73 ev->event_handler(ev);
74 }
75
76 #endif