Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 335 lines (283 sloc) 7.997 kb
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
1 /* $OpenBSD: poll.c,v 1.2 2002/06/25 15:50:15 mickey Exp $ */
2
3 /*
b85b710 Update copyright statements to reflect the facts that:
Nick Mathewson authored
4 * Copyright 2000-2007 Niels Provos <provos@citi.umich.edu>
17efc1c Update all our copyright notices to say "2010"
Nick Mathewson authored
5 * Copyright 2007-2010 Niels Provos and Nick Mathewson
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
c3f496c @provos minor corrections; change license to 3-clause BSD license
provos authored
15 * 3. The name of the author may not be used to endorse or promote products
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
ec347b9 Move event-config.h to include/event2
Nick Mathewson authored
29 #include "event2/event-config.h"
0915ca0 @kev009 Include evconfig-private.h in internal files for great good.
kev009 authored
30 #include "evconfig-private.h"
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
31
32 #include <sys/types.h>
8889a77 Replace all use of config.h with event-config.h.
Nick Mathewson authored
33 #ifdef _EVENT_HAVE_SYS_TIME_H
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
34 #include <sys/time.h>
35 #endif
36 #include <sys/queue.h>
37 #include <poll.h>
38 #include <signal.h>
850c3ff @chris-davis Add evutil_tv_to_msec for safe conversion of timevals to milliseconds.
chris-davis authored
39 #include <limits.h>
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #include <unistd.h>
44 #include <errno.h>
45
8773c4c @provos make libevent thread-safe; first cut
provos authored
46 #include "event-internal.h"
169321c Rename four internal headers to follow the -internal.h convention.
Nick Mathewson authored
47 #include "evsignal-internal.h"
48 #include "log-internal.h"
49 #include "evmap-internal.h"
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
50 #include "event2/thread.h"
51 #include "evthread-internal.h"
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
52
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
53 struct pollidx {
54 int idxplus1;
55 };
56
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
57 struct pollop {
58 int event_count; /* Highest number alloc */
e5bbd40 Clean up formatting: use tabs, not 8-spaces, to indent.
Nick Mathewson authored
59 int nfds; /* Highest number used */
60 int realloc_copy; /* True iff we must realloc
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
61 * event_set_copy */
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
62 struct pollfd *event_set;
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
63 struct pollfd *event_set_copy;
3ba224d @provos fixes for threaded operations from Andrew Danforth
provos authored
64 };
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
65
2c2618d more whitespace normalization
Nick Mathewson authored
66 static void *poll_init(struct event_base *);
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
67 static int poll_add(struct event_base *, int, short old, short events, void *_idx);
68 static int poll_del(struct event_base *, int, short old, short events, void *_idx);
2c2618d more whitespace normalization
Nick Mathewson authored
69 static int poll_dispatch(struct event_base *, struct timeval *);
70 static void poll_dealloc(struct event_base *);
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
71
7517ef2 @provos some fixes from openbsd via brad
provos authored
72 const struct eventop pollops = {
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
73 "poll",
74 poll_init,
75 poll_add,
76 poll_del,
2e8051f @provos introduce a way to free the base from Nick Mathewson <nickm@freehaven.ne...
provos authored
77 poll_dispatch,
ce4ee41 r16733@catbus: nickm | 2007-11-26 14:18:25 -0500
Nick Mathewson authored
78 poll_dealloc,
e5bbd40 Clean up formatting: use tabs, not 8-spaces, to indent.
Nick Mathewson authored
79 0, /* doesn't need_reinit */
0596592 Add new functions to access backends by their features and to query the ...
Nick Mathewson authored
80 EV_FEATURE_FDS,
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
81 sizeof(struct pollidx),
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
82 };
83
ca42671 @provos make event methods static so that they are not exported; from Andrei Nig...
provos authored
84 static void *
41b7cbc @provos more the signal base into the event base; this removes global state and ...
provos authored
85 poll_init(struct event_base *base)
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
86 {
3ba224d @provos fixes for threaded operations from Andrew Danforth
provos authored
87 struct pollop *pollop;
88
49868b6 r15316@tombo: nickm | 2008-04-24 20:58:36 -0400
Nick Mathewson authored
89 if (!(pollop = mm_calloc(1, sizeof(struct pollop))))
3ba224d @provos fixes for threaded operations from Andrew Danforth
provos authored
90 return (NULL);
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
91
d776f84 @provos deprecate the usage of signal_{add,del,set} and name it evsignal_{add,de...
provos authored
92 evsig_init(base);
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
93
3ba224d @provos fixes for threaded operations from Andrew Danforth
provos authored
94 return (pollop);
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
95 }
96
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
97 #ifdef CHECK_INVARIANTS
98 static void
99 poll_check_ok(struct pollop *pop)
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
100 {
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
101 int i, idx;
e72dff1 @provos replace references to __FUNCTION__ with __func__
provos authored
102 struct event *ev;
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
103
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
104 for (i = 0; i < pop->fd_count; ++i) {
105 idx = pop->idxplus1_by_fd[i]-1;
106 if (idx < 0)
107 continue;
2e36dbe Use EVUTIL_ASSERT() consistently instead of assert.
Nick Mathewson authored
108 EVUTIL_ASSERT(pop->event_set[idx].fd == i);
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
109 }
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
110 for (i = 0; i < pop->nfds; ++i) {
111 struct pollfd *pfd = &pop->event_set[i];
2e36dbe Use EVUTIL_ASSERT() consistently instead of assert.
Nick Mathewson authored
112 EVUTIL_ASSERT(pop->idxplus1_by_fd[pfd->fd] == i+1);
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
113 }
114 }
115 #else
116 #define poll_check_ok(pop)
117 #endif
118
ca42671 @provos make event methods static so that they are not exported; from Andrei Nig...
provos authored
119 static int
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
120 poll_dispatch(struct event_base *base, struct timeval *tv)
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
121 {
850c3ff @chris-davis Add evutil_tv_to_msec for safe conversion of timevals to milliseconds.
chris-davis authored
122 int res, i, j, nfds;
123 long msec = -1;
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
124 struct pollop *pop = base->evbase;
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
125 struct pollfd *event_set;
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
126
9938aaf @provos treate EINVAL as per fd error in kqueue; use argument for debug macros i...
provos authored
127 poll_check_ok(pop);
3ad6b47 @provos make clock_monotonic work; do not use default timeout;
provos authored
128
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
129 nfds = pop->nfds;
130
767eb70 Fix compilation with threading disabled.
Nick Mathewson authored
131 #ifndef _EVENT_DISABLE_THREAD_SUPPORT
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
132 if (base->th_base_lock) {
133 /* If we're using this backend in a multithreaded setting,
134 * then we need to work on a copy of event_set, so that we can
135 * let other threads modify the main event_set while we're
136 * polling. If we're not multithreaded, then we'll skip the
137 * copy step here to save memory and time. */
138 if (pop->realloc_copy) {
139 struct pollfd *tmp = mm_realloc(pop->event_set_copy,
140 pop->event_count * sizeof(struct pollfd));
141 if (tmp == NULL) {
142 event_warn("realloc");
143 return -1;
144 }
145 pop->event_set_copy = tmp;
146 pop->realloc_copy = 0;
147 }
148 memcpy(pop->event_set_copy, pop->event_set,
149 sizeof(struct pollfd)*nfds);
150 event_set = pop->event_set_copy;
151 } else {
152 event_set = pop->event_set;
153 }
767eb70 Fix compilation with threading disabled.
Nick Mathewson authored
154 #else
155 event_set = pop->event_set;
156 #endif
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
157
850c3ff @chris-davis Add evutil_tv_to_msec for safe conversion of timevals to milliseconds.
chris-davis authored
158 if (tv != NULL) {
159 msec = evutil_tv_to_msec(tv);
160 if (msec < 0 || msec > INT_MAX)
161 msec = INT_MAX;
162 }
3ad6b47 @provos make clock_monotonic work; do not use default timeout;
provos authored
163
76cd2b7 Stop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks.
Nick Mathewson authored
164 EVBASE_RELEASE_LOCK(base, th_base_lock);
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
165
166 res = poll(event_set, nfds, msec);
167
76cd2b7 Stop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks.
Nick Mathewson authored
168 EVBASE_ACQUIRE_LOCK(base, th_base_lock);
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
169
170 if (res == -1) {
171 if (errno != EINTR) {
e5bbd40 Clean up formatting: use tabs, not 8-spaces, to indent.
Nick Mathewson authored
172 event_warn("poll");
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
173 return (-1);
174 }
175
176 return (0);
41b7cbc @provos more the signal base into the event base; this removes global state and ...
provos authored
177 }
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
178
fbdaf3a @provos debugging callbacks from Nick Mathewson <nickm@freehaven.net>
provos authored
179 event_debug(("%s: poll reports %d", __func__, res));
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
180
cdaca02 Activate fd events in a pseudorandom order on older backends.
Nick Mathewson authored
181 if (res == 0 || nfds == 0)
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
182 return (0);
183
cdaca02 Activate fd events in a pseudorandom order on older backends.
Nick Mathewson authored
184 i = random() % nfds;
185 for (j = 0; j < nfds; j++) {
186 int what;
187 if (++i == nfds)
188 i = 0;
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
189 what = event_set[i].revents;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
190 if (!what)
191 continue;
192
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
193 res = 0;
e1cd86d @provos fixes to handle error cases by Anatoly Vorobey at pobox.com
provos authored
194
e506eaf @provos constify; some windows stuff by mike davis; fix a poll bug
provos authored
195 /* If the file gets closed notify */
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
196 if (what & (POLLHUP|POLLERR))
e1cd86d @provos fixes to handle error cases by Anatoly Vorobey at pobox.com
provos authored
197 what |= POLLIN|POLLOUT;
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
198 if (what & POLLIN)
f08bf53 @provos fix poll hup support
provos authored
199 res |= EV_READ;
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
200 if (what & POLLOUT)
f08bf53 @provos fix poll hup support
provos authored
201 res |= EV_WRITE;
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
202 if (res == 0)
203 continue;
204
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
205 evmap_io_active(base, event_set[i].fd, res);
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
206 }
207
208 return (0);
209 }
210
ca42671 @provos make event methods static so that they are not exported; from Andrei Nig...
provos authored
211 static int
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
212 poll_add(struct event_base *base, int fd, short old, short events, void *_idx)
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
213 {
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
214 struct pollop *pop = base->evbase;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
215 struct pollfd *pfd = NULL;
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
216 struct pollidx *idx = _idx;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
217 int i;
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
218
2e36dbe Use EVUTIL_ASSERT() consistently instead of assert.
Nick Mathewson authored
219 EVUTIL_ASSERT((events & EV_SIGNAL) == 0);
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
220 if (!(events & (EV_READ|EV_WRITE)))
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
221 return (0);
222
223 poll_check_ok(pop);
224 if (pop->nfds + 1 >= pop->event_count) {
025b009 @provos fail without leaking memory when poll set extension fails
provos authored
225 struct pollfd *tmp_event_set;
226 int tmp_event_count;
227
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
228 if (pop->event_count < 32)
025b009 @provos fail without leaking memory when poll set extension fails
provos authored
229 tmp_event_count = 32;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
230 else
025b009 @provos fail without leaking memory when poll set extension fails
provos authored
231 tmp_event_count = pop->event_count * 2;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
232
233 /* We need more file descriptors */
49868b6 r15316@tombo: nickm | 2008-04-24 20:58:36 -0400
Nick Mathewson authored
234 tmp_event_set = mm_realloc(pop->event_set,
025b009 @provos fail without leaking memory when poll set extension fails
provos authored
235 tmp_event_count * sizeof(struct pollfd));
236 if (tmp_event_set == NULL) {
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
237 event_warn("realloc");
238 return (-1);
239 }
025b009 @provos fail without leaking memory when poll set extension fails
provos authored
240 pop->event_set = tmp_event_set;
241
242 pop->event_count = tmp_event_count;
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
243 pop->realloc_copy = 1;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
244 }
245
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
246 i = idx->idxplus1 - 1;
247
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
248 if (i >= 0) {
249 pfd = &pop->event_set[i];
250 } else {
251 i = pop->nfds++;
252 pfd = &pop->event_set[i];
253 pfd->events = 0;
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
254 pfd->fd = fd;
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
255 idx->idxplus1 = i + 1;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
256 }
257
258 pfd->revents = 0;
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
259 if (events & EV_WRITE)
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
260 pfd->events |= POLLOUT;
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
261 if (events & EV_READ)
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
262 pfd->events |= POLLIN;
263 poll_check_ok(pop);
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
264
265 return (0);
266 }
267
268 /*
269 * Nothing to be done here.
270 */
271
ca42671 @provos make event methods static so that they are not exported; from Andrei Nig...
provos authored
272 static int
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
273 poll_del(struct event_base *base, int fd, short old, short events, void *_idx)
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
274 {
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
275 struct pollop *pop = base->evbase;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
276 struct pollfd *pfd = NULL;
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
277 struct pollidx *idx = _idx;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
278 int i;
279
2e36dbe Use EVUTIL_ASSERT() consistently instead of assert.
Nick Mathewson authored
280 EVUTIL_ASSERT((events & EV_SIGNAL) == 0);
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
281 if (!(events & (EV_READ|EV_WRITE)))
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
282 return (0);
283
284 poll_check_ok(pop);
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
285 i = idx->idxplus1 - 1;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
286 if (i < 0)
287 return (-1);
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
288
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
289 /* Do we still want to read or write? */
290 pfd = &pop->event_set[i];
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
291 if (events & EV_READ)
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
292 pfd->events &= ~POLLIN;
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
293 if (events & EV_WRITE)
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
294 pfd->events &= ~POLLOUT;
295 poll_check_ok(pop);
296 if (pfd->events)
297 /* Another event cares about that fd. */
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
298 return (0);
299
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
300 /* Okay, so we aren't interested in that fd anymore. */
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
301 idx->idxplus1 = 0;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
302
303 --pop->nfds;
304 if (i != pop->nfds) {
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
305 /*
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
306 * Shift the last pollfd down into the now-unoccupied
307 * position.
308 */
309 memcpy(&pop->event_set[i], &pop->event_set[pop->nfds],
310 sizeof(struct pollfd));
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
311 idx = evmap_io_get_fdinfo(&base->io, pop->event_set[i].fd);
2e36dbe Use EVUTIL_ASSERT() consistently instead of assert.
Nick Mathewson authored
312 EVUTIL_ASSERT(idx);
313 EVUTIL_ASSERT(idx->idxplus1 == pop->nfds + 1);
554e149 Move per-fd info from eventops into evmap. Not done for win32.c yet.
Nick Mathewson authored
314 idx->idxplus1 = i + 1;
c15db03 @provos performance improvements by Nick Mathewson; we modify the arrays directl...
provos authored
315 }
316
317 poll_check_ok(pop);
318 return (0);
b3d1c6a @provos support poll(2) and split out the signal handling
provos authored
319 }
2e8051f @provos introduce a way to free the base from Nick Mathewson <nickm@freehaven.ne...
provos authored
320
ca42671 @provos make event methods static so that they are not exported; from Andrei Nig...
provos authored
321 static void
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
322 poll_dealloc(struct event_base *base)
2e8051f @provos introduce a way to free the base from Nick Mathewson <nickm@freehaven.ne...
provos authored
323 {
02b2b4d @provos Restructure the event backends so that they do not need to keep track of...
provos authored
324 struct pollop *pop = base->evbase;
2e8051f @provos introduce a way to free the base from Nick Mathewson <nickm@freehaven.ne...
provos authored
325
d776f84 @provos deprecate the usage of signal_{add,del,set} and name it evsignal_{add,de...
provos authored
326 evsig_dealloc(base);
2e8051f @provos introduce a way to free the base from Nick Mathewson <nickm@freehaven.ne...
provos authored
327 if (pop->event_set)
49868b6 r15316@tombo: nickm | 2008-04-24 20:58:36 -0400
Nick Mathewson authored
328 mm_free(pop->event_set);
6b22e74 Add locking to event_base_loop.
Nick Mathewson authored
329 if (pop->event_set_copy)
330 mm_free(pop->event_set_copy);
2e8051f @provos introduce a way to free the base from Nick Mathewson <nickm@freehaven.ne...
provos authored
331
332 memset(pop, 0, sizeof(struct pollop));
49868b6 r15316@tombo: nickm | 2008-04-24 20:58:36 -0400
Nick Mathewson authored
333 mm_free(pop);
2e8051f @provos introduce a way to free the base from Nick Mathewson <nickm@freehaven.ne...
provos authored
334 }
Something went wrong with that request. Please try again.