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.28 by root, Sun Mar 16 16:38:23 2008 UTC vs.
Revision 1.29 by root, Tue May 20 19:26:45 2008 UTC

96#else 96#else
97 97
98 int word = fd / NFDBITS; 98 int word = fd / NFDBITS;
99 fd_mask mask = 1UL << (fd % NFDBITS); 99 fd_mask mask = 1UL << (fd % NFDBITS);
100 100
101 if (expect_false (vec_max < word + 1)) 101 if (expect_false (vec_max <= word))
102 { 102 {
103 int new_max = word + 1; 103 int new_max = word + 1;
104 104
105 vec_ri = ev_realloc (vec_ri, new_max * NFDBYTES); 105 vec_ri = ev_realloc (vec_ri, new_max * NFDBYTES);
106 vec_ro = ev_realloc (vec_ro, new_max * NFDBYTES); /* could free/malloc */ 106 vec_ro = ev_realloc (vec_ro, new_max * NFDBYTES); /* could free/malloc */
144 144
145 if (expect_false (res < 0)) 145 if (expect_false (res < 0))
146 { 146 {
147 #if EV_SELECT_IS_WINSOCKET 147 #if EV_SELECT_IS_WINSOCKET
148 errno = WSAGetLastError (); 148 errno = WSAGetLastError ();
149 #endif
150 #ifdef WSABASEERR
151 /* on windows, select returns incompatible error codes, fix this */
152 if (errno >= WSABASEERR && errno < WSABASEERR + 1000)
153 if (errno == WSAENOTSOCK)
154 errno = EBADF;
155 else
156 errno -= WSABASEERR;
157 #endif
158
159 #ifdef _WIN32
160 /* select on windows errornously returns EINVAL when no fd sets have been
161 * provided (this is documented). what microsoft doesn't tell you that this bug
162 * exists even when the fd sets are provided, so we have to check for this bug
163 * here and emulate by sleeping manually.
164 * we also get EINVAL when the timeout is invalid, but we ignore this case here
165 * and assume that EINVAL always means: you have to wait manually.
166 */
167 if (errno == EINVAL)
168 {
169 ev_sleep (timeout);
170 return;
171 }
149 #endif 172 #endif
150 173
151 if (errno == EBADF) 174 if (errno == EBADF)
152 fd_ebadf (EV_A); 175 fd_ebadf (EV_A);
153 else if (errno == ENOMEM && !syserr_cb) 176 else if (errno == ENOMEM && !syserr_cb)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines