]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-program-client: Use i_close_fd() rather than close() when error is not supposed...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 15 Mar 2018 23:08:17 +0000 (00:08 +0100)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 25 Jun 2019 09:22:31 +0000 (12:22 +0300)
src/lib-program-client/program-client-remote.c
src/lib-program-client/program-client.c

index 143840b79ec84957565c28fccb981daa5f78cbd1..e579c051212474e5994a6784b19409317e317d73 100644 (file)
@@ -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);
                }
        }
 
index ef6545f5de97be5acd15c465361672de0e847ffb..a8f69032244423f22f7dc183c35dade6a498f0b5 100644 (file)
@@ -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);