From d2366a2ba65542e2d24772dbcc0b5ed26ee6f6cc Mon Sep 17 00:00:00 2001 From: Jan Fabian Radon Date: Mon, 5 Dec 2022 20:31:27 +0100 Subject: [PATCH] Bugfix/355 fix gzip trailer for empty stream (#357) * #355 fix write gzip trailer even the stream is empty. * #355 minor improvements for quota messaging * #355 fix gzip trailer for empty stream --- CHANGELOG.md | 4 +++- configure.ac | 2 +- rpm/dovecot-ceph-plugin.spec | 2 +- src/storage-rbox/rbox-save.cpp | 5 ++--- src/storage-rbox/rbox-sync.cpp | 39 ++++++++++++++++------------------ 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 876edf4c..ecb39608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Change Log +## [0.0.47](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.47) (2022-12-05) +- #355 fix gzip trailer when stream is empty -## [0.0.46](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.45) (2022-11-22) +## [0.0.46](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.46) (2022-11-22) - #349 bugfix doveadm rmb create ceph index validate object metadata ## [0.0.45](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.45) (2022-11-22) diff --git a/configure.ac b/configure.ac index c7dac368..65393adf 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ AC_PREREQ([2.59]) -AC_INIT([dovecot-ceph-plugin], [0.0.46], [https://github.com/ceph-dovecot/dovecot-ceph-plugin/issues/new], ,[https://github.com/ceph-dovecot/dovecot-ceph-plugin]) +AC_INIT([dovecot-ceph-plugin], [0.0.47], [https://github.com/ceph-dovecot/dovecot-ceph-plugin/issues/new], ,[https://github.com/ceph-dovecot/dovecot-ceph-plugin]) AC_CONFIG_AUX_DIR([.]) diff --git a/rpm/dovecot-ceph-plugin.spec b/rpm/dovecot-ceph-plugin.spec index 7b7a04c4..ddc4e641 100644 --- a/rpm/dovecot-ceph-plugin.spec +++ b/rpm/dovecot-ceph-plugin.spec @@ -14,7 +14,7 @@ Name: dovecot-ceph-plugin Summary: Dovecot Ceph RADOS plugins -Version: 0.0.46 +Version: 0.0.47 Release: 0%{?dist} URL: https://github.com/ceph-dovecot/dovecot-ceph-plugin diff --git a/src/storage-rbox/rbox-save.cpp b/src/storage-rbox/rbox-save.cpp index 3f002e12..08e0ef6a 100644 --- a/src/storage-rbox/rbox-save.cpp +++ b/src/storage-rbox/rbox-save.cpp @@ -784,9 +784,8 @@ int rbox_save_finish(struct mail_save_context *_ctx) { // clean stream if still open #if DOVECOT_PREREQ(2, 3) int ret = 0; - - if (r_ctx->ctx.data.output != r_ctx->output_stream && - r_ctx->ctx.data.output != NULL) { + //#355 we need to write zipl trailer even the stream is empty! + if (r_ctx->ctx.data.output != r_ctx->output_stream ) { /* e.g. zlib plugin had changed this. make sure we successfully write the trailer. */ i_info("check state2 %ld",r_ctx->ctx.data.output); diff --git a/src/storage-rbox/rbox-sync.cpp b/src/storage-rbox/rbox-sync.cpp index 8758acaa..3374b99c 100644 --- a/src/storage-rbox/rbox-sync.cpp +++ b/src/storage-rbox/rbox-sync.cpp @@ -50,24 +50,24 @@ static void rbox_sync_expunge(struct rbox_sync_context *ctx, uint32_t seq1, uint FUNC_START(); struct mailbox *box = &ctx->rbox->box; uint32_t uid = -1; + uint32_t seq; - for (; seq1 <= seq2; seq1++) { - mail_index_lookup_uid(ctx->sync_view, seq1, &uid); - if (!mail_index_transaction_is_expunged(ctx->trans, seq1)) { + for (seq = seq1; seq <= seq2; seq++) { + mail_index_lookup_uid(ctx->sync_view, seq, &uid); + const struct mail_index_record *rec; + rec = mail_index_lookup(ctx->sync_view, seq); + if (rec == NULL) { + i_error("rbox_sync_expunge: mail_index_lookup failed! for %d uid(%d)", seq1, uid); + continue; // skip further processing. + } + if (!mail_index_transaction_is_expunged(ctx->trans, seq)) { /* todo load flags and set alt_storage flag */ - const struct mail_index_record *rec; - rec = mail_index_lookup(ctx->sync_view, seq1); - if (rec == NULL) { - i_error("rbox_sync_expunge: mail_index_lookup failed! for %d uid(%d)", seq1, uid); - continue; // skip further processing. - } - - mail_index_expunge(ctx->trans, seq1); + mail_index_expunge(ctx->trans, seq); struct expunged_item *item = p_new(default_pool, struct expunged_item, 1); i_zero(item); item->uid = uid; - if (rbox_get_oid_from_index(ctx->sync_view, seq1, ((struct rbox_mailbox *)box)->ext_id, &item->oid) < 0) { + if (rbox_get_oid_from_index(ctx->sync_view, seq, ((struct rbox_mailbox *)box)->ext_id, &item->oid) < 0) { // continue anyway } else { item->alt_storage = is_alternate_storage_set(rec->flags) && is_alternate_pool_valid(box); @@ -409,6 +409,7 @@ int rbox_sync_begin(struct rbox_mailbox *rbox, struct rbox_sync_context **ctx_r, } } if (ret <= 0) { + index_storage_expunging_deinit(&ctx->rbox->box); array_delete(&ctx->expunged_items, array_count(&ctx->expunged_items) - 1, 1); array_free(&ctx->expunged_items); i_free(ctx); @@ -475,6 +476,8 @@ static int rbox_sync_object_expunge(struct rbox_sync_context *ctx, struct expung item->alt_storage); } } + // directly notify + mailbox_sync_notify(box, item->uid, MAILBOX_SYNC_TYPE_EXPUNGE); FUNC_END(); return ret_remove; @@ -493,17 +496,12 @@ static void rbox_sync_expunge_rbox_objects(struct rbox_sync_context *ctx) { T_BEGIN { item = items[i]; rbox_sync_object_expunge(ctx, item); - // directly notify - if (ctx->rbox->box.v.sync_notify != NULL) { - ctx->rbox->box.v.sync_notify(&ctx->rbox->box, item->uid, MAILBOX_SYNC_TYPE_EXPUNGE); - } } T_END; } } - if (ctx->rbox->box.v.sync_notify != NULL){ - ctx->rbox->box.v.sync_notify(&ctx->rbox->box, 0, static_cast(0)); - } + mailbox_sync_notify(&ctx->rbox->box, 0, 0); + FUNC_END(); } @@ -530,7 +528,7 @@ int rbox_sync_finish(struct rbox_sync_context **_ctx, bool success) { } else { mail_index_sync_rollback(&ctx->index_sync_ctx); } - + i_info("EXPUNGE: calling deinit"); index_storage_expunging_deinit(&ctx->rbox->box); if (array_is_created(&ctx->expunged_items)) { @@ -544,7 +542,6 @@ int rbox_sync_finish(struct rbox_sync_context **_ctx, bool success) { } array_free(&ctx->expunged_items); } - i_free(ctx); FUNC_END(); return ret;