Whamcloud - gitweb
* Fixed bug in destroying idle persistent peer
authoreeb <eeb>
Sun, 9 Jan 2005 19:52:51 +0000 (19:52 +0000)
committereeb <eeb>
Sun, 9 Jan 2005 19:52:51 +0000 (19:52 +0000)
lnet/klnds/openiblnd/openiblnd.c

index 9bf9985..8443c87 100644 (file)
@@ -339,6 +339,8 @@ kibnal_create_peer (ptl_nid_t nid)
         peer->ibp_reconnect_interval = IBNAL_MIN_RECONNECT_INTERVAL;
 
         atomic_inc (&kibnal_data.kib_npeers);
+        CDEBUG(D_NET, "peer %p "LPX64"\n", peer, nid);
+
         return (peer);
 }
 
@@ -508,13 +510,19 @@ kibnal_del_peer_locked (kib_peer_t *peer, int single_share)
         if (peer->ibp_persistence != 0)
                 return;
 
-        list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) {
-                conn = list_entry(ctmp, kib_conn_t, ibc_list);
+        if (list_empty(&peer->ibp_conns)) {
+                kibnal_unlink_peer_locked(peer);
+        } else {
+                list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) {
+                        conn = list_entry(ctmp, kib_conn_t, ibc_list);
 
-                kibnal_close_conn_locked (conn, 0);
+                        kibnal_close_conn_locked (conn, 0);
+                }
+                /* NB peer is no longer persistent; closing its last conn
+                 * unlinked it. */
         }
-
-        /* NB peer unlinks itself when last conn is closed */
+        /* NB peer now unlinked; might even be freed if the peer table had the
+         * last ref on it. */
 }
 
 int