Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/plugins/expire/expire-plugin.c @ 6940:414c9d631a81 HEAD
Replaced t_push/t_pop calls with T_FRAME*() macros.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 05 Dec 2007 17:47:44 +0200 |
parents | 1a3604c8ee05 |
children | 7ed926ed7aa4 |
comparison
equal
deleted
inserted
replaced
6939:c7b42fea5fcc | 6940:414c9d631a81 |
---|---|
93 uint32_t *first_saved_uid_r, | 93 uint32_t *first_saved_uid_r, |
94 uint32_t *last_saved_uid_r) | 94 uint32_t *last_saved_uid_r) |
95 { | 95 { |
96 struct expire_mailbox *xpr_box = EXPIRE_CONTEXT(t->box); | 96 struct expire_mailbox *xpr_box = EXPIRE_CONTEXT(t->box); |
97 struct expire_transaction_context *xt = EXPIRE_CONTEXT(t); | 97 struct expire_transaction_context *xt = EXPIRE_CONTEXT(t); |
98 const char *key, *value; | 98 const char *mailbox_name = t->box->name; |
99 time_t new_stamp; | 99 time_t new_stamp; |
100 bool update_dict; | 100 bool update_dict = FALSE; |
101 int ret; | 101 int ret; |
102 | |
103 t_push(); | |
104 key = t_strconcat(DICT_PATH_SHARED, expire.username, "/", | |
105 t->box->name, NULL); | |
106 | 102 |
107 if (xt->first_expunged) { | 103 if (xt->first_expunged) { |
108 /* first mail expunged. dict needs updating. */ | 104 /* first mail expunged. dict needs updating. */ |
109 first_nonexpunged_timestamp(t, &new_stamp); | 105 first_nonexpunged_timestamp(t, &new_stamp); |
110 update_dict = TRUE; | 106 update_dict = TRUE; |
111 } else { | |
112 /* saved new mails. dict needs to be updated only if this is | |
113 the first mail in the database */ | |
114 ret = dict_lookup(expire.db, pool_datastack_create(), | |
115 key, &value); | |
116 update_dict = ret == 0 || strtoul(value, NULL, 10) == 0; | |
117 new_stamp = xt->first_save_time; | |
118 } | 107 } |
119 | 108 |
120 mail_free(&xt->mail); | 109 mail_free(&xt->mail); |
121 i_free(xt); | |
122 | |
123 if (xpr_box->module_ctx.super. | 110 if (xpr_box->module_ctx.super. |
124 transaction_commit(t, uid_validity_r, | 111 transaction_commit(t, uid_validity_r, |
125 first_saved_uid_r, last_saved_uid_r) < 0) { | 112 first_saved_uid_r, last_saved_uid_r) < 0) { |
126 t_pop(); | 113 i_free(xt); |
127 return -1; | 114 return -1; |
128 } | 115 } |
129 | 116 |
130 if (update_dict) { | 117 T_FRAME_BEGIN { |
131 struct dict_transaction_context *dctx; | 118 const char *key, *value; |
132 | 119 |
133 new_stamp += xpr_box->expire_secs; | 120 key = t_strconcat(DICT_PATH_SHARED, expire.username, "/", |
134 | 121 mailbox_name, NULL); |
135 dctx = dict_transaction_begin(expire.db); | 122 if (!xt->first_expunged) { |
136 dict_set(dctx, key, dec2str(new_stamp)); | 123 /* saved new mails. dict needs to be updated only if |
137 dict_transaction_commit(dctx); | 124 this is the first mail in the database */ |
138 } | 125 ret = dict_lookup(expire.db, pool_datastack_create(), |
139 t_pop(); | 126 key, &value); |
127 update_dict = ret == 0 || strtoul(value, NULL, 10) == 0; | |
128 new_stamp = xt->first_save_time; | |
129 } | |
130 | |
131 if (update_dict) { | |
132 struct dict_transaction_context *dctx; | |
133 | |
134 new_stamp += xpr_box->expire_secs; | |
135 | |
136 dctx = dict_transaction_begin(expire.db); | |
137 dict_set(dctx, key, dec2str(new_stamp)); | |
138 dict_transaction_commit(dctx); | |
139 } | |
140 } T_FRAME_END; | |
141 i_free(xt); | |
140 return 0; | 142 return 0; |
141 } | 143 } |
142 | 144 |
143 static void | 145 static void |
144 expire_mailbox_transaction_rollback(struct mailbox_transaction_context *t) | 146 expire_mailbox_transaction_rollback(struct mailbox_transaction_context *t) |