str_data(str), str_len(str)) < 0 ||
o_stream_flush(request->winbind->out_pipe) < 0) {
auth_request_log_error(auth_request, AUTH_SUBSYS_MECH,
- "write(out_pipe) failed: %m");
+ "write(out_pipe) failed: %s",
+ o_stream_get_error(request->winbind->out_pipe));
return HR_RESTART;
}
request->continued = FALSE;
break;
}
if (line == NULL && ctx->input->stream_errno != 0) {
- i_error("read(%s) failed: %m", ctx->path);
+ i_error("read(%s) failed: %s", ctx->path,
+ i_stream_get_error(ctx->input));
_ctx->failed = TRUE;
}
}
} T_END;
ret = o_stream_send(conn->output, data, len);
if (ret != (off_t)len) {
- if (ret < 0)
- i_error("director(%s): write() failed: %m", conn->name);
- else {
+ if (ret < 0) {
+ i_error("director(%s): write() failed: %s", conn->name,
+ o_stream_get_error(conn->output));
+ } else {
i_error("director(%s): Output buffer full, "
"disconnecting", conn->name);
}
line = i_stream_read_next_line(ctx->input);
alarm(0);
if (line == NULL) {
- if (ctx->input->stream_errno != 0)
- i_fatal("read(%s) failed: %m", ctx->socket_path);
- else if (ctx->input->eof)
+ if (ctx->input->stream_errno != 0) {
+ i_fatal("read(%s) failed: %s", ctx->socket_path,
+ i_stream_get_error(ctx->input));
+ } else if (ctx->input->eof) {
i_fatal("%s disconnected", ctx->socket_path);
- else {
+ } else {
i_fatal("read(%s) timed out (is director configured?)",
ctx->socket_path);
}
static void director_disconnect(struct director_context *ctx)
{
if (ctx->input != NULL) {
- if (ctx->input->stream_errno != 0)
- i_fatal("read(%s) failed: %m", ctx->socket_path);
+ if (ctx->input->stream_errno != 0) {
+ i_fatal("read(%s) failed: %s", ctx->socket_path,
+ i_stream_get_error(ctx->input));
+ }
i_stream_destroy(&ctx->input);
}
}
penalty_print_line(ctx, &penalty_line);
} T_END;
}
- if (input->stream_errno != 0)
- i_fatal("read(%s) failed: %m", ctx->anvil_path);
+ if (input->stream_errno != 0) {
+ i_fatal("read(%s) failed: %s", ctx->anvil_path,
+ i_stream_get_error(input));
+ }
i_stream_destroy(&input);
}
line = i_stream_read_next_line(ctx->input);
alarm(0);
if (line == NULL) {
- if (ctx->input->stream_errno != 0)
- i_fatal("read(%s) failed: %m", ctx->socket_path);
- else if (ctx->input->eof)
+ if (ctx->input->stream_errno != 0) {
+ i_fatal("read(%s) failed: %s", ctx->socket_path,
+ i_stream_get_error(ctx->input));
+ } else if (ctx->input->eof)
i_fatal("%s disconnected", ctx->socket_path);
else
i_fatal("read(%s) timed out", ctx->socket_path);
static void replicator_disconnect(struct replicator_context *ctx)
{
- if (ctx->input->stream_errno != 0)
- i_fatal("read(%s) failed: %m", ctx->socket_path);
+ if (ctx->input->stream_errno != 0) {
+ i_fatal("read(%s) failed: %s", ctx->socket_path,
+ i_stream_get_error(ctx->input));
+ }
i_stream_destroy(&ctx->input);
}
} while (args != NULL);
}
if (input->stream_errno != 0)
- i_fatal("read(%s) failed: %m", path);
+ i_fatal("read(%s) failed: %s", path, i_stream_get_error(input));
i_stream_destroy(&input);
}
hash_table_insert(ctx->sessions, line->id, line);
}
- if (ctx->input->stream_errno != 0)
- i_fatal("read(%s) failed: %m", ctx->path);
+ if (ctx->input->stream_errno != 0) {
+ i_fatal("read(%s) failed: %s", ctx->path,
+ i_stream_get_error(ctx->input));
+ }
i_fatal("read(%s): unexpected EOF", ctx->path);
}
callback(ctx, &who_line);
} T_END;
}
- if (input->stream_errno != 0)
- i_fatal("read(%s) failed: %m", ctx->anvil_path);
+ if (input->stream_errno != 0) {
+ i_fatal("read(%s) failed: %s", ctx->anvil_path,
+ i_stream_get_error(input));
+ }
i_stream_destroy(&input);
}
if (i_stream_read(client->input) == -1) {
if (client->input->stream_errno != 0) {
- errno = client->input->stream_errno;
- i_fatal("read(server) failed: %m");
+ i_fatal("read(server) failed: %s",
+ i_stream_get_error(client->input));
}
i_info("Server disconnected");
o_stream_uncork(conn->output);
if (o_stream_nfinish(conn->output) < 0) {
- i_error("write(auth socket) failed: %m");
+ i_error("write(auth socket) failed: %s",
+ o_stream_get_error(conn->output));
auth_master_unset_io(conn);
auth_connection_close(conn);
return -1;
AUTH_CLIENT_PROTOCOL_MINOR_VERSION,
conn->client->client_pid);
if (o_stream_send_str(conn->output, handshake) < 0) {
- i_warning("Error sending handshake to auth server: %m");
+ i_warning("Error sending handshake to auth server: %s",
+ o_stream_get_error(conn->output));
auth_server_connection_disconnect(conn,
- strerror(conn->output->last_failed_errno));
+ o_stream_get_error(conn->output));
return -1;
}
resp->payload_input = input;
if ((ret = i_stream_get_size(input, TRUE, &resp->payload_size)) <= 0) {
if (ret < 0) {
- i_error("i_stream_get_size(%s) failed: %m",
- i_stream_get_name(input));
+ i_error("i_stream_get_size(%s) failed: %s",
+ i_stream_get_name(input), i_stream_get_error(input));
}
resp->payload_size = 0;
resp->payload_chunked = TRUE;
if (resp->payload_input->stream_errno != 0) {
/* we're in the middle of sending a response, so the connection
will also have to be aborted */
- errno = resp->payload_input->stream_errno;
- *error_r = t_strdup_printf("read(%s) failed: %m",
- i_stream_get_name(resp->payload_input));
+ *error_r = t_strdup_printf("read(%s) failed: %s",
+ i_stream_get_name(resp->payload_input),
+ i_stream_get_error(resp->payload_input));
ret = -1;
} else if (output->stream_errno != 0) {
/* failed to send response */
- errno = output->stream_errno;
- if (errno != EPIPE && errno != ECONNRESET) {
- *error_r = t_strdup_printf("write(%s) failed: %m",
- o_stream_get_name(output));
+ if (output->stream_errno != EPIPE &&
+ output->stream_errno != ECONNRESET) {
+ *error_r = t_strdup_printf("write(%s) failed: %s",
+ o_stream_get_name(output), o_stream_get_error(output));
}
ret = -1;
} else {
o_stream_ref(output);
o_stream_cork(output);
if (o_stream_sendv(output, iov, N_ELEMENTS(iov)) < 0) {
- if (errno != EPIPE && errno != ECONNRESET) {
- *error_r = t_strdup_printf("write(%s) failed: %m",
- o_stream_get_name(output));
+ if (output->stream_errno != EPIPE &&
+ output->stream_errno != ECONNRESET) {
+ *error_r = t_strdup_printf("write(%s) failed: %s",
+ o_stream_get_name(output), o_stream_get_error(output));
}
ret = -1;
}
o_stream_cork(output);
mail_index_strmap_recreate_write(view, output);
if (o_stream_nfinish(output) < 0) {
- mail_index_set_error(strmap->index,
- "write(%s) failed: %m", temp_path);
+ mail_index_set_error(strmap->index, "write(%s) failed: %s",
+ temp_path, o_stream_get_error(output));
ret = -1;
}
o_stream_destroy(&output);
hash_table_iterate_deinit(&iter);
if (o_stream_nfinish(output) < 0) {
- i_error("write(%s) failed: %m", file->path);
+ i_error("write(%s) failed: %s", file->path,
+ o_stream_get_error(output));
o_stream_unref(&output);
duplicate_file_free(&ctx->file);
return;
lmtp_client_fail(client,
"501 5.5.4 Command reply line too long");
} else if (client->input->stream_errno != 0) {
- errno = client->input->stream_errno;
- i_error("lmtp client: read() failed: %m");
+ i_error("lmtp client: read() failed: %s",
+ i_stream_get_error(client->input));
lmtp_client_fail(client, ERRSTR_TEMP_REMOTE_FAILURE
" (read failure)");
} else if (client->input->eof) {
}
if (o_stream_nfinish(smtp_client->output) < 0) {
- *error_r = t_strdup_printf("write(%s) failed: %m",
- smtp_client->temp_path);
+ *error_r = t_strdup_printf("write(%s) failed: %s",
+ smtp_client->temp_path, o_stream_get_error(smtp_client->output));
return -1;
}
if (o_stream_seek(smtp_client->output, 0) < 0) {
- *error_r = t_strdup_printf("lseek(%s) failed: %m",
- smtp_client->temp_path);
+ *error_r = t_strdup_printf("lseek(%s) failed: %s",
+ smtp_client->temp_path, o_stream_get_error(smtp_client->output));
return -1;
}
aqueue_delete_tail(client->queries);
}
if (client->input->stream_errno != 0) {
- i_error("read(%s) failed: %m", client->path);
+ i_error("read(%s) failed: %s", client->path,
+ i_stream_get_error(client->input));
anvil_reconnect(client);
} else if (client->input->eof) {
i_error("read(%s) failed: EOF", client->path);
i_error("Invalid line in %s: %s", list->path, line);
} T_END;
if (input->stream_errno != 0) {
- i_error("read(%s) failed: %m", line);
+ i_error("read(%s) failed: %s", line, i_stream_get_error(input));
ret = -1;
}
i_stream_destroy(&input);
o_stream_nsend(output, str_data(str), str_len(str));
}
if (o_stream_nfinish(output) < 0) {
- i_error("write(%s) failed: %m", path);
+ i_error("write(%s) failed: %s", path, o_stream_get_error(output));
ret = -1;
}
o_stream_destroy(&output);
if (ret == 0)
return 1;
*error_r = istream->stream_errno != 0 ?
- t_strdup_printf("read(%s) failed: %m", path) :
+ t_strdup_printf("read(%s) failed: %s", path,
+ i_stream_get_error(istream)) :
t_strdup_printf("read(%s) failed: EOF", path);
return -1;
}
int ret = 0;
if (o_stream_nfinish(ctx->ctx.data.output) < 0) {
- mail_storage_set_critical(storage, "write(%s) failed: %m", path);
+ mail_storage_set_critical(storage, "write(%s) failed: %s", path,
+ o_stream_get_error(ctx->ctx.data.output));
ret = -1;
}
return 0;
}
mail_storage_set_critical(&file->storage->storage,
- "read(%s) failed: %m", file->cur_path);
+ "read(%s) failed: %s", file->cur_path,
+ i_stream_get_error(file->input));
return -1;
}
enum mdbox_map_append_flags append_flags;
uoff_t msg_size;
off_t ret;
- int read_errno;
if (ctx->append_ctx == NULL)
ctx->append_ctx = mdbox_map_append_begin(ctx->atomic);
input = i_stream_create_limit(file->input, msg_size);
ret = o_stream_send_istream(output, input);
- read_errno = input->stream_errno;
- i_stream_unref(&input);
-
- if (read_errno != 0) {
- errno = read_errno;
+ if (input->stream_errno != 0) {
mail_storage_set_critical(&file->storage->storage,
- "read(%s) failed: %m", file->cur_path);
+ "read(%s) failed: %s", file->cur_path,
+ i_stream_get_error(input));
+ i_stream_unref(&input);
return -1;
}
+ i_stream_unref(&input);
if (o_stream_nfinish(output) < 0) {
mail_storage_set_critical(&file->storage->storage,
- "write(%s) failed: %m",
- out_file_append->file->cur_path);
+ "write(%s) failed: %s",
+ out_file_append->file->cur_path,
+ o_stream_get_error(output));
return -1;
}
if (ret != (off_t)msg_size) {
output = o_stream_create_fd_file(out_fd, 0, FALSE);
i_stream_seek(file->input, 0);
- while ((ret = o_stream_send_istream(output, file->input)) > 0) ;
+ ret = o_stream_send_istream(output, file->input) > 0 ? 0 : -1;
if (o_stream_nfinish(output) < 0) {
- mail_storage_set_critical(storage, "write(%s) failed: %m",
- temp_path);
+ mail_storage_set_critical(storage, "write(%s) failed: %s",
+ temp_path, o_stream_get_error(output));
ret = -1;
} else if (file->input->stream_errno != 0) {
- errno = file->input->stream_errno;
- dbox_file_set_syscall_error(file, "ftruncate()");
+ mail_storage_set_critical(storage, "read(%s) failed: %s",
+ temp_path, i_stream_get_error(file->input));
ret = -1;
- } else if (ret < 0) {
- mail_storage_set_critical(storage,
- "o_stream_send_istream(%s, %s) "
- "failed with unknown error",
- temp_path, file->cur_path);
}
o_stream_unref(&output);
if (o_stream_nfinish(_ctx->data.output) < 0) {
if (!mail_storage_set_error_from_errno(storage)) {
mail_storage_set_critical(storage,
- "write(%s) failed: %m", ctx->temp_path);
+ "write(%s) failed: %s", ctx->temp_path,
+ o_stream_get_error(_ctx->data.output));
}
ctx->failed = TRUE;
}
if (output->last_failed_errno == 0)
return 0;
- errno = output->last_failed_errno;
if (!mail_storage_set_error_from_errno(storage)) {
- mail_storage_set_critical(storage, "write(%s) failed: %m",
- o_stream_get_name(output));
+ mail_storage_set_critical(storage, "write(%s) failed: %s",
+ o_stream_get_name(output), o_stream_get_error(output));
}
return -1;
}
{
struct maildir_save_context *ctx = (struct maildir_save_context *)_ctx;
struct mail_storage *storage = &ctx->mbox->storage->storage;
- const char *path;
+ const char *path, *output_errstr;
off_t real_size;
uoff_t size;
int output_errno;
if (!ctx->failed && o_stream_nfinish(_ctx->data.output) < 0) {
if (!mail_storage_set_error_from_errno(storage)) {
mail_storage_set_critical(storage,
- "write(%s) failed: %m", path);
+ "write(%s) failed: %s", path,
+ o_stream_get_error(_ctx->data.output));
}
ctx->failed = TRUE;
}
ctx->file_last->vsize = (uoff_t)-1;
output_errno = _ctx->data.output->last_failed_errno;
+ output_errstr = t_strdup(o_stream_get_error(_ctx->data.output));
o_stream_destroy(&_ctx->data.output);
if (storage->set->parsed_fsync_mode != FSYNC_MODE_NEVER &&
/* delete the tmp file */
i_unlink_if_exists(path);
- errno = output_errno;
- if (ENOQUOTA(errno)) {
+ if (ENOQUOTA(output_errno)) {
mail_storage_set_error(storage,
MAIL_ERROR_NOQUOTA, MAIL_ERRSTR_NO_QUOTA);
- } else if (errno != 0) {
+ } else if (output_errno != 0) {
mail_storage_set_critical(storage,
- "write(%s) failed: %m", path);
+ "write(%s) failed: %s", path, output_errstr);
}
maildir_save_remove_last_filename(ctx);
if (input->stream_errno == ESTALE && try_retry)
*retry_r = TRUE;
else {
- errno = input->stream_errno;
mail_storage_set_critical(storage,
- "read(%s) failed: %m", uidlist->path);
+ "read(%s) failed: %s", uidlist->path,
+ i_stream_get_error(input));
}
uidlist->last_read_offset = 0;
}
maildir_uidlist_iter_deinit(&iter);
if (o_stream_nfinish(output) < 0) {
- mail_storage_set_critical(storage, "write(%s) failed: %m", path);
+ mail_storage_set_critical(storage, "write(%s) failed: %s", path,
+ o_stream_get_error(output));
o_stream_unref(&output);
return -1;
}
/* actual parser error */
*error_r = parser->error;
} else if (parser->input->stream_errno != 0) {
- *error_r = t_strdup_printf("read(%s) failed: %m",
- i_stream_get_name(parser->input));
+ *error_r = t_strdup_printf("read(%s) failed: %s",
+ i_stream_get_name(parser->input),
+ i_stream_get_error(parser->input));
} else if (parser->data == parser->end &&
!i_stream_have_bytes_left(parser->input) &&
parser->state != JSON_STATE_DONE) {
}
if (o_stream_nfinish(output) < 0) {
- i_error("write(%s) failed: %m", str_c(path));
+ i_error("write(%s) failed: %s", str_c(path),
+ o_stream_get_error(output));
ret = -1;
}
if (mailbox_list_iter_deinit(&iter) < 0)
}
str_free(&str);
if (o_stream_nfinish(output) < 0) {
- i_error("write(%s) failed: %m", path);
+ i_error("write(%s) failed: %s", path,
+ o_stream_get_error(output));
ret = -1;
}
o_stream_destroy(&output);
ret = 0;
else {
ret = -1;
- i_error("read(%s) failed: %m", path);
+ i_error("read(%s) failed: %s", path,
+ i_stream_get_error(input));
}
} else {
if (fstat(fd, &st) < 0) {
o_stream_nsend(output, &trie->hdr, sizeof(trie->hdr));
}
if (o_stream_nfinish(output) < 0) {
- i_error("write() to %s failed: %m", path);
+ i_error("write(%s) failed: %s", path,
+ o_stream_get_error(output));
ret = -1;
}
o_stream_destroy(&output);
}
if (o_stream_nfinish(ctx->output) < 0) {
- i_error("write() to %s failed: %m", ctx->uidlist->path);
+ i_error("write() to %s failed: %s", ctx->uidlist->path,
+ o_stream_get_error(ctx->output));
return -1;
}
return 0;
if (ctx->uidlist->corrupted)
ret = -1;
else if (o_stream_nfinish(ctx->output) < 0) {
- i_error("write() to %s failed: %m", temp_path);
+ i_error("write(%s) failed: %s", temp_path,
+ o_stream_get_error(ctx->output));
ret = -1;
} else if (rename(temp_path, ctx->uidlist->path) < 0) {
i_error("rename(%s, %s) failed: %m",
if (ctx->input->stream_errno != 0) {
ctx->failed = TRUE;
- i_error("read(%s) failed: %m", ctx->log->path);
+ i_error("read(%s) failed: %s", ctx->log->path,
+ i_stream_get_error(ctx->input));
} else {
size = i_stream_get_data_size(ctx->input);
ctx->corrupted = TRUE;