summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Wang <alexw@nicira.com>2014-07-18 14:27:36 -0700
committerAlex Wang <alexw@nicira.com>2014-07-18 17:30:17 -0700
commit1738803acda21425c19d1549c0c1e6586ef0c64a (patch)
treea3aa53bec71f1c4ec53721c06175356aca87573d
parent6a92c6f079f7f19c6a46d167af16ff600d3023d0 (diff)
downloadopenvswitch-1738803acda21425c19d1549c0c1e6586ef0c64a.tar.gz
netlink-socket: Do not make flow_dump block on netlink socket.
Commit 93295354 (netlink-socket: Simplify multithreaded dumping to match Linux reality.) makes the call to recvmsg() block if no messages are available. This can cause revalidator threads hanging for long time or even deadlock when main thread tries to stop the revalidator threads. This commit fixes the issue by enabling the MSG_DONTWAIT flag in the call to recvmsg(). Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
-rw-r--r--lib/netlink-socket.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c
index b1e6804fb..09d3a6187 100644
--- a/lib/netlink-socket.c
+++ b/lib/netlink-socket.c
@@ -724,9 +724,15 @@ nl_dump_refill(struct nl_dump *dump, struct ofpbuf *buffer)
int error;
while (!ofpbuf_size(buffer)) {
- error = nl_sock_recv__(dump->sock, buffer, true);
+ error = nl_sock_recv__(dump->sock, buffer, false);
if (error) {
- /* The kernel shouldn't return EAGAIN while there's data left. */
+ /* The kernel never blocks providing the results of a dump, so
+ * error == EAGAIN means that we've read the whole thing, and
+ * therefore transform it into EOF. (The kernel always provides
+ * NLMSG_DONE as a sentinel. Some other thread must have received
+ * that already but not yet signaled it in 'status'.)
+ *
+ * Any other error is just an error. */
return error == EAGAIN ? EOF : error;
}