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.22 by root, Fri Nov 23 05:13:49 2007 UTC vs.
Revision 1.24 by root, Sun Dec 9 02:12:44 2007 UTC

88#else 88#else
89 89
90 int word = fd / NFDBITS; 90 int word = fd / NFDBITS;
91 int mask = 1UL << (fd % NFDBITS); 91 int mask = 1UL << (fd % NFDBITS);
92 92
93 if (vec_max < word + 1) 93 if (expect_false (vec_max < word + 1))
94 { 94 {
95 int new_max = word + 1; 95 int new_max = word + 1;
96 96
97 vec_ri = ev_realloc (vec_ri, new_max * NFDBYTES); 97 vec_ri = ev_realloc (vec_ri, new_max * NFDBYTES);
98 vec_ro = ev_realloc (vec_ro, new_max * NFDBYTES); /* could free/malloc */ 98 vec_ro = ev_realloc (vec_ro, new_max * NFDBYTES); /* could free/malloc */
132 tv.tv_sec = (long)timeout; 132 tv.tv_sec = (long)timeout;
133 tv.tv_usec = (long)((timeout - (ev_tstamp)tv.tv_sec) * 1e6); 133 tv.tv_usec = (long)((timeout - (ev_tstamp)tv.tv_sec) * 1e6);
134 134
135 res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv); 135 res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv);
136 136
137 if (res < 0) 137 if (expect_false (res < 0))
138 { 138 {
139 #if EV_SELECT_IS_WINSOCKET 139 #if EV_SELECT_IS_WINSOCKET
140 errno = WSAGetLastError (); 140 errno = WSAGetLastError ();
141 #endif 141 #endif
142 142
166 #endif 166 #endif
167 167
168 if (FD_ISSET (handle, (fd_set *)vec_ro)) events |= EV_READ; 168 if (FD_ISSET (handle, (fd_set *)vec_ro)) events |= EV_READ;
169 if (FD_ISSET (handle, (fd_set *)vec_wo)) events |= EV_WRITE; 169 if (FD_ISSET (handle, (fd_set *)vec_wo)) events |= EV_WRITE;
170 170
171 if (events) 171 if (expect_true (events))
172 fd_event (EV_A_ fd, events); 172 fd_event (EV_A_ fd, events);
173 } 173 }
174 } 174 }
175 175
176#else 176#else
189 int events = 0; 189 int events = 0;
190 190
191 events |= word_r & mask ? EV_READ : 0; 191 events |= word_r & mask ? EV_READ : 0;
192 events |= word_w & mask ? EV_WRITE : 0; 192 events |= word_w & mask ? EV_WRITE : 0;
193 193
194 if (events) 194 if (expect_true (events))
195 fd_event (EV_A_ word * NFDBITS + bit, events); 195 fd_event (EV_A_ word * NFDBITS + bit, events);
196 } 196 }
197 } 197 }
198 } 198 }
199 199
200#endif 200#endif
201} 201}
202 202
203static int 203int inline_size
204select_init (EV_P_ int flags) 204select_init (EV_P_ int flags)
205{ 205{
206 backend_fudge = 1e-2; /* needed to compensate for select returning early, very conservative */ 206 backend_fudge = 1e-2; /* needed to compensate for select returning early, very conservative */
207 backend_modify = select_modify; 207 backend_modify = select_modify;
208 backend_poll = select_poll; 208 backend_poll = select_poll;
222#endif 222#endif
223 223
224 return EVBACKEND_SELECT; 224 return EVBACKEND_SELECT;
225} 225}
226 226
227static void 227void inline_size
228select_destroy (EV_P) 228select_destroy (EV_P)
229{ 229{
230 ev_free (vec_ri); 230 ev_free (vec_ri);
231 ev_free (vec_ro); 231 ev_free (vec_ro);
232 ev_free (vec_wi); 232 ev_free (vec_wi);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines