summaryrefslogtreecommitdiff
path: root/epoll.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-07-29 18:12:05 -0400
committerNick Mathewson <nickm@torproject.org>2010-07-29 18:12:04 -0400
commit9e725f72e72cb9b37b39915a260f9aee265f2c59 (patch)
tree8abf4a0bd3460f121fc748a1e0aa5457237a1a61 /epoll.c
parentcc2379d2642d2b9d0cbb1098ce1b3095e14551b3 (diff)
downloadlibevent-9e725f72e72cb9b37b39915a260f9aee265f2c59.tar.gz
Improve error message for failed epoll to make debugging easier.
Diffstat (limited to 'epoll.c')
-rw-r--r--epoll.c43
1 files changed, 33 insertions, 10 deletions
diff --git a/epoll.c b/epoll.c
index 6707ae8a..04fbfeb0 100644
--- a/epoll.c
+++ b/epoll.c
@@ -120,6 +120,30 @@ epoll_init(struct event_base *base)
return (epollop);
}
+static const char *
+change_to_string(int change)
+{
+ change &= (EV_CHANGE_ADD|EV_CHANGE_DEL);
+ if (change == EV_CHANGE_ADD) {
+ return "add";
+ } else if (change == EV_CHANGE_DEL) {
+ return "del";
+ } else if (change == 0) {
+ return "none";
+ } else {
+ return "???";
+ }
+}
+
+static const char *
+epoll_op_to_string(int op)
+{
+ return op == EPOLL_CTL_ADD?"ADD":
+ op == EPOLL_CTL_DEL?"DEL":
+ op == EPOLL_CTL_MOD?"MOD":
+ "???";
+}
+
static int
epoll_apply_changes(struct event_base *base)
{
@@ -242,24 +266,23 @@ epoll_apply_changes(struct event_base *base)
* got around to calling epoll_dispatch. */
event_debug((" DEL was unnecessary."));
} else {
- event_warn("Epoll %s on fd %d failed. Old events were %d; read change was %d; write change was %d.",
- op == EPOLL_CTL_ADD?"ADD":
- op == EPOLL_CTL_DEL?"DEL":
- op == EPOLL_CTL_MOD?"MOD":"???",
+ event_warn("Epoll %s on fd %d failed. Old events were %d; read change was %d (%s); write change was %d (%s).",
+ epoll_op_to_string(op),
ch->fd,
ch->old_events,
- ch->read_change, ch->write_change
- );
+ ch->read_change,
+ change_to_string(ch->read_change),
+ ch->write_change,
+ change_to_string(ch->write_change));
}
} else {
event_debug(("Epoll %s(%d) on fd %d okay. [old events were %d; read change was %d; write change was %d]",
- op == EPOLL_CTL_ADD?"ADD":
- op == EPOLL_CTL_DEL?"DEL":
- op == EPOLL_CTL_MOD?"MOD":"???",
+ epoll_op_to_string(op),
(int)epev.events,
(int)ch->fd,
ch->old_events,
- ch->read_change, ch->write_change));
+ ch->read_change,
+ ch->write_change));
}
}