Skip to content

Commit c332ee5

Browse files
authored
Merge pull request #1784 from thananon/fix_usnic_thread
Fix btl/usnic deadlock when the connectivity check is turned off.
2 parents f59c2fc + 7bd1821 commit c332ee5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

opal/mca/btl/usnic/btl_usnic_cclient.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,15 @@ int opal_btl_usnic_connectivity_ping(uint32_t src_ipv4_addr, int src_port,
228228
uint32_t dest_netmask, int dest_port,
229229
char *dest_nodename,
230230
size_t max_msg_size)
231-
{
232-
OPAL_THREAD_LOCK(&btl_usnic_lock);
231+
{
233232
/* If connectivity checking is not enabled, do nothing */
234233
if (!mca_btl_usnic_component.connectivity_enabled) {
235234
return OPAL_SUCCESS;
236235
}
237236

237+
/* Protect opal_fd_write for multithreaded case */
238+
OPAL_THREAD_LOCK(&btl_usnic_lock);
239+
238240
/* Send the PING command */
239241
int id = CONNECTIVITY_AGENT_CMD_PING;
240242
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,
260262
ABORT("usnic connectivity client IPC write failed");
261263
/* Will not return */
262264
}
265+
266+
/* Unlock and return */
263267
OPAL_THREAD_UNLOCK(&btl_usnic_lock);
264268

265269
return OPAL_SUCCESS;

0 commit comments

Comments
 (0)