From 2c33da507046c25d87741fe0ce7947985c8c7a10 Mon Sep 17 00:00:00 2001
From: Jan Moskyto Matejka <mq@ucw.cz>
Date: Tue, 20 Dec 2016 20:13:08 +0100
Subject: [PATCH] Netlink: fix occasional netlink hangs on busy machines

---
 sysdep/linux/netlink.c | 1 +
 sysdep/unix/io.c       | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c
index 368e0ef9d..22313f439 100644
--- a/sysdep/linux/netlink.c
+++ b/sysdep/linux/netlink.c
@@ -1497,6 +1497,7 @@ nl_async_hook(sock *sk, uint size UNUSED)
 	   *  One day we might react to it by asking for route table
 	   *  scan in near future.
 	   */
+	  log(L_WARN "Kernel dropped some netlink messages, will resync on next scan.");
 	  return 1;	/* More data are likely to be ready */
 	}
       else if (errno != EWOULDBLOCK)
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 644a4fcd7..8773f4c41 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -2238,7 +2238,8 @@ io_loop(void)
 	      if (pfd[s->index].revents & (POLLHUP | POLLERR))
 		{
 		  sk_err(s, pfd[s->index].revents);
-		  goto next2;
+		  if (s != current_sock)
+		    goto next2;
 		}
 
 	      current_sock = sk_next(s);
-- 
GitLab