Mercurial > hg > nginx-quic
annotate src/event/modules/ngx_kqueue_module.c @ 6132:859ce1c41f64
Win32: fixed shm.handle loss on reload.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 27 Apr 2015 03:44:30 +0300 |
parents | 4652f8f26b12 |
children | dc92298b1852 |
rev | line source |
---|---|
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
1 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
5 */ |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
7
b5481d6fbbd4
nginx-0.0.1-2002-08-29-20:59:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
6
diff
changeset
|
9 #include <ngx_core.h> |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_event.h> |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
102
7e86d028d8f0
nginx-0.0.1-2003-06-06-18:59:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
13 typedef struct { |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
14 ngx_uint_t changes; |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
15 ngx_uint_t events; |
102
7e86d028d8f0
nginx-0.0.1-2003-06-06-18:59:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
16 } ngx_kqueue_conf_t; |
7e86d028d8f0
nginx-0.0.1-2003-06-06-18:59:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
17 |
7e86d028d8f0
nginx-0.0.1-2003-06-06-18:59:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
18 |
563 | 19 static ngx_int_t ngx_kqueue_init(ngx_cycle_t *cycle, ngx_msec_t timer); |
6020
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
20 #ifdef EVFILT_USER |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
21 static ngx_int_t ngx_kqueue_notify_init(ngx_log_t *log); |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
22 #endif |
113
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
112
diff
changeset
|
23 static void ngx_kqueue_done(ngx_cycle_t *cycle); |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
24 static ngx_int_t ngx_kqueue_add_event(ngx_event_t *ev, ngx_int_t event, |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
25 ngx_uint_t flags); |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
26 static ngx_int_t ngx_kqueue_del_event(ngx_event_t *ev, ngx_int_t event, |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
27 ngx_uint_t flags); |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
28 static ngx_int_t ngx_kqueue_set_event(ngx_event_t *ev, ngx_int_t filter, |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
29 ngx_uint_t flags); |
6020
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
30 #ifdef EVFILT_USER |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
31 static ngx_int_t ngx_kqueue_notify(ngx_event_handler_pt handler); |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
32 #endif |
563 | 33 static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, |
34 ngx_uint_t flags); | |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
35 static ngx_inline void ngx_kqueue_dump_event(ngx_log_t *log, |
499 | 36 struct kevent *kev); |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
37 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
38 static void *ngx_kqueue_create_conf(ngx_cycle_t *cycle); |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
39 static char *ngx_kqueue_init_conf(ngx_cycle_t *cycle, void *conf); |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
40 |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
41 |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
42 int ngx_kqueue = -1; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 |
6030
4652f8f26b12
Removed unix ngx_threaded and related ngx_process_changes.
Ruslan Ermilov <ru@nginx.com>
parents:
6029
diff
changeset
|
44 static struct kevent *change_list; |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
45 static struct kevent *event_list; |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
46 static ngx_uint_t max_changes, nchanges, nevents; |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
47 |
6020
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
48 #ifdef EVFILT_USER |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
49 static ngx_event_t notify_event; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
50 static struct kevent notify_kev; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
51 #endif |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
52 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
53 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
54 static ngx_str_t kqueue_name = ngx_string("kqueue"); |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
55 |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
56 static ngx_command_t ngx_kqueue_commands[] = { |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
57 |
499 | 58 { ngx_string("kqueue_changes"), |
59 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
60 ngx_conf_set_num_slot, | |
61 0, | |
62 offsetof(ngx_kqueue_conf_t, changes), | |
63 NULL }, | |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
64 |
499 | 65 { ngx_string("kqueue_events"), |
66 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
67 ngx_conf_set_num_slot, | |
68 0, | |
69 offsetof(ngx_kqueue_conf_t, events), | |
70 NULL }, | |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
71 |
499 | 72 ngx_null_command |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
73 }; |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
74 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
75 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
76 ngx_event_module_t ngx_kqueue_module_ctx = { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
77 &kqueue_name, |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
78 ngx_kqueue_create_conf, /* create configuration */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
79 ngx_kqueue_init_conf, /* init configuration */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
80 |
95
b48066122884
nginx-0.0.1-2003-05-23-15:53:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
81 { |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
82 ngx_kqueue_add_event, /* add an event */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
83 ngx_kqueue_del_event, /* delete an event */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
84 ngx_kqueue_add_event, /* enable an event */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
85 ngx_kqueue_del_event, /* disable an event */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
86 NULL, /* add an connection */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
87 NULL, /* delete an connection */ |
6020
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
88 #ifdef EVFILT_USER |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
89 ngx_kqueue_notify, /* trigger a notify */ |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
90 #else |
6018
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
91 NULL, /* trigger a notify */ |
6020
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
92 #endif |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
93 ngx_kqueue_process_events, /* process the events */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
94 ngx_kqueue_init, /* init the events */ |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
95 ngx_kqueue_done /* done the events */ |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
96 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
97 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
98 }; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
99 |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
100 ngx_module_t ngx_kqueue_module = { |
509 | 101 NGX_MODULE_V1, |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
102 &ngx_kqueue_module_ctx, /* module context */ |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
103 ngx_kqueue_commands, /* module directives */ |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
104 NGX_EVENT_MODULE, /* module type */ |
541 | 105 NULL, /* init master */ |
112
da763a85be66
nginx-0.0.1-2003-07-04-10:03:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
111
diff
changeset
|
106 NULL, /* init module */ |
541 | 107 NULL, /* init process */ |
108 NULL, /* init thread */ | |
109 NULL, /* exit thread */ | |
110 NULL, /* exit process */ | |
111 NULL, /* exit master */ | |
112 NGX_MODULE_V1_PADDING | |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
113 }; |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
114 |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
87
diff
changeset
|
115 |
499 | 116 static ngx_int_t |
563 | 117 ngx_kqueue_init(ngx_cycle_t *cycle, ngx_msec_t timer) |
111
1c002f2b77ed
nginx-0.0.1-2003-07-03-20:30:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
105
diff
changeset
|
118 { |
565 | 119 ngx_kqueue_conf_t *kcf; |
111
1c002f2b77ed
nginx-0.0.1-2003-07-03-20:30:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
105
diff
changeset
|
120 struct timespec ts; |
565 | 121 #if (NGX_HAVE_TIMER_EVENT) |
122 struct kevent kev; | |
123 #endif | |
111
1c002f2b77ed
nginx-0.0.1-2003-07-03-20:30:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
105
diff
changeset
|
124 |
1c002f2b77ed
nginx-0.0.1-2003-07-03-20:30:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
105
diff
changeset
|
125 kcf = ngx_event_get_conf(cycle->conf_ctx, ngx_kqueue_module); |
1c002f2b77ed
nginx-0.0.1-2003-07-03-20:30:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
105
diff
changeset
|
126 |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
127 if (ngx_kqueue == -1) { |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
128 ngx_kqueue = kqueue(); |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
129 |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
130 if (ngx_kqueue == -1) { |
113
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
112
diff
changeset
|
131 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
112
diff
changeset
|
132 "kqueue() failed"); |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
133 return NGX_ERROR; |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
134 } |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
135 |
6020
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
136 #ifdef EVFILT_USER |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
137 if (ngx_kqueue_notify_init(cycle->log) != NGX_OK) { |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
138 return NGX_ERROR; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
139 } |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
140 #endif |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
141 } |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
142 |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
143 if (max_changes < kcf->changes) { |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
144 if (nchanges) { |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
145 ts.tv_sec = 0; |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
146 ts.tv_nsec = 0; |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
147 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
148 if (kevent(ngx_kqueue, change_list, (int) nchanges, NULL, 0, &ts) |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
149 == -1) |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
150 { |
113
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
112
diff
changeset
|
151 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
112
diff
changeset
|
152 "kevent() failed"); |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
153 return NGX_ERROR; |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
154 } |
113
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
112
diff
changeset
|
155 nchanges = 0; |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
156 } |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
157 |
6030
4652f8f26b12
Removed unix ngx_threaded and related ngx_process_changes.
Ruslan Ermilov <ru@nginx.com>
parents:
6029
diff
changeset
|
158 if (change_list) { |
4652f8f26b12
Removed unix ngx_threaded and related ngx_process_changes.
Ruslan Ermilov <ru@nginx.com>
parents:
6029
diff
changeset
|
159 ngx_free(change_list); |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
160 } |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
161 |
6030
4652f8f26b12
Removed unix ngx_threaded and related ngx_process_changes.
Ruslan Ermilov <ru@nginx.com>
parents:
6029
diff
changeset
|
162 change_list = ngx_alloc(kcf->changes * sizeof(struct kevent), |
4652f8f26b12
Removed unix ngx_threaded and related ngx_process_changes.
Ruslan Ermilov <ru@nginx.com>
parents:
6029
diff
changeset
|
163 cycle->log); |
4652f8f26b12
Removed unix ngx_threaded and related ngx_process_changes.
Ruslan Ermilov <ru@nginx.com>
parents:
6029
diff
changeset
|
164 if (change_list == NULL) { |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
165 return NGX_ERROR; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
166 } |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
167 } |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
168 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
169 max_changes = kcf->changes; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
170 |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
171 if (nevents < kcf->events) { |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
172 if (event_list) { |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
173 ngx_free(event_list); |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
174 } |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
175 |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
176 event_list = ngx_alloc(kcf->events * sizeof(struct kevent), cycle->log); |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
177 if (event_list == NULL) { |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
178 return NGX_ERROR; |
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
179 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
180 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
181 |
1451
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
182 ngx_event_flags = NGX_USE_ONESHOT_EVENT |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
183 |NGX_USE_KQUEUE_EVENT |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
184 |NGX_USE_VNODE_EVENT; |
563 | 185 |
186 #if (NGX_HAVE_TIMER_EVENT) | |
187 | |
188 if (timer) { | |
189 kev.ident = 0; | |
190 kev.filter = EVFILT_TIMER; | |
191 kev.flags = EV_ADD|EV_ENABLE; | |
192 kev.fflags = 0; | |
193 kev.data = timer; | |
194 kev.udata = 0; | |
195 | |
196 ts.tv_sec = 0; | |
197 ts.tv_nsec = 0; | |
198 | |
199 if (kevent(ngx_kqueue, &kev, 1, NULL, 0, &ts) == -1) { | |
200 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
201 "kevent(EVFILT_TIMER) failed"); | |
202 return NGX_ERROR; | |
203 } | |
204 | |
205 ngx_event_flags |= NGX_USE_TIMER_EVENT; | |
206 } | |
207 | |
208 #endif | |
209 | |
210 #if (NGX_HAVE_CLEAR_EVENT) | |
211 ngx_event_flags |= NGX_USE_CLEAR_EVENT; | |
212 #else | |
213 ngx_event_flags |= NGX_USE_LEVEL_EVENT; | |
214 #endif | |
215 | |
216 #if (NGX_HAVE_LOWAT_EVENT) | |
217 ngx_event_flags |= NGX_USE_LOWAT_EVENT; | |
218 #endif | |
219 | |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
220 nevents = kcf->events; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 |
113
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
112
diff
changeset
|
222 ngx_io = ngx_os_io; |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
223 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
224 ngx_event_actions = ngx_kqueue_module_ctx.actions; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
225 |
17
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
14
diff
changeset
|
226 return NGX_OK; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
228 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
229 |
6020
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
230 #ifdef EVFILT_USER |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
231 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
232 static ngx_int_t |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
233 ngx_kqueue_notify_init(ngx_log_t *log) |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
234 { |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
235 notify_kev.ident = 0; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
236 notify_kev.filter = EVFILT_USER; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
237 notify_kev.data = 0; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
238 notify_kev.flags = EV_ADD|EV_CLEAR; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
239 notify_kev.fflags = 0; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
240 notify_kev.udata = 0; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
241 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
242 if (kevent(ngx_kqueue, ¬ify_kev, 1, NULL, 0, NULL) == -1) { |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
243 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
244 "kevent(EVFILT_USER, EV_ADD) failed"); |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
245 return NGX_ERROR; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
246 } |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
247 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
248 notify_event.active = 1; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
249 notify_event.log = log; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
250 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
251 notify_kev.flags = 0; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
252 notify_kev.fflags = NOTE_TRIGGER; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
253 notify_kev.udata = NGX_KQUEUE_UDATA_T ((uintptr_t) ¬ify_event); |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
254 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
255 return NGX_OK; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
256 } |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
257 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
258 #endif |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
259 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
260 |
499 | 261 static void |
262 ngx_kqueue_done(ngx_cycle_t *cycle) | |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
263 { |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
264 if (close(ngx_kqueue) == -1) { |
113
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
112
diff
changeset
|
265 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
112
diff
changeset
|
266 "kqueue close() failed"); |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
267 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
268 |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
269 ngx_kqueue = -1; |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
270 |
6030
4652f8f26b12
Removed unix ngx_threaded and related ngx_process_changes.
Ruslan Ermilov <ru@nginx.com>
parents:
6029
diff
changeset
|
271 ngx_free(change_list); |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
272 ngx_free(event_list); |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
273 |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
274 change_list = NULL; |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
275 event_list = NULL; |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
276 max_changes = 0; |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
277 nchanges = 0; |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
278 nevents = 0; |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
279 } |
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
280 |
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
281 |
499 | 282 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
283 ngx_kqueue_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
284 { |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
285 ngx_int_t rc; |
583 | 286 #if 0 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
287 ngx_event_t *e; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
288 ngx_connection_t *c; |
583 | 289 #endif |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
290 |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
291 ev->active = 1; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
292 ev->disabled = 0; |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
293 ev->oneshot = (flags & NGX_ONESHOT_EVENT) ? 1 : 0; |
11
f323b4f74e4a
nginx-0.0.1-2002-09-12-18:42:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
8
diff
changeset
|
294 |
583 | 295 #if 0 |
455 | 296 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
297 if (ev->index < nchanges |
194
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
189
diff
changeset
|
298 && ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1) |
583 | 299 == (uintptr_t) ev) |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
32
diff
changeset
|
300 { |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
301 if (change_list[ev->index].flags == EV_DISABLE) { |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
302 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
303 /* |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
304 * if the EV_DISABLE is still not passed to a kernel |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
305 * we will not pass it |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
306 */ |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
307 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
308 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
309 "kevent activated: %d: ft:%i", |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
310 ngx_event_ident(ev->data), event); |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
311 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
312 if (ev->index < --nchanges) { |
455 | 313 e = (ngx_event_t *) |
314 ((uintptr_t) change_list[nchanges].udata & (uintptr_t) ~1); | |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
315 change_list[ev->index] = change_list[nchanges]; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
316 e->index = ev->index; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
317 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
318 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
319 return NGX_OK; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
320 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
321 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
322 c = ev->data; |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
323 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
324 ngx_log_error(NGX_LOG_ALERT, ev->log, 0, |
161
88abd07d9f62
nginx-0.0.1-2003-10-27-19:16:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
325 "previous event on #%d were not passed in kernel", c->fd); |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
326 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
327 return NGX_ERROR; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
32
diff
changeset
|
328 } |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
32
diff
changeset
|
329 |
455 | 330 #endif |
331 | |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
332 rc = ngx_kqueue_set_event(ev, event, EV_ADD|EV_ENABLE|flags); |
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
333 |
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
334 return rc; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
335 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
336 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
337 |
499 | 338 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
339 ngx_kqueue_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
340 { |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
341 ngx_int_t rc; |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
342 ngx_event_t *e; |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
343 |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
344 ev->active = 0; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
345 ev->disabled = 0; |
374
213f17e9f776
nginx-0.0.7-2004-07-02-09:47:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
346 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
347 if (ev->index < nchanges |
194
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
189
diff
changeset
|
348 && ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1) |
583 | 349 == (uintptr_t) ev) |
32
d45effe5854c
nginx-0.0.1-2002-12-19-10:08:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
350 { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
351 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
352 "kevent deleted: %d: ft:%i", |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
353 ngx_event_ident(ev->data), event); |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
354 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
355 /* if the event is still not passed to a kernel we will not pass it */ |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
356 |
583 | 357 nchanges--; |
358 | |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
359 if (ev->index < nchanges) { |
455 | 360 e = (ngx_event_t *) |
361 ((uintptr_t) change_list[nchanges].udata & (uintptr_t) ~1); | |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
362 change_list[ev->index] = change_list[nchanges]; |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
363 e->index = ev->index; |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
364 } |
18
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
365 |
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
366 return NGX_OK; |
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
367 } |
72ad26c77d2d
nginx-0.0.1-2002-10-04-21:58:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
17
diff
changeset
|
368 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
369 /* |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
370 * when the file descriptor is closed the kqueue automatically deletes |
4572
67653855682e
Fixed spelling in multiline C comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
371 * its filters so we do not need to delete explicitly the event |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
372 * before the closing the file descriptor. |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
373 */ |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
374 |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
375 if (flags & NGX_CLOSE_EVENT) { |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
376 return NGX_OK; |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
377 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
378 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
379 if (flags & NGX_DISABLE_EVENT) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
380 ev->disabled = 1; |
1451
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
381 |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
382 } else { |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
383 flags |= EV_DELETE; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
384 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
385 |
1451
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
386 rc = ngx_kqueue_set_event(ev, event, flags); |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
387 |
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
388 return rc; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
389 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
390 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
391 |
499 | 392 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
393 ngx_kqueue_set_event(ngx_event_t *ev, ngx_int_t filter, ngx_uint_t flags) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
394 { |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
395 struct kevent *kev; |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
396 struct timespec ts; |
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
397 ngx_connection_t *c; |
32
d45effe5854c
nginx-0.0.1-2002-12-19-10:08:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
398 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
399 c = ev->data; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
400 |
1440
576921748c9a
use ev->log, because ev->data may be connection stub only
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
401 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
402 "kevent set event: %d: ft:%i fl:%04Xi", |
213
f536f91e8e99
nginx-0.0.1-2003-12-19-15:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
403 c->fd, filter, flags); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
404 |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
405 if (nchanges >= max_changes) { |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
406 ngx_log_error(NGX_LOG_WARN, ev->log, 0, |
17
8dd06e2844f5
nginx-0.0.1-2002-09-27-19:05:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
14
diff
changeset
|
407 "kqueue change list is filled up"); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
408 |
32
d45effe5854c
nginx-0.0.1-2002-12-19-10:08:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
409 ts.tv_sec = 0; |
d45effe5854c
nginx-0.0.1-2002-12-19-10:08:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
410 ts.tv_nsec = 0; |
d45effe5854c
nginx-0.0.1-2002-12-19-10:08:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
411 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
412 if (kevent(ngx_kqueue, change_list, (int) nchanges, NULL, 0, &ts) |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
413 == -1) |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
414 { |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
102
diff
changeset
|
415 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, "kevent() failed"); |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
416 return NGX_ERROR; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
417 } |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
418 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
419 nchanges = 0; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
420 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
421 |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
422 kev = &change_list[nchanges]; |
372
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
423 |
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
424 kev->ident = c->fd; |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
425 kev->filter = (short) filter; |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
426 kev->flags = (u_short) flags; |
489 | 427 kev->udata = NGX_KQUEUE_UDATA_T ((uintptr_t) ev | ev->instance); |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
428 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
429 if (filter == EVFILT_VNODE) { |
372
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
430 kev->fflags = NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND |
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
431 |NOTE_ATTRIB|NOTE_RENAME |
196
11fbd0fc041d
nginx-0.0.1-2003-11-26-18:42:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
432 #if (__FreeBSD__ == 4 && __FreeBSD_version >= 430000) \ |
11fbd0fc041d
nginx-0.0.1-2003-11-26-18:42:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
433 || __FreeBSD_version >= 500018 |
372
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
434 |NOTE_REVOKE |
196
11fbd0fc041d
nginx-0.0.1-2003-11-26-18:42:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
435 #endif |
2024 | 436 ; |
372
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
437 kev->data = 0; |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
438 |
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
439 } else { |
455 | 440 #if (NGX_HAVE_LOWAT_EVENT) |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
441 if (flags & NGX_LOWAT_EVENT) { |
372
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
442 kev->fflags = NOTE_LOWAT; |
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
443 kev->data = ev->available; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
444 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
445 } else { |
372
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
446 kev->fflags = 0; |
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
447 kev->data = 0; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
448 } |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
449 #else |
372
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
450 kev->fflags = 0; |
c9fdfccebc49
nginx-0.0.7-2004-06-29-01:03:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
371
diff
changeset
|
451 kev->data = 0; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
452 #endif |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
453 } |
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
454 |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
455 ev->index = nchanges; |
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
456 nchanges++; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
457 |
1451
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
458 if (flags & NGX_FLUSH_EVENT) { |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
459 ts.tv_sec = 0; |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
460 ts.tv_nsec = 0; |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
461 |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
462 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "kevent flush"); |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
463 |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
464 if (kevent(ngx_kqueue, change_list, (int) nchanges, NULL, 0, &ts) |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
465 == -1) |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
466 { |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
467 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, "kevent() failed"); |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
468 return NGX_ERROR; |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
469 } |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
470 |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
471 nchanges = 0; |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
472 } |
ae957ab627e2
NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT
Igor Sysoev <igor@sysoev.ru>
parents:
1440
diff
changeset
|
473 |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
474 return NGX_OK; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
475 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
476 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
18
diff
changeset
|
477 |
6020
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
478 #ifdef EVFILT_USER |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
479 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
480 static ngx_int_t |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
481 ngx_kqueue_notify(ngx_event_handler_pt handler) |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
482 { |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
483 notify_event.handler = handler; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
484 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
485 if (kevent(ngx_kqueue, ¬ify_kev, 1, NULL, 0, NULL) == -1) { |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
486 ngx_log_error(NGX_LOG_ALERT, notify_event.log, ngx_errno, |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
487 "kevent(EVFILT_USER, NOTE_TRIGGER) failed"); |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
488 return NGX_ERROR; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
489 } |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
490 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
491 return NGX_OK; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
492 } |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
493 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
494 #endif |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
495 |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
496 |
499 | 497 static ngx_int_t |
563 | 498 ngx_kqueue_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, |
499 ngx_uint_t flags) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
500 { |
563 | 501 int events, n; |
502 ngx_int_t i, instance; | |
503 ngx_uint_t level; | |
504 ngx_err_t err; | |
5821
3f5f0ab59b35
Events: processing of posted events changed from LIFO to FIFO.
Valentin Bartenev <vbart@nginx.com>
parents:
5820
diff
changeset
|
505 ngx_event_t *ev; |
3f5f0ab59b35
Events: processing of posted events changed from LIFO to FIFO.
Valentin Bartenev <vbart@nginx.com>
parents:
5820
diff
changeset
|
506 ngx_queue_t *queue; |
563 | 507 struct timespec ts, *tp; |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
272
diff
changeset
|
508 |
6030
4652f8f26b12
Removed unix ngx_threaded and related ngx_process_changes.
Ruslan Ermilov <ru@nginx.com>
parents:
6029
diff
changeset
|
509 n = (int) nchanges; |
4652f8f26b12
Removed unix ngx_threaded and related ngx_process_changes.
Ruslan Ermilov <ru@nginx.com>
parents:
6029
diff
changeset
|
510 nchanges = 0; |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
511 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
512 if (timer == NGX_TIMER_INFINITE) { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
513 tp = NULL; |
315
39b6f2df45c0
nginx-0.0.3-2004-04-14-21:44:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
313
diff
changeset
|
514 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
515 } else { |
619 | 516 |
623 | 517 ts.tv_sec = timer / 1000; |
518 ts.tv_nsec = (timer % 1000) * 1000000; | |
519 | |
619 | 520 /* |
623 | 521 * 64-bit Darwin kernel has the bug: kernel level ts.tv_nsec is |
619 | 522 * the int32_t while user level ts.tv_nsec is the long (64-bit), |
523 * so on the big endian PowerPC all nanoseconds are lost. | |
524 */ | |
525 | |
623 | 526 #if (NGX_DARWIN_KEVENT_BUG) |
527 ts.tv_nsec <<= 32; | |
528 #endif | |
529 | |
51
a6afbb8a2ada
nginx-0.0.1-2003-01-24-09:20:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
50
diff
changeset
|
530 tp = &ts; |
a6afbb8a2ada
nginx-0.0.1-2003-01-24-09:20:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
50
diff
changeset
|
531 } |
a6afbb8a2ada
nginx-0.0.1-2003-01-24-09:20:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
50
diff
changeset
|
532 |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
533 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
561 | 534 "kevent timer: %M, changes: %d", timer, n); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
535 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
536 events = kevent(ngx_kqueue, change_list, n, event_list, (int) nevents, tp); |
32
d45effe5854c
nginx-0.0.1-2002-12-19-10:08:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
537 |
3043 | 538 err = (events == -1) ? ngx_errno : 0; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
539 |
3473
0299cf5856fc
do not update time in the timer signal handler,
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
540 if (flags & NGX_UPDATE_TIME || ngx_event_timer_alarm) { |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
541 ngx_time_update(); |
563 | 542 } |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
170
diff
changeset
|
543 |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
272
diff
changeset
|
544 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
272
diff
changeset
|
545 "kevent events: %d", events); |
248
e885208c518b
nginx-0.0.2-2004-02-03-00:19:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
546 |
563 | 547 if (err) { |
548 if (err == NGX_EINTR) { | |
549 | |
550 if (ngx_event_timer_alarm) { | |
551 ngx_event_timer_alarm = 0; | |
552 return NGX_OK; | |
553 } | |
388
80e72c428b39
nginx-0.0.7-2004-07-13-00:43:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
554 |
563 | 555 level = NGX_LOG_INFO; |
556 | |
557 } else { | |
558 level = NGX_LOG_ALERT; | |
559 } | |
560 | |
561 ngx_log_error(level, cycle->log, err, "kevent() failed"); | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
562 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
563 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
564 |
567 | 565 if (events == 0) { |
566 if (timer != NGX_TIMER_INFINITE) { | |
567 return NGX_OK; | |
568 } | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
569 |
567 | 570 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
571 "kevent() returned no events without timeout"); | |
572 return NGX_ERROR; | |
563 | 573 } |
371
780e93985b93
nginx-0.0.7-2004-06-28-20:05:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
370
diff
changeset
|
574 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
575 for (i = 0; i < events; i++) { |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
576 |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
577 ngx_kqueue_dump_event(cycle->log, &event_list[i]); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
578 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
579 if (event_list[i].flags & EV_ERROR) { |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
272
diff
changeset
|
580 ngx_log_error(NGX_LOG_ALERT, cycle->log, event_list[i].data, |
583 | 581 "kevent() error on %d filter:%d flags:%04Xd", |
582 event_list[i].ident, event_list[i].filter, | |
583 event_list[i].flags); | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
584 continue; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
585 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
586 |
563 | 587 #if (NGX_HAVE_TIMER_EVENT) |
588 | |
589 if (event_list[i].filter == EVFILT_TIMER) { | |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
590 ngx_time_update(); |
563 | 591 continue; |
592 } | |
593 | |
594 #endif | |
595 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
596 ev = (ngx_event_t *) event_list[i].udata; |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
597 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
598 switch (event_list[i].filter) { |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
599 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
600 case EVFILT_READ: |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
601 case EVFILT_WRITE: |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
602 |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
603 instance = (uintptr_t) ev & 1; |
194
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
189
diff
changeset
|
604 ev = (ngx_event_t *) ((uintptr_t) ev & (uintptr_t) ~1); |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
605 |
375
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
374
diff
changeset
|
606 if (ev->closed || ev->instance != instance) { |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
607 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
608 /* |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
609 * the stale event from a file descriptor |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
610 * that was just closed in this iteration |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
611 */ |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
612 |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
272
diff
changeset
|
613 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
461 | 614 "kevent: stale event %p", ev); |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
615 continue; |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
616 } |
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
617 |
374
213f17e9f776
nginx-0.0.7-2004-07-02-09:47:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
618 if (ev->log && (ev->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { |
213f17e9f776
nginx-0.0.7-2004-07-02-09:47:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
619 ngx_kqueue_dump_event(ev->log, &event_list[i]); |
213f17e9f776
nginx-0.0.7-2004-07-02-09:47:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
620 } |
213f17e9f776
nginx-0.0.7-2004-07-02-09:47:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
373
diff
changeset
|
621 |
509 | 622 if (ev->oneshot) { |
623 ev->active = 0; | |
624 } | |
625 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
626 ev->available = event_list[i].data; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
627 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
628 if (event_list[i].flags & EV_EOF) { |
375
744ccb59062d
nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
374
diff
changeset
|
629 ev->pending_eof = 1; |
163
fb61ba77beba
nginx-0.0.1-2003-10-28-18:45:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
161
diff
changeset
|
630 ev->kq_errno = event_list[i].fflags; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
631 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
632 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
633 ev->ready = 1; |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
634 |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
635 break; |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
53
diff
changeset
|
636 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
637 case EVFILT_VNODE: |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
638 ev->kq_vnode = 1; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
639 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
640 break; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
641 |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
53
diff
changeset
|
642 case EVFILT_AIO: |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
643 ev->complete = 1; |
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
644 ev->ready = 1; |
59
e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
53
diff
changeset
|
645 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
646 break; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
647 |
6020
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
648 #ifdef EVFILT_USER |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
649 case EVFILT_USER: |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
650 break; |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
651 #endif |
e5f1d83360ef
Events: implemented kqueue notification mechanism.
Valentin Bartenev <vbart@nginx.com>
parents:
6018
diff
changeset
|
652 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
653 default: |
301
744965ec6275
nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
272
diff
changeset
|
654 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
655 "unexpected kevent() filter %d", |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
656 event_list[i].filter); |
271
e16dfb9b9afa
nginx-0.0.2-2004-02-26-20:10:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
657 continue; |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
658 } |
271
e16dfb9b9afa
nginx-0.0.2-2004-02-26-20:10:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
659 |
563 | 660 if (flags & NGX_POST_EVENTS) { |
5820
3377f9459e99
Events: removed broken thread support from posted events.
Valentin Bartenev <vbart@nginx.com>
parents:
4572
diff
changeset
|
661 queue = ev->accept ? &ngx_posted_accept_events |
3377f9459e99
Events: removed broken thread support from posted events.
Valentin Bartenev <vbart@nginx.com>
parents:
4572
diff
changeset
|
662 : &ngx_posted_events; |
3377f9459e99
Events: removed broken thread support from posted events.
Valentin Bartenev <vbart@nginx.com>
parents:
4572
diff
changeset
|
663 |
3377f9459e99
Events: removed broken thread support from posted events.
Valentin Bartenev <vbart@nginx.com>
parents:
4572
diff
changeset
|
664 ngx_post_event(ev, queue); |
271
e16dfb9b9afa
nginx-0.0.2-2004-02-26-20:10:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
665 |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
666 continue; |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
667 } |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
668 |
509 | 669 ev->handler(ev); |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
670 } |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
38
diff
changeset
|
671 |
12
055ed05235ae
nginx-0.0.1-2002-09-13-18:47:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
11
diff
changeset
|
672 return NGX_OK; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
673 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
674 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
675 |
499 | 676 static ngx_inline void |
677 ngx_kqueue_dump_event(ngx_log_t *log, struct kevent *kev) | |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
678 { |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
679 ngx_log_debug6(NGX_LOG_DEBUG_EVENT, log, 0, |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
680 (kev->ident > 0x8000000 && kev->ident != (unsigned) -1) ? |
461 | 681 "kevent: %p: ft:%d fl:%04Xd ff:%08Xd d:%d ud:%p": |
682 "kevent: %d: ft:%d fl:%04Xd ff:%08Xd d:%d ud:%p", | |
307
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
683 kev->ident, kev->filter, |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
684 kev->flags, kev->fflags, |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
685 kev->data, kev->udata); |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
686 } |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
687 |
ce375c313e96
nginx-0.0.3-2004-04-08-19:58:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
688 |
499 | 689 static void * |
690 ngx_kqueue_create_conf(ngx_cycle_t *cycle) | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
691 { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
692 ngx_kqueue_conf_t *kcf; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
693 |
501 | 694 kcf = ngx_palloc(cycle->pool, sizeof(ngx_kqueue_conf_t)); |
695 if (kcf == NULL) { | |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
696 return NULL; |
501 | 697 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
698 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
699 kcf->changes = NGX_CONF_UNSET; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
700 kcf->events = NGX_CONF_UNSET; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
701 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
702 return kcf; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
703 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
704 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
705 |
499 | 706 static char * |
707 ngx_kqueue_init_conf(ngx_cycle_t *cycle, void *conf) | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
708 { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
709 ngx_kqueue_conf_t *kcf = conf; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
710 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
711 ngx_conf_init_uint_value(kcf->changes, 512); |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
623
diff
changeset
|
712 ngx_conf_init_uint_value(kcf->events, 512); |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
713 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
714 return NGX_CONF_OK; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
715 } |