From 2249ad2ec38accc702755564ec839701b4c052a7 Mon Sep 17 00:00:00 2001 From: maxim Date: Mon, 19 Oct 2009 12:47:56 +0000 Subject: [PATCH] b=20897 i=isaac i=maxim Fix for conn race when create_conn creates conn and add it to peer's list, releases global lock, gets a comm error, acquires the lock again and attempts to close the conn while it could be closed by some other thread. --- lnet/ChangeLog | 6 ++++++ lnet/klnds/socklnd/socklnd.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lnet/ChangeLog b/lnet/ChangeLog index c71ff8b..ab54322 100644 --- a/lnet/ChangeLog +++ b/lnet/ChangeLog @@ -12,6 +12,12 @@ tbd Sun Microsystems, Inc. mxlnd - MX 1.2.1 or later, ptllnd - Portals 3.3 / UNICOS/lc 1.5.x, 2.0.x +Severity : normal +Bugzilla : 20897 +Description: ksocknal_close_conn_locked connection race +Details : A race was possible when ksocknal_create_conn calls + ksocknal_close_conn_locked for already closed conn. + Severity : enhancement Bugzilla : 13065 Description: port router pinger to userspace diff --git a/lnet/klnds/socklnd/socklnd.c b/lnet/klnds/socklnd/socklnd.c index 8564da5..e76b178 100644 --- a/lnet/klnds/socklnd/socklnd.c +++ b/lnet/klnds/socklnd/socklnd.c @@ -1355,7 +1355,10 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route, if (rc != 0) { cfs_write_lock_bh(global_lock); - ksocknal_close_conn_locked(conn, rc); + if (!conn->ksnc_closing) { + /* could be closed by another thread */ + ksocknal_close_conn_locked(conn, rc); + } cfs_write_unlock_bh(global_lock); } else if (ksocknal_connsock_addref(conn) == 0) { /* Allow I/O to proceed. */ -- 1.8.3.1