chiark
/
gitweb
/
~ian
/
inn-innduct.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use libinn for die (rename fatal -> die)
[inn-innduct.git]
/
backends
/
innduct.c
diff --git
a/backends/innduct.c
b/backends/innduct.c
index 00bbe2d141308446dc4fadfa456ed4e8f8b05e1e..5da5600aecd1620f6bc12ff08fe29d51caa50f5b 100644
(file)
--- a/
backends/innduct.c
+++ b/
backends/innduct.c
@@
-225,8
+225,8
@@
perl -ne 'print if m/-8\<-/..m/-\>8-/; print "\f" if m/-\^L-/' backends/innduct.
#define NORET_PRINTF(f,a) __attribute__((__noreturn__,__format__(printf,f,a)))
#define NORET __attribute__((__noreturn__))
#define NORET_PRINTF(f,a) __attribute__((__noreturn__,__format__(printf,f,a)))
#define NORET __attribute__((__noreturn__))
-#define NEW(ptr) ((ptr)= z
m
malloc(sizeof(*(ptr))))
-#define NEW_DECL(type,ptr) type ptr = z
m
malloc(sizeof(*(ptr)))
+#define NEW(ptr) ((ptr)= z
x
malloc(sizeof(*(ptr))))
+#define NEW_DECL(type,ptr) type ptr = z
x
malloc(sizeof(*(ptr)))
#define DUMPV(fmt,pfx,v) fprintf(f, " " #v "=" fmt, pfx v);
#define DUMPV(fmt,pfx,v) fprintf(f, " " #v "=" fmt, pfx v);
@@
-608,10
+608,8
@@
static int innduct_fatal_cleanup(void) { return 12; } /* used for libinn die */
DIEWRAP(syscrash, " critical", LOG_CRIT, errno, 16);
DIEWRAP(crash, " critical", LOG_CRIT, -1, 16);
DIEWRAP(syscrash, " critical", LOG_CRIT, errno, 16);
DIEWRAP(crash, " critical", LOG_CRIT, -1, 16);
-DIEWRAP(sysfatal, " fatal", LOG_ERR, errno, 12);
-DIEWRAP(fatal, " fatal", LOG_ERR, -1, 12);
-
#define INNLOGWRAPS(INNLOGWRAP) \
#define INNLOGWRAPS(INNLOGWRAP) \
+ INNLOGWRAP(die, " fatal", LOG_ERR) \
INNLOGWRAP(warn, " warning", LOG_WARNING) \
INNLOGWRAP(notice, " notice", LOG_NOTICE)
INNLOGWRAPS(INNLOGWRAP_DECLARE)
INNLOGWRAP(warn, " warning", LOG_WARNING) \
INNLOGWRAP(notice, " notice", LOG_NOTICE)
INNLOGWRAPS(INNLOGWRAP_DECLARE)
@@
-631,7
+629,7
@@
static char *mvasprintf(const char *fmt, va_list al) PRINTF(1,0);
static char *mvasprintf(const char *fmt, va_list al) {
char *str;
int rc= vasprintf(&str,fmt,al);
static char *mvasprintf(const char *fmt, va_list al) {
char *str;
int rc= vasprintf(&str,fmt,al);
- if (rc<0) sys
fatal
("vasprintf(\"%s\",...) failed", fmt);
+ if (rc<0) sys
die
("vasprintf(\"%s\",...) failed", fmt);
return str;
}
static char *masprintf(const char *fmt, ...) PRINTF(1,2);
return str;
}
static char *masprintf(const char *fmt, ...) PRINTF(1,2);
@@
-662,7
+660,7
@@
static pid_t mfork(const char *what) {
pid_t child;
child= fork();
pid_t child;
child= fork();
- if (child==-1) sys
fatal
("cannot fork for %s",what);
+ if (child==-1) sys
die
("cannot fork for %s",what);
dbg("forked %s %ld", what, (unsigned long)child);
if (!child) postfork();
return child;
dbg("forked %s %ld", what, (unsigned long)child);
if (!child) postfork();
return child;
@@
-711,14
+709,8
@@
static int mwaitpid(pid_t *pid, const char *what) {
return status;
}
return status;
}
-static void *mmalloc(size_t sz) {
- void *p= malloc(sz);
- if (!p) sysfatal("unable to malloc %lu bytes",(unsigned long)sz);
- return p;
-}
-
-static void *zmmalloc(size_t sz) {
- void *p= mmalloc(sz);
+static void *zxmalloc(size_t sz) {
+ void *p= xmalloc(sz);
memset(p,0,sz);
return p;
}
memset(p,0,sz);
return p;
}
@@
-1354,7
+1346,7
@@
static void *connchild_event(oop_source *lp, int fd, oop_event e, void *u) {
case CONNCHILD_ESTATUS_STREAM: conn->stream= 1; break;
case CONNCHILD_ESTATUS_NOSTREAM: conn->stream= 0; break;
default:
case CONNCHILD_ESTATUS_STREAM: conn->stream= 1; break;
case CONNCHILD_ESTATUS_NOSTREAM: conn->stream= 0; break;
default:
-
fatal
("connect: child gave unexpected exit status %d", es);
+
die
("connect: child gave unexpected exit status %d", es);
}
/* Phew! */
}
/* Phew! */
@@
-1421,37
+1413,37
@@
static void connect_start(void) {
--l;
}
if (!buf[0]) {
--l;
}
if (!buf[0]) {
- sys
fatal
("connect: connection attempt failed");
+ sys
die
("connect: connection attempt failed");
} else {
buf[l]= 0;
} else {
buf[l]= 0;
-
fatal
("connect: %s: %s", stripped ? "rejected" : "failed",
-
sanitise(buf,-1));
+
die
("connect: %s: %s", stripped ? "rejected" : "failed",
+ sanitise(buf,-1));
}
}
if (NNTPsendpassword((char*)remote_host, cn_from, cn_to) < 0)
}
}
if (NNTPsendpassword((char*)remote_host, cn_from, cn_to) < 0)
- sys
fatal
("connect: authentication failed");
+ sys
die
("connect: authentication failed");
if (try_stream) {
if (fputs("MODE STREAM\r\n", cn_to)==EOF ||
fflush(cn_to))
if (try_stream) {
if (fputs("MODE STREAM\r\n", cn_to)==EOF ||
fflush(cn_to))
- sys
fatal
("connect: could not send MODE STREAM");
+ sys
die
("connect: could not send MODE STREAM");
buf[sizeof(buf)-1]= 0;
if (!fgets(buf, sizeof(buf)-1, cn_from)) {
if (ferror(cn_from))
buf[sizeof(buf)-1]= 0;
if (!fgets(buf, sizeof(buf)-1, cn_from)) {
if (ferror(cn_from))
- sys
fatal
("connect: could not read response to MODE STREAM");
+ sys
die
("connect: could not read response to MODE STREAM");
else
else
-
fatal
("connect: connection close in response to MODE STREAM");
+
die
("connect: connection close in response to MODE STREAM");
}
int l= strlen(buf);
assert(l>=1);
if (buf[l-1]!='\n')
}
int l= strlen(buf);
assert(l>=1);
if (buf[l-1]!='\n')
-
fatal
("connect: response to MODE STREAM is too long: %.100s...",
-
sanitise(buf,-1));
+
die
("connect: response to MODE STREAM is too long: %.100s...",
+ sanitise(buf,-1));
l--; if (l>0 && buf[l-1]=='\r') l--;
buf[l]= 0;
char *ep;
int rcode= strtoul(buf,&ep,10);
if (ep != &buf[3])
l--; if (l>0 && buf[l-1]=='\r') l--;
buf[l]= 0;
char *ep;
int rcode= strtoul(buf,&ep,10);
if (ep != &buf[3])
-
fatal
("connect: bad response to MODE STREAM: %.50s", sanitise(buf,-1));
+
die
("connect: bad response to MODE STREAM: %.50s", sanitise(buf,-1));
switch (rcode) {
case 203:
switch (rcode) {
case 203:
@@
-1620,7
+1612,7
@@
static void article_defer(Article *art /* not on a queue */, int whichcount) {
open_defer();
if (fprintf(defer, "%s %s\n", TokenToText(art->token), art->messageid) <0
|| fflush(defer))
open_defer();
if (fprintf(defer, "%s %s\n", TokenToText(art->token), art->messageid) <0
|| fflush(defer))
- sys
fatal
("write to defer file %s",path_defer);
+ sys
die
("write to defer file %s",path_defer);
article_done(art, whichcount);
}
article_done(art, whichcount);
}
@@
-2081,11
+2073,11
@@
static InputFile *open_input_file(const char *path) {
int fd= open(path, O_RDWR);
if (fd<0) {
if (errno==ENOENT) return 0;
int fd= open(path, O_RDWR);
if (fd<0) {
if (errno==ENOENT) return 0;
- sys
fatal
("unable to open input file %s", path);
+ sys
die
("unable to open input file %s", path);
}
assert(fd>0);
}
assert(fd>0);
- InputFile *ipf=
m
malloc(sizeof(*ipf) + strlen(path) + 1);
+ InputFile *ipf=
x
malloc(sizeof(*ipf) + strlen(path) + 1);
memset(ipf,0,sizeof(*ipf));
ipf->fd= fd;
memset(ipf,0,sizeof(*ipf));
ipf->fd= fd;
@@
-2180,7
+2172,7
@@
static void *feedfile_got_article(oop_source *lp, oop_read *rd,
ipf->readcount_ok++;
ipf->readcount_ok++;
- art=
m
malloc(sizeof(*art) - 1 + midlen + 1);
+ art=
x
malloc(sizeof(*art) - 1 + midlen + 1);
memset(art,0,sizeof(*art));
art->state= art_Unchecked;
art->midlen= midlen;
memset(art,0,sizeof(*art));
art->state= art_Unchecked;
art->midlen= midlen;
@@
-2295,7
+2287,7
@@
struct Filemon_Perfile {
static void filemon_method_startfile(InputFile *ipf, Filemon_Perfile *pf) {
int wd= inotify_add_watch(filemon_inotify_fd, ipf->path, IN_MODIFY);
static void filemon_method_startfile(InputFile *ipf, Filemon_Perfile *pf) {
int wd= inotify_add_watch(filemon_inotify_fd, ipf->path, IN_MODIFY);
- if (wd < 0) sys
fatal
("inotify_add_watch %s", ipf->path);
+ if (wd < 0) sys
die
("inotify_add_watch %s", ipf->path);
if (wd >= filemon_inotify_wdmax) {
int newmax= wd+2;
if (wd >= filemon_inotify_wdmax) {
int newmax= wd+2;
@@
-2565,7
+2557,7
@@
static void statemc_lock(void) {
for (;;) {
lockfd= open(path_lock, O_CREAT|O_RDWR, 0600);
for (;;) {
lockfd= open(path_lock, O_CREAT|O_RDWR, 0600);
- if (lockfd<0) sys
fatal
("open lockfile %s", path_lock);
+ if (lockfd<0) sys
die
("open lockfile %s", path_lock);
struct flock fl;
memset(&fl,0,sizeof(fl));
struct flock fl;
memset(&fl,0,sizeof(fl));
@@
-2575,9
+2567,9
@@
static void statemc_lock(void) {
if (r==-1) {
if (errno==EACCES || isewouldblock(errno)) {
if (quiet_multiple) exit(0);
if (r==-1) {
if (errno==EACCES || isewouldblock(errno)) {
if (quiet_multiple) exit(0);
-
fatal
("another duct holds the lockfile");
+
die
("another duct holds the lockfile");
}
}
- sys
fatal
("fcntl F_SETLK lockfile %s", path_lock);
+ sys
die
("fcntl F_SETLK lockfile %s", path_lock);
}
mfstat_isreg(lockfd, &stabf, path_lock, "lockfile");
}
mfstat_isreg(lockfd, &stabf, path_lock, "lockfile");
@@
-2600,7
+2592,7
@@
static void statemc_lock(void) {
(unsigned long)self_pid,
sitename, feedfile, remote_host) == EOF ||
fflush(lockfile))
(unsigned long)self_pid,
sitename, feedfile, remote_host) == EOF ||
fflush(lockfile))
- sys
fatal
("write info to lockfile %s", path_lock);
+ sys
die
("write info to lockfile %s", path_lock);
dbg("startup: locked");
}
dbg("startup: locked");
}
@@
-2678,8
+2670,8
@@
static void statemc_start_flush(const char *why) { /* Normal => Flushing */
until_flush);
int r= link(feedfile, path_flushing);
until_flush);
int r= link(feedfile, path_flushing);
- if (r) sys
fatal
("link feedfile %s to flushing file %s",
-
feedfile, path_flushing);
+ if (r) sys
die
("link feedfile %s to flushing file %s",
+ feedfile, path_flushing);
/* => Hardlinked */
munlink(feedfile, "old feedfile link");
/* => Hardlinked */
munlink(feedfile, "old feedfile link");
@@
-2862,7
+2854,7
@@
static void open_defer(void) {
if (defer) return;
defer= fopen(path_defer, "a+");
if (defer) return;
defer= fopen(path_defer, "a+");
- if (!defer) sys
fatal
("could not open defer file %s", path_defer);
+ if (!defer) sys
die
("could not open defer file %s", path_defer);
/* truncate away any half-written records */
/* truncate away any half-written records */
@@
-2898,7
+2890,7
@@
static void open_defer(void) {
path_defer, orgsize - truncto, orgsize, truncto);
if (fflush(defer))
path_defer, orgsize - truncto, orgsize, truncto);
if (fflush(defer))
- sys
fatal
("could not flush defer file %s", path_defer);
+ sys
die
("could not flush defer file %s", path_defer);
if (ftruncate(fileno(defer), truncto))
syscrash("could not truncate defer file %s", path_defer);
if (ftruncate(fileno(defer), truncto))
syscrash("could not truncate defer file %s", path_defer);
@@
-2917,7
+2909,7
@@
static void close_defer(void) {
struct stat stab;
mfstat_isreg(fileno(defer), &stab, path_defer, "defer file");
struct stat stab;
mfstat_isreg(fileno(defer), &stab, path_defer, "defer file");
- if (fclose(defer)) sys
fatal
("could not close defer file %s", path_defer);
+ if (fclose(defer)) sys
die
("could not close defer file %s", path_defer);
defer= 0;
time_t now= mtime();
defer= 0;
time_t now= mtime();
@@
-2926,8
+2918,8
@@
static void close_defer(void) {
(unsigned long)now,
(unsigned long)stab.st_ino);
if (link(path_defer, backlog))
(unsigned long)now,
(unsigned long)stab.st_ino);
if (link(path_defer, backlog))
- sys
fatal
("could not install defer file %s as backlog file %s",
-
path_defer, backlog);
+ sys
die
("could not install defer file %s as backlog file %s",
+ path_defer, backlog);
if (unlink(path_defer))
syscrash("could not unlink old defer link %s to backlog file %s",
path_defer, backlog);
if (unlink(path_defer))
syscrash("could not unlink old defer link %s to backlog file %s",
path_defer, backlog);
@@
-2962,9
+2954,9
@@
static void search_backlog_file(void) {
switch (r) {
case GLOB_ABORTED:
switch (r) {
case GLOB_ABORTED:
- sys
fatal
("failed to expand backlog pattern %s", globpat_backlog);
+ sys
die
("failed to expand backlog pattern %s", globpat_backlog);
case GLOB_NOSPACE:
case GLOB_NOSPACE:
-
fatal
("out of memory expanding backlog pattern %s", globpat_backlog);
+
die
("out of memory expanding backlog pattern %s", globpat_backlog);
case 0:
for (i=0; i<gl.gl_pathc; i++) {
const char *path= gl.gl_pathv[i];
case 0:
for (i=0; i<gl.gl_pathc; i++) {
const char *path= gl.gl_pathv[i];
@@
-3097,7
+3089,7
@@
static void init_signals(void) {
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
syscrash("could not ignore SIGPIPE");
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
syscrash("could not ignore SIGPIPE");
- if (pipe(signal_self_pipe)) sys
fatal
("create self-pipe for signals");
+ if (pipe(signal_self_pipe)) sys
die
("create self-pipe for signals");
msetnonblock(signal_self_pipe[0],1);
msetnonblock(signal_self_pipe[1],1);
msetnonblock(signal_self_pipe[0],1);
msetnonblock(signal_self_pipe[1],1);
@@
-3205,7
+3197,7
@@
void spawn_inndcomm_flush(const char *why) { /* Moved => Flushing */
assert(!inndcomm_child);
assert(!inndcomm_sentinel_fd);
assert(!inndcomm_child);
assert(!inndcomm_sentinel_fd);
- if (pipe(pipefds)) sys
fatal
("create pipe for inndcomm child sentinel");
+ if (pipe(pipefds)) sys
die
("create pipe for inndcomm child sentinel");
inndcomm_child= mfork("inndcomm child");
inndcomm_child= mfork("inndcomm child");
@@
-3844,7
+3836,7
@@
int main(int argc, char **argv) {
if (interactive < 1) {
int null= open("/dev/null",O_RDWR);
if (interactive < 1) {
int null= open("/dev/null",O_RDWR);
- if (null<0) sys
fatal
("failed to open /dev/null");
+ if (null<0) sys
die
("failed to open /dev/null");
dup2(null,0);
dup2(null,1);
dup2(null,2);
dup2(null,0);
dup2(null,1);
dup2(null,2);
@@
-3854,7
+3846,7
@@
int main(int argc, char **argv) {
if (child1) _exit(0);
pid_t sid= setsid();
if (child1) _exit(0);
pid_t sid= setsid();
- if (sid == -1) sys
fatal
("setsid failed");
+ if (sid == -1) sys
die
("setsid failed");
pid_t child2= mfork("daemonise second fork");
if (child2) _exit(0);
pid_t child2= mfork("daemonise second fork");
if (child2) _exit(0);
@@
-3864,7
+3856,7
@@
int main(int argc, char **argv) {
if (self_pid==-1) syscrash("getpid");
r= chdir(path_run);
if (self_pid==-1) syscrash("getpid");
r= chdir(path_run);
- if (r) sys
fatal
("could not chdir to pathrun %s", path_run);
+ if (r) sys
die
("could not chdir to pathrun %s", path_run);
statemc_lock();
statemc_lock();
@@
-3874,7
+3866,7
@@
int main(int argc, char **argv) {
int val= 1;
r= SMsetup(SM_PREOPEN, &val); if (!r) warn("SMsetup SM_PREOPEN failed");
int val= 1;
r= SMsetup(SM_PREOPEN, &val); if (!r) warn("SMsetup SM_PREOPEN failed");
- r= SMinit(); if (!r)
fatal
("storage manager initialisation (SMinit) failed");
+ r= SMinit(); if (!r)
die
("storage manager initialisation (SMinit) failed");
if (interactive >= 2)
cli_stdio();
if (interactive >= 2)
cli_stdio();