From bbda43311bd6d7490b558e06a3d0a1db40da3dc6 Mon Sep 17 00:00:00 2001 From: Mark Grondona <mgrondona@llnl.gov> Date: Mon, 19 Apr 2004 22:21:56 +0000 Subject: [PATCH] o fix for file descriptor leak in slurmd.c (service_connection) --- NEWS | 1 + src/slurmd/slurmd.c | 21 ++++++++------------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index 1bd4543b984..22f47be3a6b 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ documents those changes that are of interest to users and admins. still processing job completion. This will work properly for shared nodes. -- Set SLURM_DISTRIBUTION environment varible for user tasks. + -- Fix for file descriptor leak in slurmd. * Changes in SLURM 0.3.0.0-pre9 =============================== diff --git a/src/slurmd/slurmd.c b/src/slurmd/slurmd.c index ae3980e6aca..695e80852a0 100644 --- a/src/slurmd/slurmd.c +++ b/src/slurmd/slurmd.c @@ -320,24 +320,19 @@ _service_connection(void *arg) conn_t *con = (conn_t *) arg; slurm_msg_t *msg = xmalloc(sizeof(*msg)); - if ((rc = slurm_receive_msg(con->fd, msg, 0)) < 0) { + /* set msg connection fd to accepted fd. This allows + * possibility for slurmd_req () to close accepted connection + */ + msg->conn_fd = con->fd; + + if ((rc = slurm_receive_msg(con->fd, msg, 0)) < 0) error("slurm_receive_msg: %m"); - goto done; - } else { - msg->conn_fd = con->fd; + else slurmd_req(msg, con->cli_addr); - } - - /* - * Check to see if fd already closed - */ - if (msg->conn_fd < 0) - goto done; - if (slurm_close_accepted_conn(msg->conn_fd) < 0) + if ((msg->conn_fd >= 0) && slurm_close_accepted_conn(msg->conn_fd) < 0) error ("close(%d): %m", con->fd); - done: xfree(con->cli_addr); xfree(con); slurm_free_msg(msg); -- GitLab