]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 14 Jun 2016 09:12:13 +0000 (12:12 +0300)
src/lmtp/commands.c

index 5d3f9c3e5fb3a6e5d61d6285aae7fb1af7c31ed8..5528de970a52673c2cd0eaf0ae4012d113450d74 100644 (file)
@@ -1171,7 +1171,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) {
@@ -1200,15 +1199,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;
 }