--- qmail-send.c.orig 1998-06-15
+++ qmail-send.c 2007-03-21
--- .././qmail-1.03/qmail-send.c Mon Jun 15 12:53:16 1998
+++ ../qmail-1.03.2418/qmail-send.c Wed Dec 8 21:28:40 2004
@@ -32,6 +32,8 @@
#include "fmtqfn.h"
#include "readsubdir.h"
+#define BIGTODO
+
/* critical timing feature #1: if not triggered, do not busy-loop */
/* critical timing feature #2: if triggered, respond within fixed time */
/* important timing feature: when triggered, respond instantly */
@@ -43,6 +45,7 @@
#define OSSIFIED 129600 /* 36 hours; _must_ exceed q-q's DEATH (24 hours) */
int lifetime = 604800;
+int bouncemaxbytes = 0;
stralloc percenthack = {0};
struct constmap mappercenthack;
@@ -96,7 +99,11 @@
}
void fnmake_info(id) unsigned long id; { fn.len = fmtqfn(fn.s,"info/",id,1); }
+#ifdef BIGTODO
+void fnmake_todo(id) unsigned long id; { fn.len = fmtqfn(fn.s,"todo/",id,1); }
+#else
void fnmake_todo(id) unsigned long id; { fn.len = fmtqfn(fn.s,"todo/",id,0); }
+#endif
void fnmake_mess(id) unsigned long id; { fn.len = fmtqfn(fn.s,"mess/",id,1); }
void fnmake_foop(id) unsigned long id; { fn.len = fmtqfn(fn.s,"foop/",id,0); }
void fnmake_split(id) unsigned long id; { fn.len = fmtqfn(fn.s,"",id,1); }
@@ -683,6 +690,8 @@
}
if (str_equal(sender.s,"#@[]"))
log3("triple bounce: discarding ",fn2.s,"\n");
+ else if (!*sender.s && *doublebounceto.s == '@')
+ log3("double bounce: discarding ",fn2.s,"\n");
else
{
if (qmail_open(&qqt) == -1)
@@ -740,9 +749,25 @@
qmail_fail(&qqt);
else
{
- substdio_fdbuf(&ssread,read,fd,inbuf,sizeof(inbuf));
- while ((r = substdio_get(&ssread,buf,sizeof(buf))) > 0)
- qmail_put(&qqt,buf,r);
+ if (bouncemaxbytes)
+ {
+ int bytestogo = bouncemaxbytes;
+ int bytestoget = (bytestogo < sizeof buf) ? bytestogo : sizeof buf;
+ substdio_fdbuf(&ssread,read,fd,inbuf,sizeof(inbuf));
+ while (bytestoget > 0 && (r = substdio_get(&ssread,buf,bytestoget)) > 0) {
+ qmail_put(&qqt,buf,r);
+ bytestogo -= bytestoget;
+ bytestoget = (bytestogo < sizeof buf) ? bytestogo : sizeof buf;
+ }
+ if (r > 0)
+ qmail_puts(&qqt,"\n\n--- Rest of message truncated.\n");
+ }
+ else /* preserve default behavior */
+ {
+ substdio_fdbuf(&ssread,read,fd,inbuf,sizeof(inbuf));
+ while ((r = substdio_get(&ssread,buf,sizeof(buf))) > 0)
+ qmail_put(&qqt,buf,r);
+ }
close(fd);
if (r == -1)
qmail_fail(&qqt);
@@ -1216,7 +1241,12 @@
/* this file is too long ---------------------------------------------- TODO */
datetime_sec nexttodorun;
+#ifdef BIGTODO
+int flagtododir = 0; /* if 0, have to readsubdir_init again */
+readsubdir todosubdir;
+#else
DIR *tododir; /* if 0, have to opendir again */
+#endif
stralloc todoline = {0};
char todobuf[SUBSTDIO_INSIZE];
char todobufinfo[512];
@@ -1224,7 +1254,11 @@
void todo_init()
{
+#ifdef BIGTODO
+ flagtododir = 0;
+#else
tododir = 0;
+#endif
nexttodorun = now();
trigger_set();
}
@@ -1236,7 +1270,11 @@
{
if (flagexitasap) return;
trigger_selprep(nfds,rfds);
+#ifdef BIGTODO
+ if (flagtododir) *wakeup = 0;
+#else
if (tododir) *wakeup = 0;
+#endif
if (*wakeup > nexttodorun) *wakeup = nexttodorun;
}
@@ -1253,8 +1291,12 @@
char ch;
int match;
unsigned long id;
+#ifdef BIGTODO
+ int z;
+#else
unsigned int len;
direntry *d;
+#endif
int c;
unsigned long uid;
unsigned long pid;
@@ -1265,21 +1307,43 @@
if (flagexitasap) return;
+#ifdef BIGTODO
+ if (!flagtododir)
+#else
if (!tododir)
+#endif
{
if (!trigger_pulled(rfds))
- if (recent < nexttodorun)
- return;
+ {
+ if (recent < nexttodorun)
+ return;
+ }
trigger_set();
+#ifdef BIGTODO
+ readsubdir_init(&todosubdir, "todo", pausedir);
+ flagtododir = 1;
+#else
tododir = opendir("todo");
if (!tododir)
{
pausedir("todo");
return;
}
+#endif
nexttodorun = recent + SLEEP_TODO;
}
+#ifdef BIGTODO
+ switch(readsubdir_next(&todosubdir, &id))
+ {
+ case 1:
+ break;
+ case 0:
+ flagtododir = 0;
+ default:
+ return;
+ }
+#else
d = readdir(tododir);
if (!d)
{
@@ -1291,6 +1355,7 @@
if (str_equal(d->d_name,"..")) return;
len = scan_ulong(d->d_name,&id);
if (!len || d->d_name[len]) return;
+#endif
fnmake_todo(id);
@@ -1448,6 +1513,7 @@
if (control_rldef(&envnoathost,"control/envnoathost",1,"envnoathost") != 1) return 0;
if (control_rldef(&bouncefrom,"control/bouncefrom",0,"MAILER-DAEMON") != 1) return 0;
if (control_rldef(&bouncehost,"control/bouncehost",1,"bouncehost") != 1) return 0;
+ if (control_readint(&bouncemaxbytes,"control/bouncemaxbytes") == -1) return 0;
if (control_rldef(&doublebouncehost,"control/doublebouncehost",1,"doublebouncehost") != 1) return 0;
if (control_rldef(&doublebounceto,"control/doublebounceto",0,"postmaster") != 1) return 0;
if (!stralloc_cats(&doublebounceto,"@")) return 0;
@@ -1478,6 +1544,14 @@
if (control_readfile(&newlocals,"control/locals",1) != 1)
{ log1("alert: unable to reread control/locals\n"); return; }
+ if (control_readint(&concurrency[0],"control/concurrencylocal") == -1)
+ { log1("alert: unable to reread control/concurrencylocal\n",0); return; }
+ if (control_readint(&concurrency[1],"control/concurrencyremote") == -1)
+ { log1("alert: unable to reread control/concurrencyremote\n",0); return; }
+ if (control_readint(&lifetime,"control/queuelifetime") == -1)
+ { log1("alert: unable to reread control/queuelifetime\n",0); return; }
+ r = control_readfile(&newvdoms,"control/virtualdomains",0);
+ r = control_readfile(&newvdoms,"control/virtualdomains",0);
r = control_readfile(&newvdoms,"control/virtualdomains",0);
if (r == -1)
{ log1("alert: unable to reread control/virtualdomains\n"); return; }
syntax highlighted by Code2HTML, v. 0.9.1