Skip to content

Commit ebbbfbf

Browse files
authored
Merge pull request openpmix#1308 from rhc54/topic/tl
Add missing tool rendezvous file
2 parents f4814e8 + c33cc2a commit ebbbfbf

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

src/mca/ptl/tcp/ptl_tcp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2016-2018 Intel, Inc. All rights reserved.
12+
* Copyright (c) 2016-2019 Intel, Inc. All rights reserved.
1313
* Copyright (c) 2018 IBM Corporation. All rights reserved.
1414
* $COPYRIGHT$
1515
*
@@ -48,6 +48,7 @@ typedef struct {
4848
struct sockaddr_storage connection;
4949
char *session_filename;
5050
char *nspace_filename;
51+
char *pid_filename;
5152
char *system_filename;
5253
char *rendezvous_filename;
5354
int wait_to_connect;

src/mca/ptl/tcp/ptl_tcp_component.c

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ static pmix_status_t setup_fork(const pmix_proc_t *proc, char ***env);
118118
.disable_ipv6_family = true,
119119
.session_filename = NULL,
120120
.nspace_filename = NULL,
121+
.pid_filename = NULL,
121122
.system_filename = NULL,
122123
.rendezvous_filename = NULL,
123124
.wait_to_connect = 4,
@@ -306,6 +307,10 @@ pmix_status_t component_close(void)
306307
unlink(mca_ptl_tcp_component.nspace_filename);
307308
free(mca_ptl_tcp_component.nspace_filename);
308309
}
310+
if (NULL != mca_ptl_tcp_component.pid_filename) {
311+
unlink(mca_ptl_tcp_component.pid_filename);
312+
free(mca_ptl_tcp_component.pid_filename);
313+
}
309314
if (NULL != mca_ptl_tcp_component.rendezvous_filename) {
310315
unlink(mca_ptl_tcp_component.rendezvous_filename);
311316
free(mca_ptl_tcp_component.rendezvous_filename);
@@ -779,10 +784,10 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo,
779784
FILE *fp;
780785
pid_t mypid;
781786

782-
/* first output to a file based on pid */
787+
/* first output to a std file */
783788
mypid = getpid();
784-
if (0 > asprintf(&mca_ptl_tcp_component.session_filename, "%s/pmix.%s.tool.%d",
785-
mca_ptl_tcp_component.session_tmpdir, myhost, mypid)) {
789+
if (0 > asprintf(&mca_ptl_tcp_component.session_filename, "%s/pmix.%s.tool",
790+
mca_ptl_tcp_component.session_tmpdir, myhost)) {
786791
CLOSE_THE_SOCKET(lt->socket);
787792
goto sockerror;
788793
}
@@ -813,6 +818,40 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo,
813818
goto sockerror;
814819
}
815820

821+
/* now output to a file based on pid */
822+
mypid = getpid();
823+
if (0 > asprintf(&mca_ptl_tcp_component.pid_filename, "%s/pmix.%s.tool.%d",
824+
mca_ptl_tcp_component.session_tmpdir, myhost, mypid)) {
825+
CLOSE_THE_SOCKET(lt->socket);
826+
goto sockerror;
827+
}
828+
pmix_output_verbose(2, pmix_ptl_base_framework.framework_output,
829+
"WRITING TOOL FILE %s",
830+
mca_ptl_tcp_component.pid_filename);
831+
fp = fopen(mca_ptl_tcp_component.pid_filename, "w");
832+
if (NULL == fp) {
833+
pmix_output(0, "Impossible to open the file %s in write mode\n", mca_ptl_tcp_component.pid_filename);
834+
PMIX_ERROR_LOG(PMIX_ERR_FILE_OPEN_FAILURE);
835+
CLOSE_THE_SOCKET(lt->socket);
836+
free(mca_ptl_tcp_component.pid_filename);
837+
mca_ptl_tcp_component.pid_filename = NULL;
838+
goto sockerror;
839+
}
840+
841+
/* output my URI */
842+
fprintf(fp, "%s\n", lt->uri);
843+
/* add a flag that indicates we accept v2.1 protocols */
844+
fprintf(fp, "%s\n", PMIX_VERSION);
845+
fclose(fp);
846+
/* set the file mode */
847+
if (0 != chmod(mca_ptl_tcp_component.pid_filename, S_IRUSR | S_IWUSR | S_IRGRP)) {
848+
PMIX_ERROR_LOG(PMIX_ERR_FILE_OPEN_FAILURE);
849+
CLOSE_THE_SOCKET(lt->socket);
850+
free(mca_ptl_tcp_component.pid_filename);
851+
mca_ptl_tcp_component.pid_filename = NULL;
852+
goto sockerror;
853+
}
854+
816855
/* now output it into a file based on my nspace */
817856

818857
if (0 > asprintf(&mca_ptl_tcp_component.nspace_filename, "%s/pmix.%s.tool.%s",

0 commit comments

Comments
 (0)