*
* srvx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
int res;
EV_SET(&changes[nchanges++], fd->fd, EVFILT_READ, EV_ADD, 0, 0, fd);
- EV_SET(&changes[nchanges++], fd->fd, EVFILT_WRITE, fd_wants_writes(fd) ? EV_ADD : EV_DELETE, 0, 0, fd);
+ if (fd_wants_writes(fd)) {
+ EV_SET(&changes[nchanges++], fd->fd, EVFILT_WRITE, EV_ADD, 0, 0, fd);
+ }
res = kevent(kq_fd, changes, nchanges, NULL, 0, NULL);
if (res < 0) {
log_module(MAIN_LOG, LOG_ERROR, "kevent() add failed: %s", strerror(errno));
static void
ioset_kevent_update(struct io_fd *fd)
{
- ioset_kevent_add(fd);
+ struct kevent changes[2];
+ int nchanges = 0;
+ int res;
+
+ EV_SET(&changes[nchanges++], fd->fd, EVFILT_READ, EV_ADD, 0, 0, fd);
+ EV_SET(&changes[nchanges++], fd->fd, EVFILT_WRITE, fd_wants_writes(fd) ? EV_ADD : EV_DELETE, 0, 0, fd);
+ res = kevent(kq_fd, changes, nchanges, NULL, 0, NULL);
+ if (res < 0) {
+ log_module(MAIN_LOG, LOG_ERROR, "kevent() add failed: %s", strerror(errno));
+ }
}
static void
pts = NULL;
}
res = kevent(kq_fd, NULL, 0, events, MAX_EVENTS, pts);
- if (res < 0) {
+ if ((res < 0) && (errno != EINTR)) {
log_module(MAIN_LOG, LOG_ERROR, "kevent() poll failed: %s", strerror(errno));
return 1;
}