Skip to content
This repository
Newer
Older
100644 385 lines (338 sloc) 10.416 kb
ee8cc84e »
2003-09-23 Windows support from Mike Davis
1 /*
e49e2891 »
2012-02-10 Update copyright notices to 2012
2 * Copyright 2007-2012 Niels Provos and Nick Mathewson
b85b710c »
2009-01-27 Update copyright statements to reflect the facts that:
3 * Copyright 2000-2007 Niels Provos <provos@citi.umich.edu>
ee8cc84e »
2003-09-23 Windows support from Mike Davis
4 * Copyright 2003 Michael A. Davis <mike@datanerds.net>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
0915ca0a »
2011-01-02 Include evconfig-private.h in internal files for great good.
28 #include "event2/event-config.h"
29 #include "evconfig-private.h"
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
30
bf2c5a77 »
2012-02-10 Also make win32select.c conditional for IDE users
31 #ifdef _WIN32
32
868f10e7 »
2006-11-22 mingw fixes from Nick
33 #include <winsock2.h>
4e1ec3e0 »
2007-11-07 Make all the C files in the libraries compile under MSVC 2005 Express…
34 #include <windows.h>
ee8cc84e »
2003-09-23 Windows support from Mike Davis
35 #include <sys/types.h>
36 #include <sys/queue.h>
850c3ff2 »
2010-03-31 Add evutil_tv_to_msec for safe conversion of timevals to milliseconds.
37 #include <limits.h>
ee8cc84e »
2003-09-23 Windows support from Mike Davis
38 #include <signal.h>
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <errno.h>
43
ebf29455 »
2009-04-30 Compilation fixes for vc++ 2008 express. Not the end of them.
44 #include "event2/util.h"
45 #include "util-internal.h"
169321c9 »
2009-01-13 Rename four internal headers to follow the -internal.h convention.
46 #include "log-internal.h"
ebf29455 »
2009-04-30 Compilation fixes for vc++ 2008 express. Not the end of them.
47 #include "event2/event.h"
42b97958 »
2005-02-04 make it compile again; from dug song
48 #include "event-internal.h"
9935d5b0 »
2009-01-13 Fix win32 compilation. Surprisingly, unit tests pass too.
49 #include "evmap-internal.h"
ed748a48 »
2009-10-21 Fix win32 compilation.
50 #include "event2/thread.h"
51 #include "evthread-internal.h"
ee8cc84e »
2003-09-23 Windows support from Mike Davis
52
2c2618d8 »
2010-03-05 more whitespace normalization
53 #define XFREE(ptr) do { if (ptr) mm_free(ptr); } while (0)
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
54
55 extern struct event_list timequeue;
56 extern struct event_list addqueue;
ee8cc84e »
2003-09-23 Windows support from Mike Davis
57
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
58 struct win_fd_set {
59 u_int fd_count;
60 SOCKET fd_array[1];
61 };
ee8cc84e »
2003-09-23 Windows support from Mike Davis
62
63 /* MSDN says this is required to handle SIGFPE */
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
64 volatile double SIGFPE_REQ = 0.0f;
ee8cc84e »
2003-09-23 Windows support from Mike Davis
65
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
66 struct idx_info {
67 int read_pos_plus1;
68 int write_pos_plus1;
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
69 };
70
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
71 struct win32op {
b6a158ca »
2010-11-01 Rename "size" variables in win32select that were really fd counts.
72 unsigned num_fds_in_fd_sets;
6b22e74a »
2009-10-21 Add locking to event_base_loop.
73 int resize_out_sets;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
74 struct win_fd_set *readset_in;
75 struct win_fd_set *writeset_in;
76 struct win_fd_set *readset_out;
77 struct win_fd_set *writeset_out;
78 struct win_fd_set *exset_out;
8c66eb2e »
2009-05-22 Try to contain the failure when we are running without socketpair().
79 unsigned signals_are_broken : 1;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
80 };
81
2c2618d8 »
2010-03-05 more whitespace normalization
82 static void *win32_init(struct event_base *);
946b5841 »
2012-02-29 Clean up lingering _identifiers.
83 static int win32_add(struct event_base *, evutil_socket_t, short old, short events, void *idx_);
84 static int win32_del(struct event_base *, evutil_socket_t, short old, short events, void *idx_);
2c2618d8 »
2010-03-05 more whitespace normalization
85 static int win32_dispatch(struct event_base *base, struct timeval *);
86 static void win32_dealloc(struct event_base *);
ee8cc84e »
2003-09-23 Windows support from Mike Davis
87
88 struct eventop win32ops = {
89 "win32",
90 win32_init,
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
91 win32_add,
ee8cc84e »
2003-09-23 Windows support from Mike Davis
92 win32_del,
2e8051f5 »
2006-03-28 introduce a way to free the base from Nick Mathewson <nickm@freehaven…
93 win32_dispatch,
78d0de30 »
2007-12-06 Fix compile warnings and errors in win32 build.
94 win32_dealloc,
05965921 »
2008-05-31 Add new functions to access backends by their features and to query t…
95 0, /* doesn't need reinit */
96 0, /* No features supported. */
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
97 sizeof(struct idx_info),
ee8cc84e »
2003-09-23 Windows support from Mike Davis
98 };
99
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
100 #define FD_SET_ALLOC_SIZE(n) ((sizeof(struct win_fd_set) + ((n)-1)*sizeof(SOCKET)))
101
102 static int
b6a158ca »
2010-11-01 Rename "size" variables in win32select that were really fd counts.
103 grow_fd_sets(struct win32op *op, unsigned new_num_fds)
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
104 {
105 size_t size;
106
b6a158ca »
2010-11-01 Rename "size" variables in win32select that were really fd counts.
107 EVUTIL_ASSERT(new_num_fds >= op->readset_in->fd_count &&
108 new_num_fds >= op->writeset_in->fd_count);
109 EVUTIL_ASSERT(new_num_fds >= 1);
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
110
b6a158ca »
2010-11-01 Rename "size" variables in win32select that were really fd counts.
111 size = FD_SET_ALLOC_SIZE(new_num_fds);
6b22e74a »
2009-10-21 Add locking to event_base_loop.
112 if (!(op->readset_in = mm_realloc(op->readset_in, size)))
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
113 return (-1);
6b22e74a »
2009-10-21 Add locking to event_base_loop.
114 if (!(op->writeset_in = mm_realloc(op->writeset_in, size)))
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
115 return (-1);
6b22e74a »
2009-10-21 Add locking to event_base_loop.
116 op->resize_out_sets = 1;
b6a158ca »
2010-11-01 Rename "size" variables in win32select that were really fd counts.
117 op->num_fds_in_fd_sets = new_num_fds;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
118 return (0);
119 }
120
121 static int
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
122 do_fd_set(struct win32op *op, struct idx_info *ent, evutil_socket_t s, int read)
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
123 {
124 struct win_fd_set *set = read ? op->readset_in : op->writeset_in;
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
125 if (read) {
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
126 if (ent->read_pos_plus1 > 0)
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
127 return (0);
128 } else {
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
129 if (ent->write_pos_plus1 > 0)
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
130 return (0);
131 }
b6a158ca »
2010-11-01 Rename "size" variables in win32select that were really fd counts.
132 if (set->fd_count == op->num_fds_in_fd_sets) {
133 if (grow_fd_sets(op, op->num_fds_in_fd_sets*2))
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
134 return (-1);
0c48c706 »
2005-12-08 windows memory corruption bug fix from I-M Weasel via Nick Mathewson.
135 /* set pointer will have changed and needs reiniting! */
136 set = read ? op->readset_in : op->writeset_in;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
137 }
138 set->fd_array[set->fd_count] = s;
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
139 if (read)
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
140 ent->read_pos_plus1 = set->fd_count+1;
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
141 else
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
142 ent->write_pos_plus1 = set->fd_count+1;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
143 return (set->fd_count++);
144 }
145
146 static int
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
147 do_fd_clear(struct event_base *base,
148 struct win32op *op, struct idx_info *ent, int read)
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
149 {
78d0de30 »
2007-12-06 Fix compile warnings and errors in win32 build.
150 int i;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
151 struct win_fd_set *set = read ? op->readset_in : op->writeset_in;
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
152 if (read) {
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
153 i = ent->read_pos_plus1 - 1;
154 ent->read_pos_plus1 = 0;
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
155 } else {
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
156 i = ent->write_pos_plus1 - 1;
157 ent->write_pos_plus1 = 0;
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
158 }
159 if (i < 0)
160 return (0);
e06f514d »
2010-10-14 Fix signed/unsigned warnings on win32
161 if (--set->fd_count != (unsigned)i) {
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
162 struct idx_info *ent2;
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
163 SOCKET s2;
164 s2 = set->fd_array[i] = set->fd_array[set->fd_count];
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
165
8ac3c4c2 »
2012-02-29 Have all visible internal function names end with an underscore.
166 ent2 = evmap_io_get_fdinfo_(&base->io, s2);
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
167
168 if (!ent2) /* This indicates a bug. */
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
169 return (0);
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
170 if (read)
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
171 ent2->read_pos_plus1 = i+1;
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
172 else
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
173 ent2->write_pos_plus1 = i+1;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
174 }
175 return (0);
176 }
177
5ec43fe4 »
2009-11-06 Fix a miscalculated realloc() size in win32select.c.
178 #define NEVENT 32
ee8cc84e »
2003-09-23 Windows support from Mike Davis
179 void *
946b5841 »
2012-02-29 Clean up lingering _identifiers.
180 win32_init(struct event_base *base)
ee8cc84e »
2003-09-23 Windows support from Mike Davis
181 {
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
182 struct win32op *winop;
183 size_t size;
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
184 if (!(winop = mm_calloc(1, sizeof(struct win32op))))
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
185 return NULL;
b6a158ca »
2010-11-01 Rename "size" variables in win32select that were really fd counts.
186 winop->num_fds_in_fd_sets = NEVENT;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
187 size = FD_SET_ALLOC_SIZE(NEVENT);
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
188 if (!(winop->readset_in = mm_malloc(size)))
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
189 goto err;
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
190 if (!(winop->writeset_in = mm_malloc(size)))
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
191 goto err;
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
192 if (!(winop->readset_out = mm_malloc(size)))
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
193 goto err;
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
194 if (!(winop->writeset_out = mm_malloc(size)))
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
195 goto err;
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
196 if (!(winop->exset_out = mm_malloc(size)))
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
197 goto err;
198 winop->readset_in->fd_count = winop->writeset_in->fd_count = 0;
199 winop->readset_out->fd_count = winop->writeset_out->fd_count
200 = winop->exset_out->fd_count = 0;
201
946b5841 »
2012-02-29 Clean up lingering _identifiers.
202 if (evsig_init_(base) < 0)
8c66eb2e »
2009-05-22 Try to contain the failure when we are running without socketpair().
203 winop->signals_are_broken = 1;
f0e06d75 »
2007-09-20 r15217@catbus: nickm | 2007-09-20 14:04:32 -0400
204
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
205 return (winop);
206 err:
e5bbd40a »
2010-02-18 Clean up formatting: use tabs, not 8-spaces, to indent.
207 XFREE(winop->readset_in);
208 XFREE(winop->writeset_in);
209 XFREE(winop->readset_out);
210 XFREE(winop->writeset_out);
211 XFREE(winop->exset_out);
212 XFREE(winop);
213 return (NULL);
ee8cc84e »
2003-09-23 Windows support from Mike Davis
214 }
215
216 int
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
217 win32_add(struct event_base *base, evutil_socket_t fd,
946b5841 »
2012-02-29 Clean up lingering _identifiers.
218 short old, short events, void *idx_)
ee8cc84e »
2003-09-23 Windows support from Mike Davis
219 {
02b2b4d1 »
2008-12-23 Restructure the event backends so that they do not need to keep track…
220 struct win32op *win32op = base->evbase;
946b5841 »
2012-02-29 Clean up lingering _identifiers.
221 struct idx_info *idx = idx_;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
222
8c66eb2e »
2009-05-22 Try to contain the failure when we are running without socketpair().
223 if ((events & EV_SIGNAL) && win32op->signals_are_broken)
224 return (-1);
225
02b2b4d1 »
2008-12-23 Restructure the event backends so that they do not need to keep track…
226 if (!(events & (EV_READ|EV_WRITE)))
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
227 return (0);
228
02b2b4d1 »
2008-12-23 Restructure the event backends so that they do not need to keep track…
229 event_debug(("%s: adding event for %d", __func__, (int)fd));
230 if (events & EV_READ) {
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
231 if (do_fd_set(win32op, idx, fd, 1)<0)
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
232 return (-1);
233 }
02b2b4d1 »
2008-12-23 Restructure the event backends so that they do not need to keep track…
234 if (events & EV_WRITE) {
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
235 if (do_fd_set(win32op, idx, fd, 0)<0)
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
236 return (-1);
237 }
ee8cc84e »
2003-09-23 Windows support from Mike Davis
238 return (0);
239 }
240
241 int
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
242 win32_del(struct event_base *base, evutil_socket_t fd, short old, short events,
946b5841 »
2012-02-29 Clean up lingering _identifiers.
243 void *idx_)
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
244 {
02b2b4d1 »
2008-12-23 Restructure the event backends so that they do not need to keep track…
245 struct win32op *win32op = base->evbase;
946b5841 »
2012-02-29 Clean up lingering _identifiers.
246 struct idx_info *idx = idx_;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
247
02b2b4d1 »
2008-12-23 Restructure the event backends so that they do not need to keep track…
248 event_debug(("%s: Removing event for %d", __func__, fd));
249 if (events & EV_READ)
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
250 do_fd_clear(base, win32op, idx, 1);
02b2b4d1 »
2008-12-23 Restructure the event backends so that they do not need to keep track…
251 if (events & EV_WRITE)
89fe3167 »
2009-01-14 Update win32 code to put indices in evmap.
252 do_fd_clear(base, win32op, idx, 0);
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
253
254 return 0;
255 }
256
257 static void
258 fd_set_copy(struct win_fd_set *out, const struct win_fd_set *in)
259 {
260 out->fd_count = in->fd_count;
261 memcpy(out->fd_array, in->fd_array, in->fd_count * (sizeof(SOCKET)));
262 }
263
264 /*
265 static void dump_fd_set(struct win_fd_set *s)
266 {
267 unsigned int i;
268 printf("[ ");
269 for(i=0;i<s->fd_count;++i)
270 printf("%d ",(int)s->fd_array[i]);
271 printf("]\n");
272 }
273 */
274
275 int
02b2b4d1 »
2008-12-23 Restructure the event backends so that they do not need to keep track…
276 win32_dispatch(struct event_base *base, struct timeval *tv)
ee8cc84e »
2003-09-23 Windows support from Mike Davis
277 {
02b2b4d1 »
2008-12-23 Restructure the event backends so that they do not need to keep track…
278 struct win32op *win32op = base->evbase;
ee8cc84e »
2003-09-23 Windows support from Mike Davis
279 int res = 0;
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
280 unsigned j, i;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
281 int fd_count;
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
282 SOCKET s;
ee8cc84e »
2003-09-23 Windows support from Mike Davis
283
ed748a48 »
2009-10-21 Fix win32 compilation.
284 if (win32op->resize_out_sets) {
b6a158ca »
2010-11-01 Rename "size" variables in win32select that were really fd counts.
285 size_t size = FD_SET_ALLOC_SIZE(win32op->num_fds_in_fd_sets);
ed748a48 »
2009-10-21 Fix win32 compilation.
286 if (!(win32op->readset_out = mm_realloc(win32op->readset_out, size)))
6b22e74a »
2009-10-21 Add locking to event_base_loop.
287 return (-1);
ed748a48 »
2009-10-21 Fix win32 compilation.
288 if (!(win32op->exset_out = mm_realloc(win32op->exset_out, size)))
6b22e74a »
2009-10-21 Add locking to event_base_loop.
289 return (-1);
ed748a48 »
2009-10-21 Fix win32 compilation.
290 if (!(win32op->writeset_out = mm_realloc(win32op->writeset_out, size)))
6b22e74a »
2009-10-21 Add locking to event_base_loop.
291 return (-1);
ed748a48 »
2009-10-21 Fix win32 compilation.
292 win32op->resize_out_sets = 0;
6b22e74a »
2009-10-21 Add locking to event_base_loop.
293 }
294
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
295 fd_set_copy(win32op->readset_out, win32op->readset_in);
d8164d0c »
2009-10-21 Fix win32 connect() event handling.
296 fd_set_copy(win32op->exset_out, win32op->writeset_in);
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
297 fd_set_copy(win32op->writeset_out, win32op->writeset_in);
ee8cc84e »
2003-09-23 Windows support from Mike Davis
298
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
299 fd_count =
e5bbd40a »
2010-02-18 Clean up formatting: use tabs, not 8-spaces, to indent.
300 (win32op->readset_out->fd_count > win32op->writeset_out->fd_count) ?
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
301 win32op->readset_out->fd_count : win32op->writeset_out->fd_count;
ee8cc84e »
2003-09-23 Windows support from Mike Davis
302
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
303 if (!fd_count) {
8ac3c4c2 »
2012-02-29 Have all visible internal function names end with an underscore.
304 long msec = evutil_tv_to_msec_(tv);
850c3ff2 »
2010-03-31 Add evutil_tv_to_msec for safe conversion of timevals to milliseconds.
305 /* Sleep's DWORD argument is unsigned long */
306 if (msec < 0)
307 msec = LONG_MAX;
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
308 /* Windows doesn't like you to call select() with no sockets */
850c3ff2 »
2010-03-31 Add evutil_tv_to_msec for safe conversion of timevals to milliseconds.
309 Sleep(msec);
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
310 return (0);
311 }
ee8cc84e »
2003-09-23 Windows support from Mike Davis
312
76cd2b70 »
2009-11-27 Stop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks.
313 EVBASE_RELEASE_LOCK(base, th_base_lock);
6b22e74a »
2009-10-21 Add locking to event_base_loop.
314
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
315 res = select(fd_count,
316 (struct fd_set*)win32op->readset_out,
317 (struct fd_set*)win32op->writeset_out,
318 (struct fd_set*)win32op->exset_out, tv);
319
76cd2b70 »
2009-11-27 Stop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks.
320 EVBASE_ACQUIRE_LOCK(base, th_base_lock);
6b22e74a »
2009-10-21 Add locking to event_base_loop.
321
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
322 event_debug(("%s: select returned %d", __func__, res));
323
4faeaea9 »
2010-02-19 Clean up formatting: function/keyword spacing consistency.
324 if (res <= 0) {
99442c6f »
2005-03-29 windows fixes from Nick Mathewson <nickm@freehaven.net>
325 return res;
326 }
327
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
328 if (win32op->readset_out->fd_count) {
e86af4b7 »
2012-04-09 Change evutil_weakrand_() to avoid platform random()
329 i = evutil_weakrand_range_(&base->weakrand_seed,
330 win32op->readset_out->fd_count);
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
331 for (j=0; j<win32op->readset_out->fd_count; ++j) {
332 if (++i >= win32op->readset_out->fd_count)
333 i = 0;
334 s = win32op->readset_out->fd_array[i];
8ac3c4c2 »
2012-02-29 Have all visible internal function names end with an underscore.
335 evmap_io_active_(base, s, EV_READ);
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
336 }
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
337 }
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
338 if (win32op->exset_out->fd_count) {
e86af4b7 »
2012-04-09 Change evutil_weakrand_() to avoid platform random()
339 i = evutil_weakrand_range_(&base->weakrand_seed,
340 win32op->exset_out->fd_count);
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
341 for (j=0; j<win32op->exset_out->fd_count; ++j) {
a43a1c2b »
2009-05-28 Fix compilation problems in win32.c
342 if (++i >= win32op->exset_out->fd_count)
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
343 i = 0;
344 s = win32op->exset_out->fd_array[i];
8ac3c4c2 »
2012-02-29 Have all visible internal function names end with an underscore.
345 evmap_io_active_(base, s, EV_WRITE);
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
346 }
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
347 }
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
348 if (win32op->writeset_out->fd_count) {
a826a758 »
2009-07-28 Some tweaks to Brodie Thesfield's MSVC patch.
349 SOCKET s;
e86af4b7 »
2012-04-09 Change evutil_weakrand_() to avoid platform random()
350 i = evutil_weakrand_range_(&base->weakrand_seed,
351 win32op->writeset_out->fd_count);
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
352 for (j=0; j<win32op->writeset_out->fd_count; ++j) {
a43a1c2b »
2009-05-28 Fix compilation problems in win32.c
353 if (++i >= win32op->writeset_out->fd_count)
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
354 i = 0;
5b5b880b »
2009-07-28 Various MSVC cleanups from Brodie Thiesfield.
355 s = win32op->writeset_out->fd_array[i];
8ac3c4c2 »
2012-02-29 Have all visible internal function names end with an underscore.
356 evmap_io_active_(base, s, EV_WRITE);
cdaca02c »
2009-05-27 Activate fd events in a pseudorandom order on older backends.
357 }
ee8cc84e »
2003-09-23 Windows support from Mike Davis
358 }
359 return (0);
360 }
361
2e8051f5 »
2006-03-28 introduce a way to free the base from Nick Mathewson <nickm@freehaven…
362 void
946b5841 »
2012-02-29 Clean up lingering _identifiers.
363 win32_dealloc(struct event_base *base)
2e8051f5 »
2006-03-28 introduce a way to free the base from Nick Mathewson <nickm@freehaven…
364 {
946b5841 »
2012-02-29 Clean up lingering _identifiers.
365 struct win32op *win32op = base->evbase;
2e8051f5 »
2006-03-28 introduce a way to free the base from Nick Mathewson <nickm@freehaven…
366
946b5841 »
2012-02-29 Clean up lingering _identifiers.
367 evsig_dealloc_(base);
2e8051f5 »
2006-03-28 introduce a way to free the base from Nick Mathewson <nickm@freehaven…
368 if (win32op->readset_in)
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
369 mm_free(win32op->readset_in);
2e8051f5 »
2006-03-28 introduce a way to free the base from Nick Mathewson <nickm@freehaven…
370 if (win32op->writeset_in)
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
371 mm_free(win32op->writeset_in);
2e8051f5 »
2006-03-28 introduce a way to free the base from Nick Mathewson <nickm@freehaven…
372 if (win32op->readset_out)
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
373 mm_free(win32op->readset_out);
2e8051f5 »
2006-03-28 introduce a way to free the base from Nick Mathewson <nickm@freehaven…
374 if (win32op->writeset_out)
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
375 mm_free(win32op->writeset_out);
2e8051f5 »
2006-03-28 introduce a way to free the base from Nick Mathewson <nickm@freehaven…
376 if (win32op->exset_out)
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
377 mm_free(win32op->exset_out);
2e2104f4 »
2007-12-06 r15172@tombo: nickm | 2007-12-06 12:54:37 -0500
378 /* XXXXX free the tree. */
2e8051f5 »
2006-03-28 introduce a way to free the base from Nick Mathewson <nickm@freehaven…
379
380 memset(win32op, 0, sizeof(win32op));
04366d5a »
2008-05-12 r19677@catbus: nickm | 2008-05-11 20:51:41 -0400
381 mm_free(win32op);
2e8051f5 »
2006-03-28 introduce a way to free the base from Nick Mathewson <nickm@freehaven…
382 }
bf2c5a77 »
2012-02-10 Also make win32select.c conditional for IDE users
383
384 #endif
Something went wrong with that request. Please try again.