static bool cmd_append_continue_message(struct client_command_context *cmd);
static bool cmd_append_parse_new_msg(struct client_command_context *cmd);
-static const char *get_disconnect_reason(struct cmd_append_context *ctx)
+static const char *
+get_disconnect_reason(struct cmd_append_context *ctx, uoff_t lit_offset)
{
string_t *str = t_str_new(128);
unsigned int secs = ioloop_time - ctx->started;
ctx->count, secs);
if (ctx->litinput != NULL) {
str_printfa(str, ", %"PRIuUOFF_T"/%"PRIuUOFF_T" bytes",
- ctx->litinput->v_offset, ctx->literal_size);
+ lit_offset, ctx->literal_size);
}
str_append_c(str, ')');
return str_c(str);
switch (i_stream_read(client->input)) {
case -1:
/* disconnected */
- reason = get_disconnect_reason(ctx);
+ reason = get_disconnect_reason(ctx, ctx->litinput->v_offset);
cmd_append_finish(cmd->context);
/* Reset command so that client_destroy() doesn't try to call
cmd_append_continue_message() anymore. */
}
if (ctx->litinput->eof || client->input->closed) {
- bool all_written = ctx->litinput->v_offset == ctx->literal_size;
+ uoff_t lit_offset = ctx->litinput->v_offset;
/* finished - do one more read, to make sure istream-chain
unreferences its stream, which is needed for litinput's
/* failed above */
client_send_storage_error(cmd, ctx->storage);
ctx->failed = TRUE;
- } else if (!all_written) {
+ } else if (lit_offset != ctx->literal_size) {
/* client disconnected before it finished sending the
whole message. */
ctx->failed = TRUE;
mailbox_save_cancel(&ctx->save_ctx);
- client_disconnect(client, "EOF while appending");
+ client_disconnect(client,
+ get_disconnect_reason(ctx, lit_offset));
} else if (ctx->catenate) {
/* CATENATE isn't finished yet */
} else if (mailbox_save_finish(&ctx->save_ctx) < 0) {