From 61d80537cae95d125c4b9fed31e2454a281b8b02 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 21 Feb 2014 15:26:35 -0600 Subject: [PATCH] rx: Split out rxi_SendConnectionAbortLater Take the functionality in rxi_SendConnectionAbort that schedules a delayed abort, and split it out into a new function, rxi_SendConnectionAbortLater. This allows callers an easy interface to send such a delayed abort with their own delay. This commit should incur no change in behavior; it is just code reorganization. Change-Id: I6503cf6ebb3e664d95b8792f2311ea14ee63c11d --- src/rx/rx.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/rx/rx.c b/src/rx/rx.c index 0c05763..5b1b5e3 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -4781,6 +4781,30 @@ rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np, return np; } +/** + * Schedule a connection abort to be sent after some delay. + * + * @param[in] conn The connection to send the abort on. + * @param[in] msec The number of milliseconds to wait before sending. + * + * @pre conn_data_lock must be held + */ +static void +rxi_SendConnectionAbortLater(struct rx_connection *conn, int msec) +{ + struct clock when, now; + if (!conn->error) { + return; + } + if (!conn->delayedAbortEvent) { + clock_GetTime(&now); + when = now; + clock_Addmsec(&when, msec); + conn->delayedAbortEvent = + rxevent_Post(&when, &now, rxi_SendDelayedConnAbort, conn, NULL, 0); + } +} + /* Received a response to a challenge packet */ static struct rx_packet * rxi_ReceiveResponsePacket(struct rx_connection *conn, @@ -5200,7 +5224,6 @@ rxi_SendConnectionAbort(struct rx_connection *conn, struct rx_packet *packet, int istack, int force) { afs_int32 error; - struct clock when, now; if (!conn->error) return packet; @@ -5221,12 +5244,8 @@ rxi_SendConnectionAbort(struct rx_connection *conn, RX_PACKET_TYPE_ABORT, (char *)&error, sizeof(error), istack); MUTEX_ENTER(&conn->conn_data_lock); - } else if (!conn->delayedAbortEvent) { - clock_GetTime(&now); - when = now; - clock_Addmsec(&when, rxi_connAbortDelay); - conn->delayedAbortEvent = - rxevent_Post(&when, &now, rxi_SendDelayedConnAbort, conn, NULL, 0); + } else { + rxi_SendConnectionAbortLater(conn, rxi_connAbortDelay); } return packet; } -- 1.9.4