From c7182f83ed14779b47a1a8691c0a9080478a19de Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 26 Jul 2014 21:56:04 +0200 Subject: [PATCH] Fix orphaned file descriptors during errors --- bacula/src/dird/fd_cmds.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index 730de2ab2c..adff580b9a 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -509,6 +509,7 @@ static bool send_list_item(JCR *jcr, const char *code, char *item, BSOCK *fd) fd->msglen = Mmsg(fd->msg, "%s", buf); Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg); if (!fd->send()) { + close_bpipe(bpipe); Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); return false; } @@ -534,6 +535,7 @@ static bool send_list_item(JCR *jcr, const char *code, char *item, BSOCK *fd) while (fgets(buf+optlen, sizeof(buf)-optlen, ffd)) { fd->msglen = Mmsg(fd->msg, "%s", buf); if (!fd->send()) { + fclose(ffd); Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); return false; } -- 2.39.5