Whamcloud - gitweb
b=20897
authormaxim <maxim>
Thu, 22 Oct 2009 10:40:20 +0000 (10:40 +0000)
committermaxim <maxim>
Thu, 22 Oct 2009 10:40:20 +0000 (10:40 +0000)
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
lnet/klnds/socklnd/socklnd.c

index 1114bd9..0f430a1 100644 (file)
@@ -18,6 +18,12 @@ Description:
 Details    : 
 
 Severity   : normal
 Details    : 
 
 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   : normal
 Bugzilla   : 18102
 Description: router_proc.c is rewritten to use sysctl-interface for parameters
              residing in /proc/sys/lnet
 Bugzilla   : 18102
 Description: router_proc.c is rewritten to use sysctl-interface for parameters
              residing in /proc/sys/lnet
index 3841b08..a616be1 100644 (file)
@@ -1345,7 +1345,10 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
 
         if (rc != 0) {
                 cfs_write_lock_bh(global_lock);
 
         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. */
                 cfs_write_unlock_bh(global_lock);
         } else if (ksocknal_connsock_addref(conn) == 0) {
                 /* Allow I/O to proceed. */