dovecot-2.2: doveadm: Added several missing error logging calls.

dovecot at dovecot.org dovecot at dovecot.org
Thu Mar 12 10:33:55 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/072170010eac
changeset: 18334:072170010eac
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Mar 12 12:32:30 2015 +0200
description:
doveadm: Added several missing error logging calls.

diffstat:

 src/doveadm/doveadm-mail-deduplicate.c      |   9 +++++++++
 src/doveadm/doveadm-mail-expunge.c          |   9 +++++++++
 src/doveadm/doveadm-mail-index.c            |  22 +++++++++++++++++-----
 src/doveadm/doveadm-mail-iter.c             |   8 +++++++-
 src/doveadm/doveadm-mail-mailbox-metadata.c |   8 +++++++-
 src/doveadm/doveadm-mail-mailbox-status.c   |   2 ++
 6 files changed, 51 insertions(+), 7 deletions(-)

diffs (152 lines):

diff -r 910727378a16 -r 072170010eac src/doveadm/doveadm-mail-deduplicate.c
--- a/src/doveadm/doveadm-mail-deduplicate.c	Wed Mar 11 23:05:34 2015 +0200
+++ b/src/doveadm/doveadm-mail-deduplicate.c	Thu Mar 12 12:32:30 2015 +0200
@@ -49,10 +49,16 @@
 	while (mailbox_search_next(search_ctx, &mail))
 		mail_expunge(mail);
 	if (mailbox_search_deinit(&search_ctx) < 0) {
+		i_error("Searching mailbox '%s' failed: %s",
+			mailbox_get_vname(box),
+			mailbox_get_last_error(box, NULL));
 		doveadm_mail_failed_mailbox(_ctx, box);
 		ret = -1;
 	}
 	if (mailbox_transaction_commit(&trans) < 0) {
+		i_error("Committing mailbox '%s' transaction failed: %s",
+			mailbox_get_vname(box),
+			mailbox_get_last_error(box, NULL));
 		doveadm_mail_failed_mailbox(_ctx, box);
 		ret = -1;
 	}
@@ -140,6 +146,9 @@
 	pool_unref(&pool);
 
 	if (mailbox_sync(box, 0) < 0) {
+		i_error("Syncing mailbox '%s' failed: %s",
+			mailbox_get_vname(box),
+			mailbox_get_last_error(box, NULL));
 		doveadm_mail_failed_mailbox(_ctx, box);
 		ret = -1;
 	}
diff -r 910727378a16 -r 072170010eac src/doveadm/doveadm-mail-expunge.c
--- a/src/doveadm/doveadm-mail-expunge.c	Wed Mar 11 23:05:34 2015 +0200
+++ b/src/doveadm/doveadm-mail-expunge.c	Thu Mar 12 12:32:30 2015 +0200
@@ -41,6 +41,9 @@
 	if (doveadm_mail_iter_deinit_keep_box(&iter, &box) < 0)
 		ret = -1;
 	else if (mailbox_sync(box, 0) < 0) {
+		i_error("Syncing mailbox '%s' failed: %s",
+			mailbox_get_vname(box),
+			mailbox_get_last_error(box, NULL));
 		doveadm_mail_failed_mailbox(_ctx, box);
 		ret = -1;
 	}
@@ -49,11 +52,17 @@
 		if (mailbox_delete_empty(box) < 0) {
 			error = mailbox_get_last_mail_error(box);
 			if (error != MAIL_ERROR_EXISTS) {
+				i_error("Deleting mailbox '%s' failed: %s",
+					mailbox_get_vname(box),
+					mailbox_get_last_error(box, NULL));
 				doveadm_mail_failed_mailbox(_ctx, box);
 				ret = -1;
 			}
 		} else {
 			if (mailbox_set_subscribed(box, FALSE) < 0) {
+				i_error("Unsubscribing mailbox '%s' failed: %s",
+					mailbox_get_vname(box),
+					mailbox_get_last_error(box, NULL));
 				doveadm_mail_failed_mailbox(_ctx, box);
 				ret = -1;
 			}
diff -r 910727378a16 -r 072170010eac src/doveadm/doveadm-mail-index.c
--- a/src/doveadm/doveadm-mail-index.c	Wed Mar 11 23:05:34 2015 +0200
+++ b/src/doveadm/doveadm-mail-index.c	Thu Mar 12 12:32:30 2015 +0200
@@ -39,10 +39,16 @@
 	int ret = 0;
 
 	if (mailbox_get_metadata(box, MAILBOX_METADATA_PRECACHE_FIELDS,
-				 &metadata) < 0 ||
-	    mailbox_get_status(box, STATUS_MESSAGES | STATUS_LAST_CACHED_SEQ,
-			       &status) < 0)
+				 &metadata) < 0) {
+		i_error("Mailbox %s: Precache-fields lookup failed: %s",
+			mailbox_get_vname(box), mailbox_get_last_error(box, NULL));
+	}
+	if (mailbox_get_status(box, STATUS_MESSAGES | STATUS_LAST_CACHED_SEQ,
+			       &status) < 0) {
+		i_error("Mailbox %s: Status lookup failed: %s",
+			mailbox_get_vname(box), mailbox_get_last_error(box, NULL));
 		return -1;
+	}
 
 	seq = status.last_cached_seq + 1;
 	if (seq > status.messages) {
@@ -74,10 +80,16 @@
 	}
 	if (doveadm_verbose)
 		printf("\r%u/%u\n", counter, max);
-	if (mailbox_search_deinit(&ctx) < 0)
+	if (mailbox_search_deinit(&ctx) < 0) {
+		i_error("Mailbox %s: Mail search failed: %s",
+			mailbox_get_vname(box), mailbox_get_last_error(box, NULL));
 		ret = -1;
-	if (mailbox_transaction_commit(&trans) < 0)
+	}
+	if (mailbox_transaction_commit(&trans) < 0) {
+		i_error("Mailbox %s: Transaction commit failed: %s",
+			mailbox_get_vname(box), mailbox_get_last_error(box, NULL));
 		ret = -1;
+	}
 	return ret;
 }
 
diff -r 910727378a16 -r 072170010eac src/doveadm/doveadm-mail-iter.c
--- a/src/doveadm/doveadm-mail-iter.c	Wed Mar 11 23:05:34 2015 +0200
+++ b/src/doveadm/doveadm-mail-iter.c	Thu Mar 12 12:32:30 2015 +0200
@@ -99,8 +99,14 @@
 	*_iter = NULL;
 
 	ret = doveadm_mail_iter_deinit_transaction(iter, commit);
-	if (ret == 0 && sync)
+	if (ret == 0 && sync) {
 		ret = mailbox_sync(iter->box, 0);
+		if (ret < 0) {
+			i_error("Mailbox %s: Mailbox sync failed: %s",
+				mailbox_get_vname(iter->box),
+				mailbox_get_last_error(iter->box, NULL));
+		}
+	}
 	if (ret < 0)
 		doveadm_mail_failed_mailbox(iter->ctx, iter->box);
 	if (!keep_box)
diff -r 910727378a16 -r 072170010eac src/doveadm/doveadm-mail-mailbox-metadata.c
--- a/src/doveadm/doveadm-mail-mailbox-metadata.c	Wed Mar 11 23:05:34 2015 +0200
+++ b/src/doveadm/doveadm-mail-mailbox-metadata.c	Thu Mar 12 12:32:30 2015 +0200
@@ -212,7 +212,13 @@
 	iter = mailbox_attribute_iter_init(box, type, ctx->key);
 	while ((key = mailbox_attribute_iter_next(iter)) != NULL)
 		doveadm_print(key);
-	return mailbox_attribute_iter_deinit(&iter);
+	if (mailbox_attribute_iter_deinit(&iter) < 0) {
+		i_error("Mailbox %s: Failed to iterate mailbox attributes: %s",
+			mailbox_get_vname(box),
+			mailbox_get_last_error(box, NULL));
+		return -1;
+	}
+	return 0;
 }
 
 static int
diff -r 910727378a16 -r 072170010eac src/doveadm/doveadm-mail-mailbox-status.c
--- a/src/doveadm/doveadm-mail-mailbox-status.c	Wed Mar 11 23:05:34 2015 +0200
+++ b/src/doveadm/doveadm-mail-mailbox-status.c	Thu Mar 12 12:32:30 2015 +0200
@@ -129,6 +129,8 @@
 	box = doveadm_mailbox_find(ctx->ctx.cur_mail_user, info->vname);
 	if (mailbox_get_status(box, ctx->status_items, &status) < 0 ||
 	    mailbox_get_metadata(box, ctx->metadata_items, &metadata) < 0) {
+		i_error("Mailbox %s: Failed to lookup mailbox status: %s",
+			mailbox_get_vname(box), mailbox_get_last_error(box, NULL));
 		doveadm_mail_failed_mailbox(&ctx->ctx, box);
 		mailbox_free(&box);
 		return -1;


More information about the dovecot-cvs mailing list