Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/355 fix gzip trailer for empty stream #357

Merged
merged 3 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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([.])
Expand Down
2 changes: 1 addition & 1 deletion rpm/dovecot-ceph-plugin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/storage-rbox/rbox-save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
39 changes: 18 additions & 21 deletions src/storage-rbox/rbox-sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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<mailbox_sync_type>(0));
}
mailbox_sync_notify(&ctx->rbox->box, 0, 0);

FUNC_END();
}

Expand All @@ -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)) {
Expand All @@ -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;
Expand Down