summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2010-05-14 16:54:39 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2010-05-14 16:54:39 +0200
commit475977242ac5bb9ff8826c2dd8c9a1a180320de2 (patch)
tree492a30a92b83d398635c5c4e720ae140a1a53513
parent0267f49fb2e44525aa2777bcb9900c4bb2db41e1 (diff)
downloadbird-475977242ac5bb9ff8826c2dd8c9a1a180320de2.tar
bird-475977242ac5bb9ff8826c2dd8c9a1a180320de2.zip
Handle EPIPE as a common connection close event.
-rw-r--r--proto/bgp/bgp.c9
-rw-r--r--proto/bgp/packets.c4
-rw-r--r--sysdep/unix/io.c3
3 files changed, 13 insertions, 3 deletions
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index 378cc85..253322c 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -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)
diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c
index 2160182..1e9d646 100644
--- a/proto/bgp/packets.c
+++ b/proto/bgp/packets.c
@@ -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)
;
}
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index dc7146f..456644b 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -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;