From f3c6808d3d8513db2b0543538fc35c25a60fe7a7 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 24 May 2010 13:14:36 -0700 Subject: RDS: introduce rds_conn_connect_if_down() A few paths had the same block of code to queue a connection's connect work if it was in the right state. Let's move this in to a helper function. Signed-off-by: Zach Brown --- net/rds/connection.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'net/rds/connection.c') diff --git a/net/rds/connection.c b/net/rds/connection.c index 180b83ab260..5bd96d538fb 100644 --- a/net/rds/connection.c +++ b/net/rds/connection.c @@ -539,6 +539,18 @@ void rds_conn_drop(struct rds_connection *conn) } EXPORT_SYMBOL_GPL(rds_conn_drop); +/* + * If the connection is down, trigger a connect. We may have scheduled a + * delayed reconnect however - in this case we should not interfere. + */ +void rds_conn_connect_if_down(struct rds_connection *conn) +{ + if (rds_conn_state(conn) == RDS_CONN_DOWN && + !test_and_set_bit(RDS_RECONNECT_PENDING, &conn->c_flags)) + queue_delayed_work(rds_wq, &conn->c_conn_w, 0); +} +EXPORT_SYMBOL_GPL(rds_conn_connect_if_down); + /* * An error occurred on the connection */ -- cgit v1.2.3