epoll_ctl(internal->epfd, EPOLL_CTL_DEL, task->fd, &fds[i]);
continue;
}
- if (fds[i].events & EPOLLIN)
+ if (fds[i].events & (EPOLLIN | EPOLLPRI | EPOLLHUP | EPOLLERR))
task->revents |= SILC_TASK_READ;
if (fds[i].events & EPOLLOUT)
task->revents |= SILC_TASK_WRITE;
struct epoll_event event;
if (!internal)
- return FALSE;
+ return TRUE;
+
+ SILC_LOG_DEBUG(("Scheduling fd %lu, mask %x", task->fd, event_mask));
event.events = 0;
- if (task->events & SILC_TASK_READ)
+ if (event_mask & SILC_TASK_READ)
event.events |= (EPOLLIN | EPOLLPRI);
- if (task->events & SILC_TASK_WRITE)
+ if (event_mask & SILC_TASK_WRITE)
event.events |= EPOLLOUT;
/* Zero mask unschedules task */
if (silc_unlikely(!event.events)) {
- epoll_ctl(internal->epfd, EPOLL_CTL_DEL, task->fd, &event);
+ if (epoll_ctl(internal->epfd, EPOLL_CTL_DEL, task->fd, &event)) {
+ SILC_LOG_DEBUG(("epoll_ctl (DEL): %s", strerror(errno)));
+ return FALSE;
+ }
return TRUE;
}
/* Schedule the task */
if (silc_unlikely(!task->scheduled)) {
event.data.ptr = task;
- epoll_ctl(internal->epfd, EPOLL_CTL_ADD, task->fd, &event);
+ if (epoll_ctl(internal->epfd, EPOLL_CTL_ADD, task->fd, &event)) {
+ SILC_LOG_DEBUG(("epoll_ctl (ADD): %s", strerror(errno)));
+ return FALSE;
+ }
task->scheduled = TRUE;
return TRUE;
}
/* Schedule for specific mask */
event.data.ptr = task;
- epoll_ctl(internal->epfd, EPOLL_CTL_MOD, task->fd, &event);
+ if (epoll_ctl(internal->epfd, EPOLL_CTL_MOD, task->fd, &event)) {
+ SILC_LOG_DEBUG(("epoll_ctl (MOD): %s", strerror(errno)));
+ return FALSE;
+ }
#endif /* HAVE_EPOLL_WAIT */
return TRUE;
}
#if defined(HAVE_EPOLL_WAIT)
internal->epfd = epoll_create(4);
- if (internal->epfd < 0)
+ if (internal->epfd < 0) {
+ SILC_LOG_ERROR(("epoll_create() failed: %s", strerror(errno)));
return NULL;
+ }
internal->fds = silc_calloc(4, sizeof(*internal->fds));
if (!internal->fds) {
close(internal->epfd);