]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-login: Use i_close_fd() where possible
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sun, 5 Apr 2020 13:27:52 +0000 (16:27 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 28 Jun 2022 08:10:53 +0000 (08:10 +0000)
src/lib-login/login-client.c
src/lib-login/login-server.c

index 3094777600ce99a9a6a365453b5f81780259aed1..91bb45ee47f11f259cdb03880f39a5e157f4a90d 100644 (file)
@@ -78,11 +78,7 @@ login_connection_deinit(struct login_connection **_conn)
 
        timeout_remove(&conn->to);
        io_remove(&conn->io);
-       if (conn->fd != -1) {
-               if (close(conn->fd) < 0)
-                       i_fatal("close(%s) failed: %m", conn->path);
-               conn->fd = -1;
-       }
+       i_close_fd(&conn->fd);
        i_free(conn->path);
        i_free(conn);
 }
index 0f078000a3b861e23660e77e82e6332e92438d67..93bdd55de8d56fcc771ed1a0e452e4ccc4682d45 100644 (file)
@@ -227,8 +227,7 @@ static void master_login_client_free(struct master_login_client **_client)
 
        *_client = NULL;
        if (client->fd != -1) {
-               if (close(client->fd) < 0)
-                       i_error("close(fd_read client) failed: %m");
+               i_close_fd(&client->fd);
                /* this client failed (login callback wasn't called).
                   reset prefix to default. */
                i_set_failure_prefix("%s: ", client->conn->login->service->name);
@@ -282,8 +281,7 @@ static void master_login_postlogin_free(struct master_login_postlogin *pl)
        }
        timeout_remove(&pl->to);
        io_remove(&pl->io);
-       if (close(pl->fd) < 0)
-               i_error("close(postlogin) failed: %m");
+       i_close_fd(&pl->fd);
        str_free(&pl->input);
        i_free(pl->socket_path);
        i_free(pl->username);
@@ -302,8 +300,7 @@ static void master_login_postlogin_input(struct master_login_postlogin *pl)
        while ((ret = fd_read(pl->fd, buf, sizeof(buf), &fd)) > 0) {
                if (fd != -1) {
                        /* post-login script replaced fd */
-                       if (close(pl->client->fd) < 0)
-                               conn_error(conn, "close(client) failed: %m");
+                       i_close_fd(&pl->client->fd);
                        pl->client->fd = fd;
                }
                str_append_data(pl->input, buf, ret);
@@ -539,9 +536,7 @@ static void master_login_conn_close(struct master_login_connection *conn)
 
        io_remove(&conn->io);
        o_stream_close(conn->output);
-       if (close(conn->fd) < 0)
-               i_error("close(master login) failed: %m");
-       conn->fd = -1;
+       i_close_fd(&conn->fd);
 }
 
 static void master_login_conn_unref(struct master_login_connection **_conn)