projects
/
srvx.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d1d47b2
)
Make the kqueue ioset back-end less whiny.
author
Michael Poole
<mdpoole@troilus.org>
Tue, 11 Aug 2009 03:56:03 +0000
(23:56 -0400)
committer
Michael Poole
<mdpoole@troilus.org>
Tue, 11 Aug 2009 03:56:03 +0000
(23:56 -0400)
src/ioset-kevent.c (ioset_kevent_add): Never try to use EV_DELETE, because
that can make kevent() return -1/ENOENT.
(ioset_kevent_update): We need to try to EV_DELETE here instead.
(ioset_kevent_loop): Do not bail if kevent() just returns -1/EINTR.
src/ioset-kevent.c
patch
|
blob
|
history
diff --git
a/src/ioset-kevent.c
b/src/ioset-kevent.c
index 5d6f0bbb10463c36634cdbfdb3e455a057986f95..d657082257b72aa0b01e8141affaf5c898359146 100644
(file)
--- a/
src/ioset-kevent.c
+++ b/
src/ioset-kevent.c
@@
-46,7
+46,9
@@
ioset_kevent_add(struct io_fd *fd)
int res;
EV_SET(&changes[nchanges++], fd->fd, EVFILT_READ, EV_ADD, 0, 0, fd);
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));
res = kevent(kq_fd, changes, nchanges, NULL, 0, NULL);
if (res < 0) {
log_module(MAIN_LOG, LOG_ERROR, "kevent() add failed: %s", strerror(errno));
@@
-73,7
+75,16
@@
ioset_kevent_remove(struct io_fd *fd, int closed)
static void
ioset_kevent_update(struct io_fd *fd)
{
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
}
static void
@@
-102,7
+113,7
@@
ioset_kevent_loop(struct timeval *timeout)
pts = NULL;
}
res = kevent(kq_fd, NULL, 0, events, MAX_EVENTS, pts);
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;
}
log_module(MAIN_LOG, LOG_ERROR, "kevent() poll failed: %s", strerror(errno));
return 1;
}