diff options
author | Jiri Pirko <jiri@resnulli.us> | 2013-06-07 08:37:43 +0200 |
---|---|---|
committer | Jiri Pirko <jiri@resnulli.us> | 2013-06-07 08:47:56 +0200 |
commit | e9666098cb6b0c9e8fcfaef2f643f1eae4909f89 (patch) | |
tree | c454fbd86b9e31bd338df2ad4a38a54c0c62151c /libndp | |
parent | ca3c399c269e30d4d0ed384d36b4ed1f00e8f4b2 (diff) | |
download | libndp-e9666098cb6b0c9e8fcfaef2f643f1eae4909f89.tar.gz |
libndp: add ndp_callall_eventfd_handler()
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Diffstat (limited to 'libndp')
-rw-r--r-- | libndp/libndp.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libndp/libndp.c b/libndp/libndp.c index 661c729..1b38907 100644 --- a/libndp/libndp.c +++ b/libndp/libndp.c @@ -25,6 +25,7 @@ #include <errno.h> #include <ctype.h> #include <sys/socket.h> +#include <sys/select.h> #include <netinet/in.h> #include <netinet/icmp6.h> #include <arpa/inet.h> @@ -1697,6 +1698,39 @@ int ndp_call_eventfd_handler(struct ndp *ndp) return ndp_sock_recv(ndp); } +/** + * ndp_callall_eventfd_handler: + * @ndp: libndp library context + * + * Call all pending events on eventfd handler. + * + * Returns: zero on success or negative number in case of an error. + **/ +NDP_EXPORT +int ndp_callall_eventfd_handler(struct ndp *ndp) +{ + fd_set rfds; + int fdmax; + struct timeval tv; + int fd = ndp_get_eventfd(ndp); + int ret; + int err; + + memset(&tv, 0, sizeof(tv)); + FD_ZERO(&rfds); + FD_SET(fd, &rfds); + fdmax = fd + 1; + while (true) { + ret = select(fdmax, &rfds, NULL, NULL, &tv); + if (ret == -1) + return -errno; + if (!FD_ISSET(fd, &rfds)) + return 0; + err = ndp_call_eventfd_handler(ndp); + if (err) + return err; + } +} /** * SECTION: Exported context functions |