From: Ben Pfaff Date: Tue, 30 Dec 2008 21:12:48 +0000 (-0800) Subject: New function nl_sock_wait(), to improve netlink socket abstraction. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0868a05550088156cd401ff8025ecfa8fc1e912a;p=openvswitch New function nl_sock_wait(), to improve netlink socket abstraction. --- diff --git a/lib/netlink.c b/lib/netlink.c index cb4e6c1a..28c1f116 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -44,6 +44,7 @@ #include "dynamic-string.h" #include "netlink-protocol.h" #include "ofpbuf.h" +#include "poll-loop.h" #include "timeval.h" #include "util.h" @@ -424,11 +425,12 @@ recv: return 0; } -/* Returns 'sock''s underlying file descriptor. */ -int -nl_sock_fd(const struct nl_sock *sock) +/* Causes poll_block() to wake up when any of the specified 'events' (which is + * a OR'd combination of POLLIN, POLLOUT, etc.) occur on 'sock'. */ +void +nl_sock_wait(const struct nl_sock *sock, short int events) { - return sock->fd; + poll_fd_wait(sock->fd, events); } /* Netlink messages. */ diff --git a/lib/netlink.h b/lib/netlink.h index 8163a318..d68d7793 100644 --- a/lib/netlink.h +++ b/lib/netlink.h @@ -65,7 +65,7 @@ int nl_sock_recv(struct nl_sock *, struct ofpbuf **, bool wait); int nl_sock_transact(struct nl_sock *, const struct ofpbuf *request, struct ofpbuf **reply); -int nl_sock_fd(const struct nl_sock *); +void nl_sock_wait(const struct nl_sock *, short int events); /* Netlink messages. */ diff --git a/lib/vconn-netlink.c b/lib/vconn-netlink.c index 91faa713..f4aa65a8 100644 --- a/lib/vconn-netlink.c +++ b/lib/vconn-netlink.c @@ -141,7 +141,7 @@ netlink_wait(struct vconn *vconn, enum vconn_wait_type wait) default: NOT_REACHED(); } - poll_fd_wait(nl_sock_fd(netlink->dp.sock), events); + nl_sock_wait(netlink->dp.sock, events); } struct vconn_class netlink_vconn_class = { diff --git a/vswitchd/brcompat.c b/vswitchd/brcompat.c index b4da4fbf..a9a70854 100644 --- a/vswitchd/brcompat.c +++ b/vswitchd/brcompat.c @@ -430,7 +430,7 @@ brc_run(void) void brc_wait(void) { - poll_fd_wait(nl_sock_fd(nl_sock), POLLIN); + nl_sock_wait(nl_sock, POLLIN); } void