Whamcloud - gitweb
b=20897
authormaxim <maxim>
Mon, 19 Oct 2009 12:47:56 +0000 (12:47 +0000)
committermaxim <maxim>
Mon, 19 Oct 2009 12:47:56 +0000 (12:47 +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 c71ff8b..ab54322 100644 (file)
@@ -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
index 8564da5..e76b178 100644 (file)
@@ -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. */