Skip to content

Commit 59682c2

Browse files
author
Ralph Castain
authored
Merge pull request #4312 from rhc54/topic/dli
Fix cmd line passing of DVM URI
2 parents 38e0194 + 51f3fbd commit 59682c2

File tree

1 file changed

+30
-11
lines changed
  • opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp

1 file changed

+30
-11
lines changed

opal/mca/pmix/pmix2x/pmix/src/mca/ptl/tcp/ptl_tcp.c

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,22 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer,
246246
}
247247
free(mca_ptl_tcp_component.super.uri);
248248
mca_ptl_tcp_component.super.uri = suri;
249+
} else {
250+
/* we need to extract the nspace/rank of the server from the string */
251+
p = strchr(mca_ptl_tcp_component.super.uri, ';');
252+
*p = '\0';
253+
p++;
254+
suri = strdup(p); // save the uri portion
255+
/* the '.' in the first part of the original string separates
256+
* nspace from rank */
257+
p = strchr(mca_ptl_tcp_component.super.uri, '.');
258+
*p = '\0';
259+
p++;
260+
nspace = strdup(mca_ptl_tcp_component.super.uri);
261+
rank = strtoull(p, NULL, 10);
262+
/* now update the URI */
263+
free(mca_ptl_tcp_component.super.uri);
264+
mca_ptl_tcp_component.super.uri = suri;
249265
}
250266
pmix_output_verbose(2, pmix_ptl_base_framework.framework_output,
251267
"ptl:tcp:tool attempt connect using given URI %s",
@@ -564,21 +580,23 @@ static pmix_status_t try_connect(int *sd)
564580
/* setup the path to the daemon rendezvous point */
565581
memset(&mca_ptl_tcp_component.connection, 0, sizeof(struct sockaddr_storage));
566582
if (0 == strncmp(mca_ptl_tcp_component.super.uri, "tcp4", 4)) {
567-
/* separate the IP address from the port */
568-
p = strdup(mca_ptl_tcp_component.super.uri);
583+
/* need to skip the tcp4: part */
584+
p = strdup(&mca_ptl_tcp_component.super.uri[7]);
569585
if (NULL == p) {
570586
PMIX_ERROR_LOG(PMIX_ERR_NOMEM);
571587
return PMIX_ERR_NOMEM;
572588
}
573-
p2 = strchr(&p[7], ':');
589+
590+
/* separate the IP address from the port */
591+
p2 = strchr(p, ':');
574592
if (NULL == p2) {
575593
free(p);
576594
PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM);
577595
return PMIX_ERR_BAD_PARAM;
578596
}
579597
*p2 = '\0';
580-
++p2;
581-
host = &p[7];
598+
p2++;
599+
host = p;
582600
/* load the address */
583601
in = (struct sockaddr_in*)&mca_ptl_tcp_component.connection;
584602
in->sin_family = AF_INET;
@@ -591,13 +609,14 @@ static pmix_status_t try_connect(int *sd)
591609
in->sin_port = htons(atoi(p2));
592610
len = sizeof(struct sockaddr_in);
593611
} else {
594-
/* separate the IP address from the port */
595-
p = strdup(mca_ptl_tcp_component.super.uri);
612+
/* need to skip the tcp6: part */
613+
p = strdup(&mca_ptl_tcp_component.super.uri[7]);
596614
if (NULL == p) {
597615
PMIX_ERROR_LOG(PMIX_ERR_NOMEM);
598616
return PMIX_ERR_NOMEM;
599617
}
600-
p2 = strchr(&p[7], ':');
618+
619+
p2 = strchr(p, ':');
601620
if (NULL == p2) {
602621
free(p);
603622
PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM);
@@ -607,10 +626,10 @@ static pmix_status_t try_connect(int *sd)
607626
if (']' == p[strlen(p)-1]) {
608627
p[strlen(p)-1] = '\0';
609628
}
610-
if ('[' == p[7]) {
611-
host = &p[8];
629+
if ('[' == p[0]) {
630+
host = &p[1];
612631
} else {
613-
host = &p[7];
632+
host = &p[0];
614633
}
615634
/* load the address */
616635
in6 = (struct sockaddr_in6*)&mca_ptl_tcp_component.connection;

0 commit comments

Comments
 (0)