summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2013-11-18 15:30:00 +0100
committerLinus Nordberg <linus@nordberg.se>2013-11-18 15:30:00 +0100
commitd401ecbd70e02ad5b0cd7ab103359a23c6af3224 (patch)
tree482eec62a7bb2da9e91c9a6ff93a687858a1cbd1
parentf5081dc4aae5e2cb953e8b61fe86ae506974ed7a (diff)
Disable/delete events in the timeout callback.
Without this, the sequence (1) send (successfully) (2) receive (timeout) (3) resend (successfully) will have the read event from (2) trigger a read in (3) and the response is lost. Addresses LIBRADSEC-3.
-rw-r--r--lib/event.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/event.c b/lib/event.c
index c625850..b572184 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -92,6 +92,21 @@ event_retransmit_timeout_cb (int fd, short event, void *data)
rs_debug (("%s: retransmission timeout on %p (fd %d) sending to %p\n",
__func__, conn, conn->fd, conn->active_peer));
rs_err_conn_push_fl (conn, RSE_TIMEOUT_IO, __FILE__, __LINE__, NULL);
+
+ /* Disable/delete read and write events. Timing out on reading
+ might f.ex. trigger resending of a message. It'd be
+ surprising to end up reading without having enabled/created a
+ read event in that case. */
+ if (conn->bev) /* TCP. */
+ bufferevent_disable (conn->bev, EV_WRITE|EV_READ);
+ else /* UDP. */
+ {
+ if (conn->wev)
+ event_del (conn->wev);
+ if (conn->rev)
+ event_del (conn->rev);
+ }
+
event_loopbreak (conn);
}
}