Skip to content

Commit 0b915f1

Browse files
author
rhc54
authored
Merge pull request #1843 from rhc54/topic/listener
Update the PMIx listener to avoid leaking sockets into children, and …
2 parents 59bf1f0 + 673f82e commit 0b915f1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_listener.c

100644100755
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ pmix_status_t pmix_start_listening(pmix_listener_t *lt)
8787
printf("%s:%d socket() failed\n", __FILE__, __LINE__);
8888
return PMIX_ERROR;
8989
}
90+
/* Set the socket to close-on-exec so that no children inherit
91+
* this FD */
92+
if (pmix_fd_set_cloexec(lt->socket) != PMIX_SUCCESS) {
93+
CLOSE_THE_SOCKET(lt->socket);
94+
return PMIX_ERROR;
95+
}
96+
9097

9198

9299
addrlen = sizeof(struct sockaddr_un);
@@ -296,8 +303,17 @@ static void* listen_thread(void *obj)
296303
PMIX_RELEASE(pending_connection);
297304
if (pmix_socket_errno != EAGAIN ||
298305
pmix_socket_errno != EWOULDBLOCK) {
299-
if (EMFILE == pmix_socket_errno) {
306+
if (EMFILE == pmix_socket_errno ||
307+
ENOBUFS == pmix_socket_errno ||
308+
ENOMEM == pmix_socket_errno) {
300309
PMIX_ERROR_LOG(PMIX_ERR_OUT_OF_RESOURCE);
310+
} else if (EINVAL == pmix_socket_errno ||
311+
EINTR == pmix_socket_errno) {
312+
/* race condition at finalize */
313+
goto done;
314+
} else if (ECONNABORTED == pmix_socket_errno) {
315+
/* they aborted the attempt */
316+
continue;
301317
} else {
302318
pmix_output(0, "listen_thread: accept() failed: %s (%d).",
303319
strerror(pmix_socket_errno), pmix_socket_errno);

0 commit comments

Comments
 (0)