[dovecot-cvs] dovecot/src/deliver deliver.c,1.47,1.48
tss at dovecot.org
tss at dovecot.org
Thu Feb 15 17:38:57 UTC 2007
Update of /var/lib/cvs/dovecot/src/deliver
In directory talvi:/tmp/cvs-serv14534
Modified Files:
deliver.c
Log Message:
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
over quota).
Index: deliver.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/deliver/deliver.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- deliver.c 15 Feb 2007 14:26:24 -0000 1.47
+++ deliver.c 15 Feb 2007 17:38:55 -0000 1.48
@@ -44,6 +44,10 @@
struct deliver_settings *deliver_set;
deliver_mail_func_t *deliver_mail = NULL;
+/* FIXME: these two should be in some context struct instead of as globals.. */
+static const char *default_mailbox_name = NULL;
+static bool tried_default_save = FALSE;
+
static struct module *modules;
static struct ioloop *ioloop;
@@ -109,6 +113,9 @@
const char *msgid;
int ret = 0;
+ if (strcmp(mailbox, default_mailbox_name) == 0)
+ tried_default_save = TRUE;
+
box = mailbox_open_or_create_synced(storage, mailbox);
if (box == NULL)
return -1;
@@ -633,28 +640,31 @@
if (mail_set_seq(mail, 1) < 0)
i_fatal("mail_set_seq() failed");
+ default_mailbox_name = mailbox;
ret = deliver_mail == NULL ? 0 :
deliver_mail(storage, mail, destination, mailbox);
- if (ret <= 0) {
- /* plugins didn't handle this. save into INBOX. */
+ if (ret == 0 || (ret < 0 && !tried_default_save)) {
+ /* plugins didn't handle this. save into the default mailbox. */
i_stream_seek(input, 0);
- if (deliver_save(storage, mailbox, mail, 0, NULL) < 0) {
- const char *error;
- bool syntax, temporary_error;
- int ret;
+ ret = deliver_save(storage, mailbox, mail, 0, NULL);
+ }
- error = mail_storage_get_last_error(storage, &syntax,
- &temporary_error);
- if (temporary_error)
- return EX_TEMPFAIL;
+ if (ret < 0) {
+ const char *error;
+ bool syntax, temporary_error;
+ int ret;
- /* we'll have to reply with permanent failure */
- ret = mail_send_rejection(mail, destination, error);
- if (ret != 0)
- return ret < 0 ? EX_TEMPFAIL : ret;
- /* ok, rejection sent */
- }
+ error = mail_storage_get_last_error(storage, &syntax,
+ &temporary_error);
+ if (temporary_error)
+ return EX_TEMPFAIL;
+
+ /* we'll have to reply with permanent failure */
+ ret = mail_send_rejection(mail, destination, error);
+ if (ret != 0)
+ return ret < 0 ? EX_TEMPFAIL : ret;
+ /* ok, rejection sent */
}
i_stream_unref(&input);
More information about the dovecot-cvs
mailing list