]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Handle EPIPE as a common connection close event.
authorOndrej Zajicek <santiago@crfreenet.org>
Fri, 14 May 2010 14:54:39 +0000 (16:54 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Fri, 14 May 2010 14:54:39 +0000 (16:54 +0200)
proto/bgp/bgp.c
proto/bgp/packets.c
sysdep/unix/io.c

index 378cc85df8840a411fb5c25efa8b676d764a1f7b..253322c6366ebbcb71f9654d651ed2d8efc70030 100644 (file)
@@ -434,6 +434,15 @@ bgp_sock_err(sock *sk, int err)
   struct bgp_conn *conn = sk->data;
   struct bgp_proto *p = conn->bgp;
 
+  /*
+   * This error hook may be called either asynchronously from main
+   * loop, or synchronously from sk_send().  But sk_send() is called
+   * only from bgp_tx() and bgp_kick_tx(), which are both called
+   * asynchronously from main loop. Moreover, they end if err hook is
+   * called. Therefore, we could suppose that it is always called
+   * asynchronously.
+   */
+
   bgp_store_error(p, conn, BE_SOCKET, err);
 
   if (err)
index 21601825dbe5acea829f7aa1190cb87c60cb24bf..1e9d6465f6dcc66dd68d5cfb005b247e81192caf 100644 (file)
@@ -594,7 +594,7 @@ bgp_kick_tx(void *vconn)
   struct bgp_conn *conn = vconn;
 
   DBG("BGP: kicking TX\n");
-  while (bgp_fire_tx(conn))
+  while (bgp_fire_tx(conn) > 0)
     ;
 }
 
@@ -604,7 +604,7 @@ bgp_tx(sock *sk)
   struct bgp_conn *conn = sk->data;
 
   DBG("BGP: TX hook\n");
-  while (bgp_fire_tx(conn))
+  while (bgp_fire_tx(conn) > 0)
     ;
 }
 
index dc7146f5cc0bc5e45c54893b8000c762a8c6708a..456644b2b21e93a1a176d1997550c601492d2a3d 100644 (file)
@@ -1216,7 +1216,8 @@ sk_maybe_write(sock *s)
              if (errno != EINTR && errno != EAGAIN)
                {
                  reset_tx_buffer(s);
-                 s->err_hook(s, errno);
+                 /* EPIPE is just a connection close notification during TX */
+                 s->err_hook(s, (errno != EPIPE) ? errno : 0);
                  return -1;
                }
              return 0;