From 32baeeec9de5197be1ce715e68a34333c77d866c Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 17 May 2012 16:33:47 +0200 Subject: [PATCH] eloop: add ev_fd_is_bound() helper This helper returns true if the fd is bound to an eloop object, otherwise false is returned. Signed-off-by: David Herrmann --- src/eloop.c | 5 +++++ src/eloop.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/eloop.c b/src/eloop.c index 84468da..60e8a9a 100644 --- a/src/eloop.c +++ b/src/eloop.c @@ -321,6 +321,11 @@ void ev_fd_unref(struct ev_fd *fd) free(fd); } +bool ev_fd_is_bound(struct ev_fd *fd) +{ + return fd && fd->loop; +} + int ev_eloop_new_fd(struct ev_eloop *loop, struct ev_fd **out, int rfd, int mask, ev_fd_cb cb, void *data) { diff --git a/src/eloop.h b/src/eloop.h index 0eef7e1..95f7410 100644 --- a/src/eloop.h +++ b/src/eloop.h @@ -35,6 +35,7 @@ #define EV_ELOOP_H #include +#include #include #include #include @@ -90,6 +91,7 @@ void ev_eloop_rm_idle(struct ev_idle *idle); int ev_fd_new(struct ev_fd **out); void ev_fd_ref(struct ev_fd *fd); void ev_fd_unref(struct ev_fd *fd); +bool ev_fd_is_bound(struct ev_fd *fd); int ev_eloop_new_fd(struct ev_eloop *loop, struct ev_fd **out, int rfd, int mask, ev_fd_cb cb, void *data); -- 2.7.4