+void
+event_conn_timeout_cb (int fd, short event, void *data)
+{
+ struct rs_connection *conn = NULL;
+
+ assert (data);
+ conn = (struct rs_connection *) data;
+
+ if (event & EV_TIMEOUT)
+ {
+ rs_debug (("%s: connection timeout on %p (fd %d) connecting to %p\n",
+ __func__, conn, conn->fd, conn->active_peer));
+ conn->is_connecting = 0;
+ rs_err_conn_push_fl (conn, RSE_TIMEOUT_CONN, __FILE__, __LINE__, NULL);
+ event_loopbreak (conn);
+ }
+}
+
+void
+event_retransmit_timeout_cb (int fd, short event, void *data)
+{
+ struct rs_connection *conn = NULL;
+
+ assert (data);
+ conn = (struct rs_connection *) data;
+
+ if (event & EV_TIMEOUT)
+ {
+ 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);
+ }
+}
+