Mercurial > dovecot > core-2.2
changeset 14572:8f72002cb394
expire: Handle dict errors. Don't crash if lookup fails.
Based on patch by Michal Grzedzicki
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 19 May 2012 22:11:41 +0300 |
parents | 42cca8a1d179 |
children | 23543c407e81 |
files | src/plugins/expire/expire-plugin.c |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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);