Lines Matching defs:fd

42 static evFile *FindFD(const evContext_p *ctx, int fd, int eventmask);
46 int fd,
57 "evSelectFD(ctx %p, fd %d, mask 0x%x, func %p, uap %p)\n",
58 ctx, fd, eventmask, func, uap);
62 if (fd > ctx->highestFD)
65 OK(mode = fcntl(fd, F_GETFL, NULL)); /*%< side effect: validate fd. */
74 if (fd >= ctx->maxnfds && evPollfdRealloc(ctx, 1, fd) != 0)
77 id = FindFD(ctx, fd, EV_MASK_ALL);
80 FD_SET(fd, &ctx->nonblockBefore);
84 OK(ioctl(fd, FIONBIO, (char *)&on));
86 OK(fcntl(fd, F_SETFL, mode | PORT_NONBLOCK));
88 FD_CLR(fd, &ctx->nonblockBefore);
95 * We cannot usefully capture the same fd event more than once in the
98 if (id != NULL && FindFD(ctx, fd, eventmask) != NULL)
105 id->fd = fd;
112 * ``fd.'' We do not believe these things, so we don't do it.
129 /* Insert into fd table. */
130 if (ctx->fdTable[fd] != NULL)
131 ctx->fdTable[fd]->fdprev = id;
133 id->fdnext = ctx->fdTable[fd];
134 ctx->fdTable[fd] = id;
138 FD_SET(fd, &ctx->rdNext);
140 FD_SET(fd, &ctx->wrNext);
142 FD_SET(fd, &ctx->exNext);
145 if (fd > ctx->fdMax)
146 ctx->fdMax = fd;
168 evPrintf(ctx, 1, "evDeselectFD(fd %d, mask 0x%x)\n",
169 del->fd, del->eventmask);
172 mode = fcntl(del->fd, F_GETFL, NULL);
184 /* Remove from the fd table. */
188 ctx->fdTable[del->fd] = del->fdnext;
195 * earlier, then: restore the fd to blocking status.
197 if (!(cur = FindFD(ctx, del->fd, EV_MASK_ALL)) &&
198 !FD_ISSET(del->fd, &ctx->nonblockBefore) &&
207 (void) ioctl(del->fd, FIONBIO, (char *)&off);
209 (void) fcntl(del->fd, F_SETFL, mode & ~PORT_NONBLOCK);
223 if (cur->fd == del->fd)
228 FD_CLR(del->fd, &ctx->rdNext);
229 if (FD_ISSET(del->fd, &ctx->rdLast)) {
230 FD_CLR(del->fd, &ctx->rdLast);
235 FD_CLR(del->fd, &ctx->wrNext);
236 if (FD_ISSET(del->fd, &ctx->wrLast)) {
237 FD_CLR(del->fd, &ctx->wrLast);
242 FD_CLR(del->fd, &ctx->exNext);
243 if (FD_ISSET(del->fd, &ctx->exLast)) {
244 FD_CLR(del->fd, &ctx->exLast);
250 if (del->fd == ctx->fdMax) {
253 if (cur->fd > ctx->fdMax)
254 ctx->fdMax = cur->fd;
268 FindFD(const evContext_p *ctx, int fd, int eventmask) {
271 for (id = ctx->fdTable[fd]; id != NULL; id = id->fdnext)
272 if (id->fd == fd && (id->eventmask & eventmask) != 0)