changeset 492:9bb06d43c025

Lets not resend single failed mails forever
author mmj
date Tue, 03 May 2005 17:50:31 +1000
parents ef654aa76965
children 52be16e46e2b
files src/mlmmj-maintd.c
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/mlmmj-maintd.c	Tue May 03 05:29:55 2005 +1000
+++ b/src/mlmmj-maintd.c	Tue May 03 17:50:31 2005 +1000
@@ -209,9 +209,11 @@
 	struct dirent *dp;
 	char *mailname, *fromname, *toname, *reptoname, *from, *to, *repto;
 	char *ch, *dirname = concatstr(2, listdir, "/queue/");
+	char *bouncelifestr;
 	pid_t childpid, pid;
 	struct stat st;
 	int fromfd, tofd, fd, discarded = 0, status;
+	time_t t, bouncelife = 0;
 
 	if(chdir(dirname) < 0) {
 		log_error(LOG_ARGS, "Could not chdir(%s)", dirname);
@@ -292,6 +294,21 @@
 			myfree(reptoname);
 		}
 
+		/* before we try again, check and see if it's old */
+		bouncelifestr = ctrlvalue(listdir, "bouncelife");
+		if(bouncelifestr) {
+			bouncelife = atol(bouncelifestr);
+			myfree(bouncelifestr);
+		}
+		if(bouncelife == 0)
+			bouncelife = BOUNCELIFE;
+
+		t = time(NULL);
+		if(t - st.st_mtime > bouncelife) {
+			unlink(mailname);
+			continue;
+		}
+
 		childpid = fork();
 
 		if(childpid < 0) {