From 7bd18214a7d3c4e11ada1a3fe53ebfca9c7dc00f Mon Sep 17 00:00:00 2001 From: Thananon Patinyasakdikul Date: Wed, 15 Jun 2016 07:35:04 -0700 Subject: [PATCH] Fix btl/usnic deadlock when the connectivity check is turned off. --- opal/mca/btl/usnic/btl_usnic_cclient.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/opal/mca/btl/usnic/btl_usnic_cclient.c b/opal/mca/btl/usnic/btl_usnic_cclient.c index 6370c2c790..3f0279d463 100644 --- a/opal/mca/btl/usnic/btl_usnic_cclient.c +++ b/opal/mca/btl/usnic/btl_usnic_cclient.c @@ -228,13 +228,15 @@ int opal_btl_usnic_connectivity_ping(uint32_t src_ipv4_addr, int src_port, uint32_t dest_netmask, int dest_port, char *dest_nodename, size_t max_msg_size) -{ - OPAL_THREAD_LOCK(&btl_usnic_lock); +{ /* If connectivity checking is not enabled, do nothing */ if (!mca_btl_usnic_component.connectivity_enabled) { return OPAL_SUCCESS; } + /* Protect opal_fd_write for multithreaded case */ + OPAL_THREAD_LOCK(&btl_usnic_lock); + /* Send the PING command */ int id = CONNECTIVITY_AGENT_CMD_PING; if (OPAL_SUCCESS != opal_fd_write(agent_fd, sizeof(id), &id)) { @@ -260,6 +262,8 @@ int opal_btl_usnic_connectivity_ping(uint32_t src_ipv4_addr, int src_port, ABORT("usnic connectivity client IPC write failed"); /* Will not return */ } + + /* Unlock and return */ OPAL_THREAD_UNLOCK(&btl_usnic_lock); return OPAL_SUCCESS;