dovecot-2.2: expire: Handle dict errors. Don't crash if lookup f...

dovecot at dovecot.org dovecot at dovecot.org
Sun May 20 03:26:36 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/8f72002cb394
changeset: 14572:8f72002cb394
user:      Timo Sirainen <tss at iki.fi>
date:      Sat May 19 22:11:41 2012 +0300
description:
expire: Handle dict errors. Don't crash if lookup fails.
Based on patch by Michal Grzedzicki

diffstat:

 src/plugins/expire/expire-plugin.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 42cca8a1d179 -r 8f72002cb394 src/plugins/expire/expire-plugin.c
--- a/src/plugins/expire/expire-plugin.c	Sat May 19 21:18:04 2012 +0300
+++ b/src/plugins/expire/expire-plugin.c	Sat May 19 22:11:41 2012 +0300
@@ -162,8 +162,14 @@
 			   this is the first mail in the database */
 			ret = dict_lookup(euser->db, pool_datastack_create(),
 					  key, &value);
-			if (ret == 0) {
-				/* first time saving here with expire enabled */
+			if (ret <= 0) {
+				/* first time saving here with expire enabled.
+				   also handle lookup errors by just assuming
+				   it didn't exist */
+				if (ret < 0) {
+					i_warning("expire: dict lookup failed, "
+						  "assuming update is needed");
+				}
 				first_save_timestamp(box, &new_stamp);
 				update_dict = TRUE;
 			} else if (strcmp(value, "0") == 0) {
@@ -188,7 +194,8 @@
 
 			dctx = dict_transaction_begin(euser->db);
 			dict_set(dctx, key, dec2str(new_stamp));
-			dict_transaction_commit(&dctx);
+			if (dict_transaction_commit(&dctx) < 0)
+				i_error("expire: dict commit failed");
 		}
 	} T_END;
 	i_free(xt);


More information about the dovecot-cvs mailing list