if ((cctx.cmd->flags & CMD_FLAG_NO_PRINT) == 0)
doveadm_print_deinit();
- if (o_stream_nfinish(doveadm_print_ostream) < 0) {
+ if (o_stream_finish(doveadm_print_ostream) < 0) {
i_info("Error writing output in command %s: %s",
req->cmd->name,
o_stream_get_error(req->output));
struct istream *payload = NULL;
if (req->output != NULL) {
- if (o_stream_nfinish(req->output) == -1) {
+ if (o_stream_finish(req->output) == -1) {
i_info("error writing output: %s",
o_stream_get_error(req->output));
o_stream_destroy(&req->output);
o_stream_nsend_str(ibc->output,
t_strdup_printf("%c\n", items[ITEM_DONE].chr));
}
- (void)o_stream_nfinish(ibc->output);
+ (void)o_stream_finish(ibc->output);
}
timeout_remove(&ibc->to);
output = gz->create_ostream(buf_output, 6);
o_stream_nsend_str(output, str1);
- test_assert(o_stream_nfinish(output) == 0);
+ test_assert(o_stream_finish(output) > 0);
o_stream_destroy(&output);
if (str2[0] != '\0') {
output = gz->create_ostream(buf_output, 6);
o_stream_nsend_str(output, "world");
- test_assert(o_stream_nfinish(output) == 0);
+ test_assert(o_stream_finish(output) > 0);
o_stream_destroy(&output);
}
o_stream_nsend(output, data, size);
i_stream_skip(input, size);
}
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
i_fatal("write(%s) failed: %s",
out_path, o_stream_get_error(output));
}
i_stream_skip(is_2, siz);
}
- i_assert(o_stream_nfinish(os_2)==0);
+ i_assert(o_stream_finish(os_2) > 0);
o_stream_close(os_2);
i_stream_close(is_2);
i_debug("error: %s", o_stream_get_error(os_2));
test_assert(os_2->stream_errno == 0);
- test_assert(o_stream_nfinish(os_2) == 0);
+ test_assert(o_stream_finish(os_2) > 0);
test_assert(os_2->stream_errno == 0);
o_stream_unref(&os);
i_debug("error: %s", o_stream_get_error(os_2));
test_assert(os_2->stream_errno == 0);
- test_assert(o_stream_nfinish(os_2) == 0);
+ test_assert(o_stream_finish(os_2) > 0);
test_assert(os_2->stream_errno == 0);
o_stream_unref(&os);
buffer_t *buf = buffer_create_dynamic(default_pool, 64);
struct ostream *os = o_stream_create_buffer(buf);
struct ostream *os_2 = o_stream_create_encrypt(os, "<unused>", test_v1_kp.pub, IO_STREAM_ENC_VERSION_1);
- test_assert(o_stream_nfinish(os_2) == 0);
+ test_assert(o_stream_finish(os_2) > 0);
if (os_2->stream_errno != 0)
i_debug("error: %s", o_stream_get_error(os_2));
struct ostream *os = o_stream_create_buffer(buf);
struct ostream *os_2 = o_stream_create_encrypt(os, "aes-256-gcm-sha256", test_v1_kp.pub, IO_STREAM_ENC_INTEGRITY_AEAD);
o_stream_nsend(os_2, payload, sizeof(payload));
- test_assert(o_stream_nfinish(os_2) == 0);
+ test_assert(o_stream_finish(os_2) > 0);
if (os_2->stream_errno != 0)
i_debug("error: %s", o_stream_get_error(os_2));
struct ostream *os = o_stream_create_buffer(buf);
struct ostream *os_2 = o_stream_create_encrypt(os, "aes-256-gcm-sha256", test_v1_kp.pub, IO_STREAM_ENC_INTEGRITY_AEAD);
o_stream_nsend(os_2, payload, sizeof(payload));
- test_assert(o_stream_nfinish(os_2) == 0);
+ test_assert(o_stream_finish(os_2) > 0);
if (os_2->stream_errno != 0)
i_debug("error: %s", o_stream_get_error(os_2));
buffer_t *buf = buffer_create_dynamic(default_pool, 64);
struct ostream *os = o_stream_create_buffer(buf);
struct ostream *os_2 = o_stream_create_encrypt(os, "aes-256-gcm-sha256", test_v1_kp.pub, IO_STREAM_ENC_INTEGRITY_AEAD);
- test_assert(o_stream_nfinish(os_2) == 0);
+ test_assert(o_stream_finish(os_2) > 0);
if (os_2->stream_errno != 0)
i_debug("error: %s", o_stream_get_error(os_2));
}
hash_table_iterate_deinit(&iter);
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) <= 0) {
*error_r = t_strdup_printf("write(%s) failed: %s", temp_path,
o_stream_get_error(output));
o_stream_destroy(&output);
int fs_write_stream_finish(struct fs_file *file, struct ostream **output)
{
bool success = TRUE;
+ int ret;
i_assert(*output == file->output || *output == NULL);
i_assert(output != &file->output);
*output = NULL;
if (file->output != NULL) {
o_stream_uncork(file->output);
- if (o_stream_nfinish(file->output) < 0) {
+ if ((ret = o_stream_finish(file->output)) <= 0) {
+ i_assert(ret < 0);
fs_set_error(file->fs, "write(%s) failed: %s",
o_stream_get_name(file->output),
o_stream_get_error(file->output));
mail_cache_view_close(&cache_view);
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
mail_cache_set_syscall_error(cache, "write()");
o_stream_destroy(&output);
array_free(ext_offsets);
output = o_stream_create_fd(fd, 0);
o_stream_cork(output);
mail_index_strmap_recreate_write(view, output);
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
mail_index_set_error(strmap->index, "write(%s) failed: %s",
temp_path, o_stream_get_error(output));
ret = -1;
o_stream_cork(output);
mail_index_strmap_write_block(view, output, i,
view->last_read_uid + 1);
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
mail_index_strmap_set_syscall_error(view->strmap, "write()");
ret = -1;
}
map->hdr.header_size - base_size);
o_stream_nsend(output, map->rec_map->records,
map->rec_map->records_count * map->hdr.record_size);
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
mail_index_file_set_syscall_error(index, path, "write()");
ret = -1;
}
i_stream_get_error(base64_input));
failed = TRUE;
}
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
i_error("istream-attachment: write(%s) failed: %s",
o_stream_get_name(output), o_stream_get_error(output));
failed = TRUE;
size_t size;
int ret = 0;
- if (o_stream_nfinish(part->temp_output) < 0) {
+ if (o_stream_finish(part->temp_output) < 0) {
*error_r = t_strdup_printf("write(%s) failed: %s",
o_stream_get_name(part->temp_output),
o_stream_get_error(part->temp_output));
a = array_idx_modifiable(&attachments, array_count(&attachments)-1);
a->decoded_size = output->offset - a->buffer_offset;
- if (o_stream_nfinish(output) < 0)
+ if (o_stream_finish(output) < 0)
i_unreached();
o_stream_destroy(&output);
return 0;
str_append_c(str, '\n');
o_stream_nsend(output, str_data(str), str_len(str));
}
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
i_error("write(%s) failed: %s", path, o_stream_get_error(output));
ret = -1;
}
struct test_client *client = *_client;
*_client = NULL;
- if (o_stream_nfinish(client->out) != 0)
+ if (o_stream_finish(client->out) < 0)
i_error("output error: %s", o_stream_get_error(client->out));
io_remove(&client->io);
struct test_client *client = *_client;
*_client = NULL;
- if (o_stream_nfinish(client->out) != 0)
+ if (o_stream_finish(client->out) < 0)
i_error("output error: %s", o_stream_get_error(client->out));
io_remove(&client->io);
struct stat st;
int ret = 0;
- if (o_stream_nfinish(ctx->ctx.data.output) < 0) {
+ if (o_stream_finish(ctx->ctx.data.output) < 0) {
mail_storage_set_critical(storage, "write(%s) failed: %s", path,
o_stream_get_error(ctx->ctx.data.output));
ret = -1;
{
struct mail_save_data *mdata = &ctx->ctx.data;
struct ostream *dbox_output = ctx->dbox_output;
+ int ret;
i_assert(mdata->output != NULL);
if (index_attachment_save_finish(&ctx->ctx) < 0)
ctx->failed = TRUE;
}
- if (o_stream_nfinish(mdata->output) < 0) {
+ if (mdata->output != dbox_output) {
+ /* e.g. zlib plugin had changed this. make sure we
+ successfully write the trailer. */
+ ret = o_stream_finish(mdata->output);
+ } else {
+ /* no plugins - flush the output so far */
+ ret = o_stream_nfinish(mdata->output);
+ }
+ if (ret < 0) {
mail_storage_set_critical(ctx->ctx.transaction->box->storage,
"write(%s) failed: %s",
o_stream_get_name(mdata->output),
ctx->failed = TRUE;
}
if (mdata->output != dbox_output) {
- /* e.g. zlib plugin had changed this */
o_stream_ref(dbox_output);
o_stream_destroy(&mdata->output);
mdata->output = dbox_output;
output = o_stream_create_fd_file(out_fd, 0, FALSE);
i_stream_seek(file->input, 0);
o_stream_nsend_istream(output, file->input);
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
mail_storage_set_critical(storage, "write(%s) failed: %s",
temp_path, o_stream_get_error(output));
ret = -1;
ctx->finished = TRUE;
if (!ctx->failed) {
- if (o_stream_nfinish(_ctx->data.output) < 0) {
+ if (o_stream_finish(_ctx->data.output) < 0) {
if (!mail_storage_set_error_from_errno(storage)) {
mail_storage_set_critical(storage,
"write(%s) failed: %s", ctx->temp_path,
}
path = t_strconcat(ctx->tmpdir, "/", ctx->file_last->tmp_name, NULL);
- if (!ctx->failed && o_stream_nfinish(_ctx->data.output) < 0) {
+ if (!ctx->failed && o_stream_finish(_ctx->data.output) < 0) {
if (!mail_storage_set_error_from_errno(storage)) {
mail_storage_set_critical(storage,
"write(%s) failed: %s", path,
}
maildir_uidlist_iter_deinit(&iter);
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
mail_storage_set_critical(storage, "write(%s) failed: %s", path,
o_stream_get_error(output));
o_stream_unref(&output);
}
if (changed && !failed) {
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
subswrite_set_syscall_error(list, "write()", path);
failed = TRUE;
} else if (mail_set->parsed_fsync_mode != FSYNC_MODE_NEVER) {
}
hash_table_iterate_deinit(&iter);
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
i_error("write(%s) failed: %s", file->path,
o_stream_get_error(output));
o_stream_unref(&output);
i_stream_unref(&chan0);
i_stream_unref(&is);
- test_assert(o_stream_nfinish(os) == 0);
+ test_assert(o_stream_finish(os) > 0);
o_stream_unref(&os);
io_loop_destroy(&ioloop);
io_remove(&channel->io);
io_remove(&channel->io_alt);
i_stream_unref(&channel->in);
- test_assert(o_stream_nfinish(channel->out) == 0);
+ test_assert(o_stream_finish(channel->out) > 0);
o_stream_unref(&channel->out);
i_stream_unref(&channel->in_alt);
- test_assert(o_stream_nfinish(channel->out_alt) == 0);
+ test_assert(o_stream_finish(channel->out_alt) > 0);
o_stream_unref(&channel->out_alt);
i_close_fd(&channel->fds[0]);
i_close_fd(&channel->fds[1]);
}
o_stream_uncork(output);
- test_assert(o_stream_nfinish(output) == 0);
+ test_assert(o_stream_finish(output) > 0);
i_assert(buffer->used <= MAX_BUFSIZE*4);
test_assert(memcmp(buf, buffer->data, buffer->used) == 0);
}
o_stream_uncork(output);
- test_assert(o_stream_nfinish(output) == 0);
+ test_assert(o_stream_finish(output) > 0);
ret = pread(fd, buf2, sizeof(buf2), 0);
if (ret < 0)
i_fatal("pread() failed: %m");
io_remove(&io0);
io_remove(&io1);
- test_assert(o_stream_nfinish(chan1) == 0);
+ test_assert(o_stream_finish(chan1) > 0);
o_stream_unref(&chan1);
- test_assert(o_stream_nfinish(chan0) == 0);
+ test_assert(o_stream_finish(chan0) > 0);
o_stream_unref(&chan0);
i_stream_unref(&is);
}
}
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
i_error("write(%s) failed: %s", str_c(path),
o_stream_get_error(output));
ret = -1;
}
}
str_free(&str);
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
i_error("write(%s) failed: %s", path,
o_stream_get_error(output));
ret = -1;
(void)o_stream_seek(output, 0);
o_stream_nsend(output, &trie->hdr, sizeof(trie->hdr));
}
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
i_error("write(%s) failed: %s", path,
o_stream_get_error(output));
ret = -1;
(void)o_stream_seek(ctx->output, ctx->build_hdr.used_file_size);
}
- if (o_stream_nfinish(ctx->output) < 0) {
+ if (o_stream_finish(ctx->output) < 0) {
i_error("write() to %s failed: %s", ctx->uidlist->path,
o_stream_get_error(ctx->output));
return -1;
if (ctx->uidlist->corrupted)
ret = -1;
- else if (o_stream_nfinish(ctx->output) < 0) {
+ else if (o_stream_finish(ctx->output) < 0) {
i_error("write(%s) failed: %s", temp_path,
o_stream_get_error(ctx->output));
ret = -1;
break;
}
replicator_queue_iter_deinit(&iter);
- if (o_stream_nfinish(output) < 0) {
+ if (o_stream_finish(output) < 0) {
i_error("write(%s) failed: %s", path, o_stream_get_error(output));
ret = -1;
}
{
if (proxy->in_output != NULL) {
o_stream_uncork(proxy->in_output);
- if (o_stream_nfinish(proxy->in_output) < 0) {
+ if (o_stream_finish(proxy->in_output) < 0) {
i_error("write(in) failed: %s",
o_stream_get_error(proxy->in_output));
}
}
if (proxy->out_output != NULL) {
o_stream_uncork(proxy->out_output);
- if (o_stream_nfinish(proxy->out_output) < 0) {
+ if (o_stream_finish(proxy->out_output) < 0) {
i_error("write(out) failed: %s",
o_stream_get_error(proxy->out_output));
}