]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: Fixed error logging when writing to temp file
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 16 May 2016 16:16:55 +0000 (19:16 +0300)
committerGitLab <gitlab@git.dovecot.net>
Wed, 18 May 2016 12:21:30 +0000 (15:21 +0300)
src/lmtp/commands.c

index 1da462e12f461dbecf48440cd77ccd30ae4df89d..77d271cb7bb244e36fc95d130c040990d694f602 100644 (file)
@@ -1178,7 +1178,6 @@ static int client_input_add_file(struct client *client,
 {
        struct client_state *state = &client->state;
        string_t *path;
-       ssize_t ret;
        int fd;
 
        if (state->mail_data_output != NULL) {
@@ -1207,15 +1206,17 @@ static int client_input_add_file(struct client *client,
 
        state->mail_data_fd = fd;
        state->mail_data_output = o_stream_create_fd_file(fd, 0, FALSE);
+       o_stream_set_name(state->mail_data_output, str_c(path));
        o_stream_cork(state->mail_data_output);
 
-       ret = o_stream_send(state->mail_data_output,
-                           state->mail_data->data, state->mail_data->used);
-       if (ret != (ssize_t)state->mail_data->used)
-               return -1;
-       if (o_stream_send(client->state.mail_data_output,
-                         data, size) != (ssize_t)size)
+       o_stream_nsend(state->mail_data_output,
+                      state->mail_data->data, state->mail_data->used);
+       o_stream_nsend(client->state.mail_data_output, data, size);
+       if (o_stream_nfinish(client->state.mail_data_output) < 0) {
+               i_error("write(%s) failed: %s", str_c(path),
+                       o_stream_get_error(client->state.mail_data_output));
                return -1;
+       }
        return 0;
 }