Whamcloud - gitweb
LU-15860 socklnd: Duplicate ksock_conn_cb
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd.c
index bfe6a02..f3fff31 100644 (file)
@@ -645,14 +645,17 @@ ksocknal_add_peer(struct lnet_ni *ni, struct lnet_processid *id,
                         nidhash(&id->nid));
        }
 
                         nidhash(&id->nid));
        }
 
-       ksocknal_add_conn_cb_locked(peer_ni, conn_cb);
-
-       /* Remember conns_per_peer setting at the time
-        * of connection initiation. It will define the
-        * max number of conns per type for this conn_cb
-        * while it's in use.
-        */
-       conn_cb->ksnr_max_conns = ksocknal_get_conns_per_peer(peer_ni);
+       if (peer_ni->ksnp_conn_cb) {
+               ksocknal_conn_cb_decref(conn_cb);
+       } else {
+               ksocknal_add_conn_cb_locked(peer_ni, conn_cb);
+               /* Remember conns_per_peer setting at the time
+                * of connection initiation. It will define the
+                * max number of conns per type for this conn_cb
+                * while it's in use.
+                */
+               conn_cb->ksnr_max_conns = ksocknal_get_conns_per_peer(peer_ni);
+       }
 
        write_unlock_bh(&ksocknal_data.ksnd_global_lock);
 
 
        write_unlock_bh(&ksocknal_data.ksnd_global_lock);