From: Stephan Bosch Date: Thu, 15 Mar 2018 23:08:17 +0000 (+0100) Subject: lib-program-client: Use i_close_fd() rather than close() when error is not supposed... X-Git-Tag: 2.3.7~191 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ca9eeb5bd36abc76ad3ce4baccee0236f5ede76b;p=thirdparty%2Fdovecot%2Fcore.git lib-program-client: Use i_close_fd() rather than close() when error is not supposed to happen. --- diff --git a/src/lib-program-client/program-client-remote.c b/src/lib-program-client/program-client-remote.c index 143840b79e..e579c05121 100644 --- a/src/lib-program-client/program-client-remote.c +++ b/src/lib-program-client/program-client-remote.c @@ -537,9 +537,8 @@ program_client_remote_close_output(struct program_client *pclient) pclient->path); return -1; } - } else if (close(fd_out) < 0) { - i_error("close(%s) failed: %m", pclient->path); - return -1; + } else { + i_close_fd(&fd_out); } } diff --git a/src/lib-program-client/program-client.c b/src/lib-program-client/program-client.c index ef6545f5de..a8f6903224 100644 --- a/src/lib-program-client/program-client.c +++ b/src/lib-program-client/program-client.c @@ -86,8 +86,8 @@ program_client_disconnect_extra_fds(struct program_client *pclient) for(i = 0; i < count; i++) { i_stream_unref(&efds[i].input); io_remove(&efds[i].io); - if (efds[i].parent_fd != -1 && close(efds[i].parent_fd) < 0) - i_error("close(fd=%d) failed: %m", efds[i].parent_fd); + if (efds[i].parent_fd != -1) + i_close_fd(&efds[i].parent_fd); } array_clear(&pclient->extra_fds); @@ -106,12 +106,10 @@ program_client_do_disconnect(struct program_client *pclient) iostream_pump_destroy(&pclient->pump_in); iostream_pump_destroy(&pclient->pump_out); - if (pclient->fd_in != -1 && close(pclient->fd_in) < 0) - i_error("close(%s) failed: %m", pclient->path); - if (pclient->fd_out != -1 && pclient->fd_out != pclient->fd_in - && close(pclient->fd_out) < 0) - i_error("close(%s/out) failed: %m", pclient->path); - pclient->fd_in = pclient->fd_out = -1; + if (pclient->fd_out == pclient->fd_in) + pclient->fd_in = -1; + i_close_fd(&pclient->fd_in); + i_close_fd(&pclient->fd_out); program_client_disconnect_extra_fds(pclient);