summaryrefslogtreecommitdiff
path: root/src/qmail-todo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmail-todo.c')
-rw-r--r--src/qmail-todo.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/src/qmail-todo.c b/src/qmail-todo.c
index a26365d..d2f29d5 100644
--- a/src/qmail-todo.c
+++ b/src/qmail-todo.c
@@ -53,25 +53,25 @@ int flagquitasap = 0;
void sendlog1(char *x);
void sendlog3(char *x, char *y, char *z);
-void sigterm(void)
+static void sigterm()
{
if (flagquitasap == 0) sendlog1("status: qmail-todo stop processing asap\n");
flagquitasap = 1;
}
int flagreadasap = 0;
-void sighup(void)
+static void sighup()
{
flagreadasap = 1;
}
int flagsendalive = 1;
-void senddied(void)
+static void senddied()
{
flagsendalive = 0;
}
-void cleandied()
+static void cleandied()
{
sendlog1("alert: qmail-todo lost connection to qmail-clean ... exiting\n");
flagquitasap = 1;
@@ -82,27 +82,33 @@ void cleandied()
stralloc fn = {0};
-void fnmake_init(void)
+static void nomem()
+{
+ log1s("alert: out of memory, sleeping...\n");
+ sleep(10);
+}
+
+static void fnmake_init()
{
while (!stralloc_ready(&fn, FMTQFN)) nomem();
}
-void fnmake_info(unsigned long id)
+static void fnmake_info(unsigned long id)
{
fn.len = fmtqfn(fn.s, "info/", id, 1);
}
-void fnmake_todo(unsigned long id)
+static void fnmake_todo(unsigned long id)
{
fn.len = fmtqfn(fn.s, "todo/", id, 1);
}
-void fnmake_mess(unsigned long id)
+static void fnmake_mess(unsigned long id)
{
fn.len = fmtqfn(fn.s, "mess/", id, 1);
}
-void fnmake_chanaddr(unsigned long id, int c)
+static void fnmake_chanaddr(unsigned long id, int c)
{
fn.len = fmtqfn(fn.s, chanaddr[c], id, 1);
}
@@ -115,7 +121,7 @@ stralloc rwline = {0};
/* 1 if by land, 2 if by sea, 0 if out of memory. not allowed to barf. */
/* may trash recip. must set up rwline, between a T and a \0. */
-int rewrite(char *recip)
+static int rewrite(char *recip)
{
int i;
int j;
@@ -209,7 +215,7 @@ FAIL:
comm_buf.len = pos;
}
-void comm_init(void)
+static void comm_init(void)
{
buffer_init(&toqc, write, 2, toqcbuf, sizeof(toqcbuf));
buffer_init(&fromqc, read, 3, fromqcbuf, sizeof(fromqcbuf));
@@ -222,7 +228,7 @@ void comm_init(void)
while (!stralloc_ready(&comm_buf, 1024)) nomem();
}
-int comm_canwrite(void)
+static int comm_canwrite(void)
{
/* XXX: could allow a bigger buffer; say 10 recipients */
/* XXX: returns true if there is something in the buffer */
@@ -231,7 +237,7 @@ int comm_canwrite(void)
return 0;
}
-void comm_write(unsigned long id, int local, int remote)
+static void comm_write(unsigned long id, int local, int remote)
{
int pos;
char *s;
@@ -258,7 +264,8 @@ FAIL:
comm_buf.len = pos;
}
-void comm_info(unsigned long id, unsigned long size, char *from, unsigned long pid, unsigned long uid)
+static void comm_info(
+ unsigned long id, unsigned long size, char *from, unsigned long pid, unsigned long uid)
{
int pos;
int i;
@@ -296,14 +303,14 @@ FAIL:
comm_buf.len = pos;
}
-void comm_exit(void)
+static void comm_exit(void)
{
/* if it FAILs exit, we have already stoped */
if (!stralloc_cats(&comm_buf, "X")) _exit(1);
if (!stralloc_0(&comm_buf)) _exit(1);
}
-void comm_selprep(int *nfds, fd_set *wfds, fd_set *rfds)
+static void comm_selprep(int *nfds, fd_set *wfds, fd_set *rfds)
{
if (flagsendalive) {
if (flagquitasap && comm_canwrite() == 0) comm_exit();
@@ -316,7 +323,7 @@ void comm_selprep(int *nfds, fd_set *wfds, fd_set *rfds)
}
}
-void comm_do(fd_set *wfds, fd_set *rfds)
+static void comm_do(fd_set *wfds, fd_set *rfds)
{
/* first write then read */
if (flagsendalive) {
@@ -367,14 +374,14 @@ char todobuf[BUFFER_INSIZE];
char todobufinfo[512];
char todobufchan[CHANNELS][1024];
-void todo_init(void)
+static void todo_init(void)
{
flagtododir = 0;
nexttodorun = now();
trigger_set();
}
-void todo_selprep(int *nfds, fd_set *rfds, datetime_sec *wakeup)
+static void todo_selprep(int *nfds, fd_set *rfds, datetime_sec *wakeup)
{
if (flagquitasap) return;
trigger_selprep(nfds, rfds);
@@ -382,7 +389,7 @@ void todo_selprep(int *nfds, fd_set *rfds, datetime_sec *wakeup)
if (*wakeup > nexttodorun) *wakeup = nexttodorun;
}
-void todo_do(fd_set *rfds)
+static void todo_do(fd_set *rfds)
{
struct stat st;
buffer bi;
@@ -578,7 +585,7 @@ FAIL:
/* this file is too long ---------------------------------------------- MAIN */
-int getcontrols(void)
+static int getcontrols(void)
{
if (control_init() == -1) return 0;
if (control_rldef(&envnoathost, "control/envnoathost", 1, "envnoathost") != 1) return 0;
@@ -608,7 +615,7 @@ int getcontrols(void)
stralloc newlocals = {0};
stralloc newvdoms = {0};
-void regetcontrols(void)
+static void regetcontrols(void)
{
int r;
@@ -636,7 +643,7 @@ void regetcontrols(void)
}
}
-void reread(void)
+static void reread(void)
{
if (chdir(auto_qmail) == -1) {
sendlog1("alert: qmail-todo: unable to reread controls: unable to switch to home directory\n");
@@ -682,7 +689,7 @@ int main()
do {
r = read(fdin, &c, 1);
if ((r == -1) && (errno != EINTR)) _exit(100); /* read failed probably qmail-send died */
- } while ((r = !1)); /* we assume it is a 'S' */
+ } while ((r = !1)); /* we assume it is a 'S' */
for (;;) {
recent = now();