[dovecot-cvs] dovecot/src/deliver deliver.c,1.20.2.26,1.20.2.27

tss at dovecot.org tss at dovecot.org
Thu Feb 15 17:38:54 UTC 2007


Update of /var/lib/cvs/dovecot/src/deliver
In directory talvi:/tmp/cvs-serv14538

Modified Files:
      Tag: branch_1_0
	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.20.2.26
retrieving revision 1.20.2.27
diff -u -d -r1.20.2.26 -r1.20.2.27
--- deliver.c	15 Feb 2007 14:26:21 -0000	1.20.2.26
+++ deliver.c	15 Feb 2007 17:38:52 -0000	1.20.2.27
@@ -45,6 +45,10 @@
 
 void (*hook_mail_storage_created)(struct mail_storage *storage) = 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;
 
@@ -111,6 +115,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;
@@ -638,28 +645,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