Skip to content
Snippets Groups Projects
Commit 97bee5a0 authored by Moe Jette's avatar Moe Jette
Browse files

Re-issue _slurm_close functions on EINTR to avoid leaving orphan file

descriptors. This was needed in several grouped functions (e.g.
slurm_send_recv_rc_msg and slurm_send_only_node_msg, which combine
open, send, receive, and close functions for simplicity).
parent e48ce3ac
No related branches found
No related tags found
No related merge requests found
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
/* #DEFINES */ /* #DEFINES */
#define _DEBUG 0 #define _DEBUG 0
#define MAX_SHUTDOWN_RETRY 10
#define SLURM_DEFAULT_TIMEOUT 2000 #define SLURM_DEFAULT_TIMEOUT 2000
/* STATIC VARIABLES */ /* STATIC VARIABLES */
...@@ -782,16 +783,21 @@ _send_and_recv_msg(slurm_fd fd, slurm_msg_t *req, slurm_msg_t *resp, ...@@ -782,16 +783,21 @@ _send_and_recv_msg(slurm_fd fd, slurm_msg_t *req, slurm_msg_t *resp,
int timeout) int timeout)
{ {
int err = SLURM_SUCCESS; int err = SLURM_SUCCESS;
int retry = 0;
if ( (slurm_send_node_msg(fd, req) < 0) if ( (slurm_send_node_msg(fd, req) < 0)
|| (slurm_receive_msg(fd, resp, timeout) < 0) ) || (slurm_receive_msg(fd, resp, timeout) < 0) )
err = errno; err = errno;
/* /*
* Attempt to close an open connection * Attempt to close an open connection
*/ */
if (slurm_shutdown_msg_conn(fd) < 0) while ( (slurm_shutdown_msg_conn(fd) < 0) && (errno == EINTR) ) {
return SLURM_ERROR; if (retry++ > MAX_SHUTDOWN_RETRY) {
err = errno;
break;
}
}
if (err) slurm_seterrno_ret(err); if (err) slurm_seterrno_ret(err);
...@@ -867,6 +873,7 @@ int slurm_send_recv_node_msg(slurm_msg_t *req, slurm_msg_t *resp, int timeout) ...@@ -867,6 +873,7 @@ int slurm_send_recv_node_msg(slurm_msg_t *req, slurm_msg_t *resp, int timeout)
int slurm_send_only_controller_msg(slurm_msg_t *req) int slurm_send_only_controller_msg(slurm_msg_t *req)
{ {
int rc = SLURM_SUCCESS; int rc = SLURM_SUCCESS;
int retry = 0;
slurm_fd fd = -1; slurm_fd fd = -1;
/* /*
...@@ -879,9 +886,14 @@ int slurm_send_only_controller_msg(slurm_msg_t *req) ...@@ -879,9 +886,14 @@ int slurm_send_only_controller_msg(slurm_msg_t *req)
rc = slurm_send_node_msg(fd, req); rc = slurm_send_node_msg(fd, req);
if (slurm_shutdown_msg_conn(fd) < 0) { /*
rc = SLURM_SOCKET_ERROR; * Attempt to close an open connection
goto cleanup; */
while ( (slurm_shutdown_msg_conn(fd) < 0) && (errno == EINTR) ) {
if (retry++ > MAX_SHUTDOWN_RETRY) {
rc = SLURM_SOCKET_ERROR;
goto cleanup;
}
} }
cleanup: cleanup:
...@@ -899,6 +911,7 @@ int slurm_send_only_controller_msg(slurm_msg_t *req) ...@@ -899,6 +911,7 @@ int slurm_send_only_controller_msg(slurm_msg_t *req)
int slurm_send_only_node_msg(slurm_msg_t *req) int slurm_send_only_node_msg(slurm_msg_t *req)
{ {
int rc = SLURM_SUCCESS; int rc = SLURM_SUCCESS;
int retry = 0;
slurm_fd fd = -1; slurm_fd fd = -1;
if ((fd = slurm_open_msg_conn(&req->address)) < 0) if ((fd = slurm_open_msg_conn(&req->address)) < 0)
...@@ -906,8 +919,13 @@ int slurm_send_only_node_msg(slurm_msg_t *req) ...@@ -906,8 +919,13 @@ int slurm_send_only_node_msg(slurm_msg_t *req)
rc = slurm_send_node_msg(fd, req); rc = slurm_send_node_msg(fd, req);
if (slurm_shutdown_msg_conn(fd) < 0) /*
return SLURM_SOCKET_ERROR; * Attempt to close an open connection
*/
while ( (slurm_shutdown_msg_conn(fd) < 0) && (errno == EINTR) ) {
if (retry++ > MAX_SHUTDOWN_RETRY)
return SLURM_SOCKET_ERROR;
}
return rc; return rc;
} }
......
...@@ -374,7 +374,8 @@ slurm_fd _slurm_listen_stream(slurm_addr *addr) ...@@ -374,7 +374,8 @@ slurm_fd _slurm_listen_stream(slurm_addr *addr)
return fd; return fd;
error: error:
_slurm_close_stream(fd); if ((_slurm_close_stream(fd) < 0) && (errno == EINTR))
_slurm_close_stream(fd); /* try again */
return rc; return rc;
} }
...@@ -408,7 +409,8 @@ slurm_fd _slurm_open_stream(slurm_addr *addr) ...@@ -408,7 +409,8 @@ slurm_fd _slurm_open_stream(slurm_addr *addr)
return fd; return fd;
error: error:
_slurm_close_stream(fd); if ((_slurm_close_stream(fd) < 0) && (errno == EINTR))
_slurm_close_stream(fd); /* try again */
return rc; return rc;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment