diff options
author | Jesse Gross <jesse@nicira.com> | 2011-07-31 14:47:32 -0700 |
---|---|---|
committer | Jesse Gross <jesse@nicira.com> | 2011-09-23 15:27:49 -0700 |
commit | 1e276d1a10539a8cd97d2ad63c073a9a43f0f1ef (patch) | |
tree | 832bda11a8b73845e42712ae752ef041e340ba16 /lib/netlink-socket.c | |
parent | be8194bb5935141f12339085032da5d63f856f16 (diff) |
poll-loop: Enable checking whether a FD caused a wakeup.
Each time we run through the poll loop, we check all file descriptors
that we were waiting on to see if there is data available. However,
this requires a system call and poll already provides information on
which FDs caused the wakeup so it is inefficient as the number of
active FDs grows. This provides a way to check whether a given FD
has data.
Diffstat (limited to 'lib/netlink-socket.c')
-rw-r--r-- | lib/netlink-socket.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c index 3674bacb..0f4e3e77 100644 --- a/lib/netlink-socket.c +++ b/lib/netlink-socket.c @@ -668,6 +668,14 @@ nl_sock_wait(const struct nl_sock *sock, short int events) poll_fd_wait(sock->fd, events); } +/* Checks whether this socket caused a wakeup in the previous run of the poll + * loop. */ +short int +nl_sock_woke(const struct nl_sock *sock) +{ + return poll_fd_woke(sock->fd); +} + /* Returns the PID associated with this socket. */ uint32_t nl_sock_pid(const struct nl_sock *sock) |