[PATCH 1/3] Fix bird will close a socket if it reads zero bytes (e.g. due to buffer is full)

Kenth Eriksson kenth.eriksson at infinera.com
Tue Jun 11 12:09:01 CEST 2019


Datagram sockets may return 0 and stream sockets can return 0 if the
requested number of bytes to read is 0. This may happen if the socket
buffer is full. Bird event loop will asynchronously process the socket
buffer and restore the socket rpos pointer. Thus reading data from the
socket will happen again as soon as the input is processed.

Signed-off-by: Kenth Eriksson <kenth.eriksson at infinera.com>
---
 sysdep/unix/io.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index d1d86e3b..a1d3197a 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -1873,8 +1873,14 @@ sk_read(sock *s, int revents)
 	  s->err_hook(s, 0);
 	}
       }
-      else if (!c)
+      else if (revents & POLLHUP)
+      {
 	s->err_hook(s, 0);
+      }
+      else if (!c)
+      {
+	log(L_WARN "Socket got 0 bytes, buffer full!? c=%d, rpos=%d, rbsize=%d, rbuf=%d", c, s->rpos, s->rbsize, s->rbuf);
+      }
       else
       {
 	s->rpos += c;
-- 
2.21.0



More information about the Bird-users mailing list