Skip to content

Commit ec4268b

Browse files
committed
usnic: do not send zero-length modex message
If there are no usnic BTL modules, then just avoid sending any modex message at all (other BTLs do this; it's safe to do). The change is smaller than it looks: I added a "if 0 ==..." check at the top to return immediately if there are no BTL modules. Then I removed some now-unnecessary conditionals and un-indented as appropriate. Fixes #248
1 parent e415c8f commit ec4268b

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

opal/mca/btl/usnic/btl_usnic_component.c

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -234,33 +234,34 @@ static int usnic_modex_send(void)
234234
size_t size;
235235
opal_btl_usnic_addr_t* addrs = NULL;
236236

237+
if (0 == mca_btl_usnic_component.num_modules) {
238+
return OPAL_SUCCESS;
239+
}
240+
237241
size = mca_btl_usnic_component.num_modules *
238242
sizeof(opal_btl_usnic_addr_t);
239-
if (size != 0) {
240-
addrs = (opal_btl_usnic_addr_t*) malloc(size);
241-
if (NULL == addrs) {
242-
return OPAL_ERR_OUT_OF_RESOURCE;
243-
}
243+
addrs = (opal_btl_usnic_addr_t*) malloc(size);
244+
if (NULL == addrs) {
245+
return OPAL_ERR_OUT_OF_RESOURCE;
246+
}
244247

245-
for (i = 0; i < mca_btl_usnic_component.num_modules; i++) {
246-
opal_btl_usnic_module_t* module =
247-
mca_btl_usnic_component.usnic_active_modules[i];
248-
addrs[i] = module->local_addr;
249-
opal_output_verbose(5, USNIC_OUT,
250-
"btl:usnic: modex_send DQP:%d, CQP:%d, subnet = 0x%016" PRIx64 " interface =0x%016" PRIx64,
251-
addrs[i].qp_num[USNIC_DATA_CHANNEL],
252-
addrs[i].qp_num[USNIC_PRIORITY_CHANNEL],
253-
ntoh64(addrs[i].gid.global.subnet_prefix),
254-
ntoh64(addrs[i].gid.global.interface_id));
255-
}
248+
for (i = 0; i < mca_btl_usnic_component.num_modules; i++) {
249+
opal_btl_usnic_module_t* module =
250+
mca_btl_usnic_component.usnic_active_modules[i];
251+
addrs[i] = module->local_addr;
252+
opal_output_verbose(5, USNIC_OUT,
253+
"btl:usnic: modex_send DQP:%d, CQP:%d, subnet = 0x%016" PRIx64 " interface =0x%016" PRIx64,
254+
addrs[i].qp_num[USNIC_DATA_CHANNEL],
255+
addrs[i].qp_num[USNIC_PRIORITY_CHANNEL],
256+
ntoh64(addrs[i].gid.global.subnet_prefix),
257+
ntoh64(addrs[i].gid.global.interface_id));
256258
}
257259

258260
OPAL_MODEX_SEND(rc, PMIX_SYNC_REQD, PMIX_REMOTE,
259261
&mca_btl_usnic_component.super.btl_version,
260262
addrs, size);
261-
if (NULL != addrs) {
262-
free(addrs);
263-
}
263+
free(addrs);
264+
264265
return rc;
265266
}
266267

0 commit comments

Comments
 (0)