Lines Matching refs:sop
106 static int select_resize(struct selectop *sop, int fdsz);
107 static void select_free_selectop(struct selectop *sop);
112 struct selectop *sop; in select_init() local
114 if (!(sop = mm_calloc(1, sizeof(struct selectop)))) in select_init()
117 if (select_resize(sop, SELECT_ALLOC_SIZE(32 + 1))) { in select_init()
118 select_free_selectop(sop); in select_init()
126 return (sop); in select_init()
131 check_selectop(struct selectop *sop) in check_selectop() argument
136 #define check_selectop(sop) do { (void) sop; } while (0) argument
143 struct selectop *sop = base->evbase; in select_dispatch() local
145 check_selectop(sop); in select_dispatch()
146 if (sop->resize_out_sets) { in select_dispatch()
148 size_t sz = sop->event_fdsz; in select_dispatch()
149 if (!(readset_out = mm_realloc(sop->event_readset_out, sz))) in select_dispatch()
151 sop->event_readset_out = readset_out; in select_dispatch()
152 if (!(writeset_out = mm_realloc(sop->event_writeset_out, sz))) { in select_dispatch()
159 sop->event_writeset_out = writeset_out; in select_dispatch()
160 sop->resize_out_sets = 0; in select_dispatch()
163 memcpy(sop->event_readset_out, sop->event_readset_in, in select_dispatch()
164 sop->event_fdsz); in select_dispatch()
165 memcpy(sop->event_writeset_out, sop->event_writeset_in, in select_dispatch()
166 sop->event_fdsz); in select_dispatch()
168 nfds = sop->event_fds+1; in select_dispatch()
172 res = select(nfds, sop->event_readset_out, in select_dispatch()
173 sop->event_writeset_out, NULL, tv); in select_dispatch()
177 check_selectop(sop); in select_dispatch()
190 check_selectop(sop); in select_dispatch()
196 if (FD_ISSET(i, sop->event_readset_out)) in select_dispatch()
198 if (FD_ISSET(i, sop->event_writeset_out)) in select_dispatch()
206 check_selectop(sop); in select_dispatch()
212 select_resize(struct selectop *sop, int fdsz) in select_resize() argument
217 if (sop->event_readset_in) in select_resize()
218 check_selectop(sop); in select_resize()
220 if ((readset_in = mm_realloc(sop->event_readset_in, fdsz)) == NULL) in select_resize()
222 sop->event_readset_in = readset_in; in select_resize()
223 if ((writeset_in = mm_realloc(sop->event_writeset_in, fdsz)) == NULL) { in select_resize()
232 sop->event_writeset_in = writeset_in; in select_resize()
233 sop->resize_out_sets = 1; in select_resize()
235 memset((char *)sop->event_readset_in + sop->event_fdsz, 0, in select_resize()
236 fdsz - sop->event_fdsz); in select_resize()
237 memset((char *)sop->event_writeset_in + sop->event_fdsz, 0, in select_resize()
238 fdsz - sop->event_fdsz); in select_resize()
240 sop->event_fdsz = fdsz; in select_resize()
241 check_selectop(sop); in select_resize()
254 struct selectop *sop = base->evbase; in select_add() local
258 check_selectop(sop); in select_add()
263 if (sop->event_fds < fd) { in select_add()
264 int fdsz = sop->event_fdsz; in select_add()
275 if (fdsz != sop->event_fdsz) { in select_add()
276 if (select_resize(sop, fdsz)) { in select_add()
277 check_selectop(sop); in select_add()
282 sop->event_fds = fd; in select_add()
286 FD_SET(fd, sop->event_readset_in); in select_add()
288 FD_SET(fd, sop->event_writeset_in); in select_add()
289 check_selectop(sop); in select_add()
301 struct selectop *sop = base->evbase; in select_del() local
305 check_selectop(sop); in select_del()
307 if (sop->event_fds < fd) { in select_del()
308 check_selectop(sop); in select_del()
313 FD_CLR(fd, sop->event_readset_in); in select_del()
316 FD_CLR(fd, sop->event_writeset_in); in select_del()
318 check_selectop(sop); in select_del()
323 select_free_selectop(struct selectop *sop) in select_free_selectop() argument
325 if (sop->event_readset_in) in select_free_selectop()
326 mm_free(sop->event_readset_in); in select_free_selectop()
327 if (sop->event_writeset_in) in select_free_selectop()
328 mm_free(sop->event_writeset_in); in select_free_selectop()
329 if (sop->event_readset_out) in select_free_selectop()
330 mm_free(sop->event_readset_out); in select_free_selectop()
331 if (sop->event_writeset_out) in select_free_selectop()
332 mm_free(sop->event_writeset_out); in select_free_selectop()
334 memset(sop, 0, sizeof(struct selectop)); in select_free_selectop()
335 mm_free(sop); in select_free_selectop()