Skip to content

Commit

Permalink
Disable/delete events in the timeout callback.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Linus Nordberg committed Nov 18, 2013
1 parent f5081dc commit d401ecb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit d401ecb

Please sign in to comment.