4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (c) 1995-1999 by Internet Software Consortium
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 /* eventlib.c - implement glue for the eventlib
21 * vix 09sep95 [initial]
24 #if !defined(LINT) && !defined(CODECENTER)
25 static const char rcsid
[] = "Id: eventlib.c,v 1.10 2006/03/09 23:57:56 marka Exp";
28 #include "port_before.h"
29 #include "fd_setsize.h"
31 #include <sys/types.h>
44 #include <isc/eventlib.h>
45 #include <isc/assertions.h>
46 #include "eventlib_p.h"
48 #include "port_after.h"
53 #define pselect Pselect
58 #if defined(NEED_PSELECT) || defined(USE_POLL)
59 static int pselect(int, void *, void *, void *,
69 evCreate(evContext
*opaqueCtx
) {
72 /* Make sure the memory heap is initialized. */
73 if (meminit(0, 0) < 0 && errno
!= EEXIST
)
87 INIT_LIST(ctx
->accepts
);
95 emulMaskInit(ctx
, rdLast
, EV_READ
, 1);
96 emulMaskInit(ctx
, rdNext
, EV_READ
, 0);
97 emulMaskInit(ctx
, wrLast
, EV_WRITE
, 1);
98 emulMaskInit(ctx
, wrNext
, EV_WRITE
, 0);
99 emulMaskInit(ctx
, exLast
, EV_EXCEPT
, 1);
100 emulMaskInit(ctx
, exNext
, EV_EXCEPT
, 0);
101 emulMaskInit(ctx
, nonblockBefore
, EV_WASNONBLOCKING
, 0);
102 #endif /* USE_POLL */
103 FD_ZERO(&ctx
->rdNext
);
104 FD_ZERO(&ctx
->wrNext
);
105 FD_ZERO(&ctx
->exNext
);
106 FD_ZERO(&ctx
->nonblockBefore
);
109 ctx
->fdCount
= 0; /*%< Invalidate {rd,wr,ex}Last. */
111 ctx
->highestFD
= FD_SETSIZE
- 1;
112 memset(ctx
->fdTable
, 0, sizeof ctx
->fdTable
);
114 ctx
->highestFD
= INT_MAX
/ sizeof(struct pollfd
);
116 #endif /* USE_POLL */
117 #ifdef EVENTLIB_TIME_CHECKS
118 ctx
->lastFdCount
= 0;
127 ctx
->lastEventTime
= evNowTime();
128 #ifdef EVENTLIB_TIME_CHECKS
129 ctx
->lastSelectTime
= ctx
->lastEventTime
;
131 ctx
->timers
= evCreateTimers(ctx
);
132 if (ctx
->timers
== NULL
)
136 ctx
->waitLists
= NULL
;
137 ctx
->waitDone
.first
= ctx
->waitDone
.last
= NULL
;
138 ctx
->waitDone
.prev
= ctx
->waitDone
.next
= NULL
;
140 opaqueCtx
->opaque
= ctx
;
145 evSetDebug(evContext opaqueCtx
, int level
, FILE *output
) {
146 evContext_p
*ctx
= opaqueCtx
.opaque
;
149 ctx
->output
= output
;
153 evDestroy(evContext opaqueCtx
) {
154 evContext_p
*ctx
= opaqueCtx
.opaque
;
155 int revs
= 424242; /*%< Doug Adams. */
156 evWaitList
*this_wl
, *next_wl
;
157 evWait
*this_wait
, *next_wait
;
160 while (revs
-- > 0 && ctx
->conns
!= NULL
) {
163 id
.opaque
= ctx
->conns
;
164 (void) evCancelConn(opaqueCtx
, id
);
169 while (revs
-- > 0 && ctx
->streams
!= NULL
) {
172 id
.opaque
= ctx
->streams
;
173 (void) evCancelRW(opaqueCtx
, id
);
177 while (revs
-- > 0 && ctx
->files
!= NULL
) {
180 id
.opaque
= ctx
->files
;
181 (void) evDeselectFD(opaqueCtx
, id
);
186 evDestroyTimers(ctx
);
189 for (this_wl
= ctx
->waitLists
;
190 revs
-- > 0 && this_wl
!= NULL
;
192 next_wl
= this_wl
->next
;
193 for (this_wait
= this_wl
->first
;
194 revs
-- > 0 && this_wait
!= NULL
;
195 this_wait
= next_wait
) {
196 next_wait
= this_wait
->next
;
201 for (this_wait
= ctx
->waitDone
.first
;
202 revs
-- > 0 && this_wait
!= NULL
;
203 this_wait
= next_wait
) {
204 next_wait
= this_wait
->next
;
213 evGetNext(evContext opaqueCtx
, evEvent
*opaqueEv
, int options
) {
214 evContext_p
*ctx
= opaqueCtx
.opaque
;
215 struct timespec nextTime
;
218 int x
, pselect_errno
, timerPast
;
219 #ifdef EVENTLIB_TIME_CHECKS
220 struct timespec interval
;
223 /* Ensure that exactly one of EV_POLL or EV_WAIT was specified. */
224 x
= ((options
& EV_POLL
) != 0) + ((options
& EV_WAIT
) != 0);
228 /* Get the time of day. We'll do this again after select() blocks. */
229 ctx
->lastEventTime
= evNowTime();
232 /* Finished accept()'s do not require a select(). */
233 if (!EMPTY(ctx
->accepts
)) {
236 new->u
.accept
.this = HEAD(ctx
->accepts
);
237 UNLINK(ctx
->accepts
, HEAD(ctx
->accepts
), link
);
238 opaqueEv
->opaque
= new;
242 /* Stream IO does not require a select(). */
243 if (ctx
->strDone
!= NULL
) {
246 new->u
.stream
.this = ctx
->strDone
;
247 ctx
->strDone
= ctx
->strDone
->nextDone
;
248 if (ctx
->strDone
== NULL
)
250 opaqueEv
->opaque
= new;
254 /* Waits do not require a select(). */
255 if (ctx
->waitDone
.first
!= NULL
) {
258 new->u
.wait
.this = ctx
->waitDone
.first
;
259 ctx
->waitDone
.first
= ctx
->waitDone
.first
->next
;
260 if (ctx
->waitDone
.first
== NULL
)
261 ctx
->waitDone
.last
= NULL
;
262 opaqueEv
->opaque
= new;
266 /* Get the status and content of the next timer. */
267 if ((nextTimer
= heap_element(ctx
->timers
, 1)) != NULL
) {
268 nextTime
= nextTimer
->due
;
269 timerPast
= (evCmpTime(nextTime
, ctx
->lastEventTime
) <= 0);
271 timerPast
= 0; /*%< Make gcc happy. */
272 evPrintf(ctx
, 9, "evGetNext: fdCount %d\n", ctx
->fdCount
);
273 if (ctx
->fdCount
== 0) {
274 static const struct timespec NoTime
= {0, 0L};
275 enum { JustPoll
, Block
, Timer
} m
;
276 struct timespec t
, *tp
;
278 /* Are there any events at all? */
279 if ((options
& EV_WAIT
) != 0 && !nextTimer
&& ctx
->fdMax
== -1)
282 /* Figure out what select()'s timeout parameter should be. */
283 if ((options
& EV_POLL
) != 0) {
287 } else if (nextTimer
== NULL
) {
291 } else if (timerPast
) {
297 /* ``t'' filled in later. */
300 #ifdef EVENTLIB_TIME_CHECKS
301 if (ctx
->debug
> 0) {
302 interval
= evSubTime(ctx
->lastEventTime
,
303 ctx
->lastSelectTime
);
304 if (interval
.tv_sec
> 0 || interval
.tv_nsec
> 0)
306 "time between pselect() %u.%09u count %d\n",
307 interval
.tv_sec
, interval
.tv_nsec
,
313 /* XXX need to copy only the bits we are using. */
314 ctx
->rdLast
= ctx
->rdNext
;
315 ctx
->wrLast
= ctx
->wrNext
;
316 ctx
->exLast
= ctx
->exNext
;
319 * The pollfd structure uses separate fields for
320 * the input and output events (corresponding to
321 * the ??Next and ??Last fd sets), so there's no
322 * need to copy one to the other.
324 #endif /* USE_POLL */
327 t
= evSubTime(nextTime
, ctx
->lastEventTime
);
330 /* XXX should predict system's earliness and adjust. */
331 x
= pselect(ctx
->fdMax
+1,
332 &ctx
->rdLast
, &ctx
->wrLast
, &ctx
->exLast
,
334 pselect_errno
= errno
;
337 evPrintf(ctx
, 4, "select() returns %d (err: %s)\n",
338 x
, (x
== -1) ? strerror(errno
) : "none");
340 evPrintf(ctx
, 4, "poll() returns %d (err: %s)\n",
341 x
, (x
== -1) ? strerror(errno
) : "none");
342 #endif /* USE_POLL */
343 /* Anything but a poll can change the time. */
345 ctx
->lastEventTime
= evNowTime();
347 /* Select() likes to finish about 10ms early. */
348 } while (x
== 0 && m
== Timer
&&
349 evCmpTime(ctx
->lastEventTime
, nextTime
) < 0);
350 #ifdef EVENTLIB_TIME_CHECKS
351 ctx
->lastSelectTime
= ctx
->lastEventTime
;
354 if (pselect_errno
== EINTR
) {
355 if ((options
& EV_NULL
) != 0)
360 opaqueEv
->opaque
= new;
363 if (pselect_errno
== EBADF
) {
364 for (x
= 0; x
<= ctx
->fdMax
; x
++) {
367 if (FD_ISSET(x
, &ctx
->rdNext
) == 0 &&
368 FD_ISSET(x
, &ctx
->wrNext
) == 0 &&
369 FD_ISSET(x
, &ctx
->exNext
) == 0)
371 if (fstat(x
, &sb
) == -1 &&
373 evPrintf(ctx
, 1, "EBADF: %d\n",
378 EV_ERR(pselect_errno
);
380 if (x
== 0 && (nextTimer
== NULL
|| !timerPast
) &&
384 #ifdef EVENTLIB_TIME_CHECKS
385 ctx
->lastFdCount
= x
;
388 INSIST(nextTimer
|| ctx
->fdCount
);
390 /* Timers go first since we'd like them to be accurate. */
391 if (nextTimer
&& !timerPast
) {
392 /* Has anything happened since we blocked? */
393 timerPast
= (evCmpTime(nextTime
, ctx
->lastEventTime
) <= 0);
395 if (nextTimer
&& timerPast
) {
398 new->u
.timer
.this = nextTimer
;
399 opaqueEv
->opaque
= new;
403 /* No timers, so there should be a ready file descriptor. */
405 while (ctx
->fdCount
> 0) {
409 if (ctx
->fdNext
== NULL
) {
412 * Hitting the end twice means that the last
413 * select() found some FD's which have since
416 * On some systems, the count returned by
417 * selects is the total number of bits in
418 * all masks that are set, and on others it's
419 * the number of fd's that have some bit set,
420 * and on others, it's just broken. We
421 * always assume that it's the number of
422 * bits set in all masks, because that's what
423 * the man page says it should do, and
424 * the worst that can happen is we do an
430 ctx
->fdNext
= ctx
->files
;
433 ctx
->fdNext
= fid
->next
;
437 if (FD_ISSET(fd
, &ctx
->rdLast
))
438 eventmask
|= EV_READ
;
439 if (FD_ISSET(fd
, &ctx
->wrLast
))
440 eventmask
|= EV_WRITE
;
441 if (FD_ISSET(fd
, &ctx
->exLast
))
442 eventmask
|= EV_EXCEPT
;
443 eventmask
&= fid
->eventmask
;
444 if (eventmask
!= 0) {
445 if ((eventmask
& EV_READ
) != 0) {
446 FD_CLR(fd
, &ctx
->rdLast
);
449 if ((eventmask
& EV_WRITE
) != 0) {
450 FD_CLR(fd
, &ctx
->wrLast
);
453 if ((eventmask
& EV_EXCEPT
) != 0) {
454 FD_CLR(fd
, &ctx
->exLast
);
459 new->u
.file
.this = fid
;
460 new->u
.file
.eventmask
= eventmask
;
461 opaqueEv
->opaque
= new;
465 if (ctx
->fdCount
< 0) {
467 * select()'s count is off on a number of systems, and
468 * can result in fdCount < 0.
470 evPrintf(ctx
, 4, "fdCount < 0 (%d)\n", ctx
->fdCount
);
474 /* We get here if the caller deselect()'s an FD. Gag me with a goto. */
479 evDispatch(evContext opaqueCtx
, evEvent opaqueEv
) {
480 evContext_p
*ctx
= opaqueCtx
.opaque
;
481 evEvent_p
*ev
= opaqueEv
.opaque
;
482 #ifdef EVENTLIB_TIME_CHECKS
484 struct timespec start_time
;
485 struct timespec interval
;
488 #ifdef EVENTLIB_TIME_CHECKS
490 start_time
= evNowTime();
495 evAccept
*this = ev
->u
.accept
.this;
498 "Dispatch.Accept: fd %d -> %d, func %p, uap %p\n",
499 this->conn
->fd
, this->fd
,
500 this->conn
->func
, this->conn
->uap
);
501 errno
= this->ioErrno
;
502 (this->conn
->func
)(opaqueCtx
, this->conn
->uap
, this->fd
,
503 &this->la
, this->lalen
,
504 &this->ra
, this->ralen
);
505 #ifdef EVENTLIB_TIME_CHECKS
506 func
= this->conn
->func
;
511 evFile
*this = ev
->u
.file
.this;
512 int eventmask
= ev
->u
.file
.eventmask
;
515 "Dispatch.File: fd %d, mask 0x%x, func %p, uap %p\n",
516 this->fd
, this->eventmask
, this->func
, this->uap
);
517 (this->func
)(opaqueCtx
, this->uap
, this->fd
, eventmask
);
518 #ifdef EVENTLIB_TIME_CHECKS
524 evStream
*this = ev
->u
.stream
.this;
527 "Dispatch.Stream: fd %d, func %p, uap %p\n",
528 this->fd
, this->func
, this->uap
);
529 errno
= this->ioErrno
;
530 (this->func
)(opaqueCtx
, this->uap
, this->fd
, this->ioDone
);
531 #ifdef EVENTLIB_TIME_CHECKS
537 evTimer
*this = ev
->u
.timer
.this;
539 evPrintf(ctx
, 5, "Dispatch.Timer: func %p, uap %p\n",
540 this->func
, this->uap
);
541 (this->func
)(opaqueCtx
, this->uap
, this->due
, this->inter
);
542 #ifdef EVENTLIB_TIME_CHECKS
548 evWait
*this = ev
->u
.wait
.this;
551 "Dispatch.Wait: tag %p, func %p, uap %p\n",
552 this->tag
, this->func
, this->uap
);
553 (this->func
)(opaqueCtx
, this->uap
, this->tag
);
554 #ifdef EVENTLIB_TIME_CHECKS
561 #ifdef EVENTLIB_TIME_CHECKS
570 #ifdef EVENTLIB_TIME_CHECKS
571 if (ctx
->debug
> 0) {
572 interval
= evSubTime(evNowTime(), start_time
);
574 * Complain if it took longer than 50 milliseconds.
576 * We call getuid() to make an easy to find mark in a kernel
579 if (interval
.tv_sec
> 0 || interval
.tv_nsec
> 50000000)
581 "dispatch interval %u.%09u uid %d type %d func %p\n",
582 interval
.tv_sec
, interval
.tv_nsec
,
583 getuid(), ev
->type
, func
);
587 evDrop(opaqueCtx
, opaqueEv
);
592 evDrop(evContext opaqueCtx
, evEvent opaqueEv
) {
593 evContext_p
*ctx
= opaqueCtx
.opaque
;
594 evEvent_p
*ev
= opaqueEv
.opaque
;
598 FREE(ev
->u
.accept
.this);
608 id
.opaque
= ev
->u
.stream
.this;
609 (void) evCancelRW(opaqueCtx
, id
);
613 evTimer
*this = ev
->u
.timer
.this;
616 /* Check to see whether the user func cleared the timer. */
617 if (heap_element(ctx
->timers
, this->index
) != this) {
618 evPrintf(ctx
, 5, "Dispatch.Timer: timer rm'd?\n");
622 * Timer is still there. Delete it if it has expired,
623 * otherwise set it according to its next interval.
625 if (this->inter
.tv_sec
== (time_t)0 &&
626 this->inter
.tv_nsec
== 0L) {
627 opaque
.opaque
= this;
628 (void) evClearTimer(opaqueCtx
, opaque
);
630 opaque
.opaque
= this;
631 (void) evResetTimer(opaqueCtx
, opaque
, this->func
,
633 evAddTime((this->mode
& EV_TMR_RATE
) ?
642 FREE(ev
->u
.wait
.this);
657 evMainLoop(evContext opaqueCtx
) {
661 while ((x
= evGetNext(opaqueCtx
, &event
, EV_WAIT
)) == 0)
662 if ((x
= evDispatch(opaqueCtx
, event
)) < 0)
668 evHighestFD(evContext opaqueCtx
) {
669 evContext_p
*ctx
= opaqueCtx
.opaque
;
671 return (ctx
->highestFD
);
675 evPrintf(const evContext_p
*ctx
, int level
, const char *fmt
, ...) {
679 if (ctx
->output
!= NULL
&& ctx
->debug
>= level
) {
680 vfprintf(ctx
->output
, fmt
, ap
);
687 evSetOption(evContext
*opaqueCtx
, const char *option
, int value
) {
688 /* evContext_p *ctx = opaqueCtx->opaque; */
692 #ifndef CLOCK_MONOTONIC
696 #ifdef CLOCK_MONOTONIC
697 if (strcmp(option
, "monotime") == 0) {
698 if (opaqueCtx
!= NULL
)
700 if (value
== 0 || value
== 1) {
701 __evOptMonoTime
= value
;
714 evGetOption(evContext
*opaqueCtx
, const char *option
, int *value
) {
715 /* evContext_p *ctx = opaqueCtx->opaque; */
718 #ifndef CLOCK_MONOTONIC
723 #ifdef CLOCK_MONOTONIC
724 if (strcmp(option
, "monotime") == 0) {
725 if (opaqueCtx
!= NULL
)
727 *value
= __evOptMonoTime
;
735 #if defined(NEED_PSELECT) || defined(USE_POLL)
736 /* XXX needs to move to the porting library. */
738 pselect(int nfds
, void *rfds
, void *wfds
, void *efds
,
739 struct timespec
*tsp
,
740 const sigset_t
*sigmask
)
742 struct timeval tv
, *tvp
;
746 int polltimeout
= INFTIM
;
752 #endif /* USE_POLL */
756 tv
= evTimeVal(*tsp
);
758 polltimeout
= 1000 * tv
.tv_sec
+ tv
.tv_usec
/ 1000;
759 #endif /* USE_POLL */
763 sigprocmask(SIG_SETMASK
, sigmask
, &sigs
);
765 n
= select(nfds
, rfds
, wfds
, efds
, tvp
);
768 * rfds, wfds, and efds should all be from the same evContext_p,
769 * so any of them will do. If they're all NULL, the caller is
770 * presumably calling us to block.
773 ctx
= ((__evEmulMask
*)rfds
)->ctx
;
774 else if (wfds
!= NULL
)
775 ctx
= ((__evEmulMask
*)wfds
)->ctx
;
776 else if (efds
!= NULL
)
777 ctx
= ((__evEmulMask
*)efds
)->ctx
;
780 if (ctx
!= NULL
&& ctx
->fdMax
!= -1) {
781 fds
= &(ctx
->pollfds
[ctx
->firstfd
]);
782 pnfds
= ctx
->fdMax
- ctx
->firstfd
+ 1;
787 n
= poll(fds
, pnfds
, polltimeout
);
792 for (e
= 0, i
= ctx
->firstfd
; i
<= ctx
->fdMax
; i
++) {
793 if (ctx
->pollfds
[i
].fd
< 0)
795 if (FD_ISSET(i
, &ctx
->rdLast
))
797 if (FD_ISSET(i
, &ctx
->wrLast
))
799 if (FD_ISSET(i
, &ctx
->exLast
))
804 #endif /* USE_POLL */
806 sigprocmask(SIG_SETMASK
, &sigs
, NULL
);
808 *tsp
= evTimeSpec(tv
);
815 evPollfdRealloc(evContext_p
*ctx
, int pollfd_chunk_size
, int fd
) {
818 void *pollfds
, *fdTable
;
820 if (fd
< ctx
->maxnfds
)
823 /* Don't allow ridiculously small values for pollfd_chunk_size */
824 if (pollfd_chunk_size
< 20)
825 pollfd_chunk_size
= 20;
827 maxnfds
= (1 + (fd
/pollfd_chunk_size
)) * pollfd_chunk_size
;
829 pollfds
= realloc(ctx
->pollfds
, maxnfds
* sizeof(*ctx
->pollfds
));
831 ctx
->pollfds
= pollfds
;
832 fdTable
= realloc(ctx
->fdTable
, maxnfds
* sizeof(*ctx
->fdTable
));
834 ctx
->fdTable
= fdTable
;
836 if (pollfds
== NULL
|| fdTable
== NULL
) {
837 evPrintf(ctx
, 2, "pollfd() realloc (%ld) failed\n",
838 (long)maxnfds
*sizeof(struct pollfd
));
842 for (i
= ctx
->maxnfds
; i
< maxnfds
; i
++) {
843 ctx
->pollfds
[i
].fd
= -1;
844 ctx
->pollfds
[i
].events
= 0;
848 ctx
->maxnfds
= maxnfds
;
853 /* Find the appropriate 'events' or 'revents' field in the pollfds array */
855 __fd_eventfield(int fd
, __evEmulMask
*maskp
) {
857 evContext_p
*ctx
= (evContext_p
*)maskp
->ctx
;
859 if (!maskp
->result
|| maskp
->type
== EV_WASNONBLOCKING
)
860 return (&(ctx
->pollfds
[fd
].events
));
862 return (&(ctx
->pollfds
[fd
].revents
));
865 /* Translate to poll(2) event */
867 __poll_event(__evEmulMask
*maskp
) {
869 switch ((maskp
)->type
) {
875 return (POLLRDBAND
| POLLPRI
| POLLWRBAND
);
876 case EV_WASNONBLOCKING
:
884 * Clear the events corresponding to the specified mask. If this leaves
885 * the events mask empty (apart from the POLLHUP bit), set the fd field
886 * to -1 so that poll(2) will ignore this fd.
889 __fd_clr(int fd
, __evEmulMask
*maskp
) {
891 evContext_p
*ctx
= maskp
->ctx
;
893 *__fd_eventfield(fd
, maskp
) &= ~__poll_event(maskp
);
894 if ((ctx
->pollfds
[fd
].events
& ~POLLHUP
) == 0) {
895 ctx
->pollfds
[fd
].fd
= -1;
896 if (fd
== ctx
->fdMax
)
897 while (ctx
->fdMax
> ctx
->firstfd
&&
898 ctx
->pollfds
[ctx
->fdMax
].fd
< 0)
900 if (fd
== ctx
->firstfd
)
901 while (ctx
->firstfd
<= ctx
->fdMax
&&
902 ctx
->pollfds
[ctx
->firstfd
].fd
< 0)
905 * Do we have a empty set of descriptors?
907 if (ctx
->firstfd
> ctx
->fdMax
) {
915 * Set the events bit(s) corresponding to the specified mask. If the events
916 * field has any other bits than POLLHUP set, also set the fd field so that
917 * poll(2) will watch this fd.
920 __fd_set(int fd
, __evEmulMask
*maskp
) {
922 evContext_p
*ctx
= maskp
->ctx
;
924 *__fd_eventfield(fd
, maskp
) |= __poll_event(maskp
);
925 if ((ctx
->pollfds
[fd
].events
& ~POLLHUP
) != 0) {
926 ctx
->pollfds
[fd
].fd
= fd
;
927 if (fd
< ctx
->firstfd
|| ctx
->fdMax
== -1)
933 #endif /* USE_POLL */