int max_fd = 0;
for (fde = ev->fd_events; fde != NULL; fde = fde->next) {
- if (fde->flags & (EVENT_FD_READ|EVENT_FD_WRITE)) {
+ if (fde->flags != 0) {
num_fds += 1;
if (fde->fd > max_fd) {
max_fd = fde->fd;
for (fde = ev->fd_events; fde; fde = fde->next) {
struct pollfd *pfd;
- if ((fde->flags & (EVENT_FD_READ|EVENT_FD_WRITE)) == 0) {
+ if (fde->flags == 0) {
continue;
}
pfd->fd = fde->fd;
- if (fde->flags & EVENT_FD_READ) {
- pfd->events |= (POLLIN|POLLHUP);
+ /*
+ * we do not need to specify POLLERR | POLLHUP
+ * they are always reported.
+ */
+ if (fde->flags & TEVENT_FD_READ) {
+ pfd->events |= POLLIN;
}
- if (fde->flags & EVENT_FD_WRITE) {
+ if (fde->flags & TEVENT_FD_WRITE) {
pfd->events |= POLLOUT;
}
}
and remove the writable flag, as we only
report errors when waiting for read events
to match the select behavior. */
- if (!(fde->flags & EVENT_FD_READ)) {
- EVENT_FD_NOT_WRITEABLE(fde);
+ if ((fde->flags & ~TEVENT_FD_WRITE) == 0) {
+ TEVENT_FD_NOT_WRITEABLE(fde);
continue;
}
- flags |= EVENT_FD_READ;
+ if (fde->flags & TEVENT_FD_ERROR) {
+ flags |= TEVENT_FD_ERROR;
+ }
+ if (fde->flags & TEVENT_FD_READ) {
+ flags |= TEVENT_FD_READ;
+ }
}
if (pfd->revents & POLLIN) {
- flags |= EVENT_FD_READ;
+ flags |= TEVENT_FD_READ;
}
if (pfd->revents & POLLOUT) {
- flags |= EVENT_FD_WRITE;
+ flags |= TEVENT_FD_WRITE;
}
if (flags & fde->flags) {
DLIST_DEMOTE(ev->fd_events, fde, struct tevent_fd);