ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev_select.c
(Generate patch)

Comparing libev/ev_select.c (file contents):
Revision 1.36 by root, Wed Jun 4 07:42:58 2008 UTC vs.
Revision 1.39 by root, Mon Jan 5 14:41:35 2009 UTC

77 SOCKET handle = anfds [fd].handle; 77 SOCKET handle = anfds [fd].handle;
78 #else 78 #else
79 int handle = fd; 79 int handle = fd;
80 #endif 80 #endif
81 81
82 /* FD_SET is broken on windows (it adds the fd to a set twice or more,
83 * which eventually leads to overflows). Need to call it only on changes.
84 */
85 #if EV_SELECT_IS_WINSOCKET
86 if ((oev ^ nev) & EV_READ)
87 #endif
82 if (nev & EV_READ) 88 if (nev & EV_READ)
83 FD_SET (handle, (fd_set *)vec_ri); 89 FD_SET (handle, (fd_set *)vec_ri);
84 else 90 else
85 FD_CLR (handle, (fd_set *)vec_ri); 91 FD_CLR (handle, (fd_set *)vec_ri);
86 92
93 #if EV_SELECT_IS_WINSOCKET
94 if ((oev ^ nev) & EV_WRITE)
95 #endif
87 if (nev & EV_WRITE) 96 if (nev & EV_WRITE)
88 FD_SET (handle, (fd_set *)vec_wi); 97 FD_SET (handle, (fd_set *)vec_wi);
89 else 98 else
90 FD_CLR (handle, (fd_set *)vec_wi); 99 FD_CLR (handle, (fd_set *)vec_wi);
91 100
92#else 101#else
93 102
94 int word = fd / NFDBITS; 103 int word = fd / NFDBITS;
95 fd_mask mask = 1UL << (fd % NFDBITS); 104 fd_mask mask = 1UL << (fd % NFDBITS);
168 #endif 177 #endif
169 178
170 #ifdef _WIN32 179 #ifdef _WIN32
171 /* select on windows errornously returns EINVAL when no fd sets have been 180 /* select on windows errornously returns EINVAL when no fd sets have been
172 * provided (this is documented). what microsoft doesn't tell you that this bug 181 * provided (this is documented). what microsoft doesn't tell you that this bug
173 * exists even when the fd sets are provided, so we have to check for this bug 182 * exists even when the fd sets _are_ provided, so we have to check for this bug
174 * here and emulate by sleeping manually. 183 * here and emulate by sleeping manually.
175 * we also get EINVAL when the timeout is invalid, but we ignore this case here 184 * we also get EINVAL when the timeout is invalid, but we ignore this case here
176 * and assume that EINVAL always means: you have to wait manually. 185 * and assume that EINVAL always means: you have to wait manually.
177 */ 186 */
178 if (errno == EINVAL) 187 if (errno == EINVAL)
185 if (errno == EBADF) 194 if (errno == EBADF)
186 fd_ebadf (EV_A); 195 fd_ebadf (EV_A);
187 else if (errno == ENOMEM && !syserr_cb) 196 else if (errno == ENOMEM && !syserr_cb)
188 fd_enomem (EV_A); 197 fd_enomem (EV_A);
189 else if (errno != EINTR) 198 else if (errno != EINTR)
190 syserr ("(libev) select"); 199 ev_syserr ("(libev) select");
191 200
192 return; 201 return;
193 } 202 }
194 203
195#if EV_SELECT_USE_FD_SET 204#if EV_SELECT_USE_FD_SET

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines