const char *fmt, va_list al) PRINTF(5,0);
static void logv(int sysloglevel, const char *pfx, int errnoval,
const char *fmt, va_list al) {
const char *fmt, va_list al) PRINTF(5,0);
static void logv(int sysloglevel, const char *pfx, int errnoval,
const char *fmt, va_list al) {
vsnprintf(msgbuf,sizeof(msgbuf), fmt,al);
msgbuf[sizeof(msgbuf)-1]= 0;
vsnprintf(msgbuf,sizeof(msgbuf), fmt,al);
msgbuf[sizeof(msgbuf)-1]= 0;
-/* error trapping wrappers are called mfoo rather than the more
- * conventional xfoo because we don't want to clash with the existing
- * xfoo functions in INN libs which use different error handlers
- */
-
-static char *mvasprintf(const char *fmt, va_list al) PRINTF(1,0);
-static char *mvasprintf(const char *fmt, va_list al) {
+static char *xvasprintf(const char *fmt, va_list al) PRINTF(1,0);
+static char *xvasprintf(const char *fmt, va_list al) {
char *str;
int rc= vasprintf(&str,fmt,al);
if (rc<0) sysdie("vasprintf(\"%s\",...) failed", fmt);
return str;
}
char *str;
int rc= vasprintf(&str,fmt,al);
if (rc<0) sysdie("vasprintf(\"%s\",...) failed", fmt);
return str;
}
-static char *masprintf(const char *fmt, ...) PRINTF(1,2);
-static char *masprintf(const char *fmt, ...) {
+static char *xasprintf(const char *fmt, ...) PRINTF(1,2);
+static char *xasprintf(const char *fmt, ...) {
int r= sigaction(signo,sa,0);
if (r) syscrash("sigaction failed for \"%s\"", strsignal(signo));
}
int r= sigaction(signo,sa,0);
if (r) syscrash("sigaction failed for \"%s\"", strsignal(signo));
}
int r= gettimeofday(tv_r,0);
if (r) syscrash("gettimeofday(2) failed");
}
int r= gettimeofday(tv_r,0);
if (r) syscrash("gettimeofday(2) failed");
}
int errnoval= oop_fd_nonblock(fd, nonblocking);
if (errnoval) { errno= errnoval; syscrash("setnonblocking"); }
}
int errnoval= oop_fd_nonblock(fd, nonblocking);
if (errnoval) { errno= errnoval; syscrash("setnonblocking"); }
}
int r= fstat(fd, stab_r);
if (r) syscrash("could not fstat %s", what);
}
int r= fstat(fd, stab_r);
if (r) syscrash("could not fstat %s", what);
}
int *enoent_r /* 0 means ENOENT is fatal */,
const char *what) {
int r= lstat(path, stab);
int *enoent_r /* 0 means ENOENT is fatal */,
const char *what) {
int r= lstat(path, stab);
r= listen(cli_master, 5);
if (r) NOCLI("listen to cli master socket");
r= listen(cli_master, 5);
if (r) NOCLI("listen to cli master socket");
loop->on_fd(loop, cli_master, OOP_READ, cli_master_readable, 0);
info("cli ready, listening on %s", path_cli);
loop->on_fd(loop, cli_master, OOP_READ, cli_master_readable, 0);
info("cli ready, listening on %s", path_cli);
warn("C%d (now %d) connection failed requeueing " RCI_TRIPLE_FMT_BASE ": %s",
conn->fd, conns.count, RCI_TRIPLE_VALS_BASE(requeue, /*nothing*/), m);
free(m);
warn("C%d (now %d) connection failed requeueing " RCI_TRIPLE_FMT_BASE ": %s",
conn->fd, conns.count, RCI_TRIPLE_VALS_BASE(requeue, /*nothing*/), m);
free(m);
if (!(WIFEXITED(status) ||
(WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL)))
report_child_status("connect", status);
}
if (connecting_fdpass_sock) {
cancel_fd_read_except(connecting_fdpass_sock);
if (!(WIFEXITED(status) ||
(WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL)))
report_child_status("connect", status);
}
if (connecting_fdpass_sock) {
cancel_fd_read_except(connecting_fdpass_sock);
int r= socketpair(AF_UNIX, SOCK_STREAM, 0, socks);
if (r) { syswarn("connect: cannot create socketpair for child"); return; }
int r= socketpair(AF_UNIX, SOCK_STREAM, 0, socks);
if (r) { syswarn("connect: cannot create socketpair for child"); return; }
alarm(connection_setup_timeout);
if (NNTPconnect((char*)remote_host, port, &cn_from, &cn_to, buf) < 0) {
alarm(connection_setup_timeout);
if (NNTPconnect((char*)remote_host, port, &cn_from, &cn_to, buf) < 0) {
assert(!ipf->filemon); /* must have had inputfile_reading_stop */
assert(!ipf->rd); /* must have had inputfile_reading_stop */
assert(!ipf->inprogress); /* no dangling pointers pointing here */
assert(!ipf->filemon); /* must have had inputfile_reading_stop */
assert(!ipf->rd); /* must have had inputfile_reading_stop */
assert(!ipf->inprogress); /* no dangling pointers pointing here */
loop->on_fd(loop, filemon_inotify_fd, OOP_READ, filemon_inotify_readable, 0);
dbg("filemon inotify init filemon_inotify_fd=%d", filemon_inotify_fd);
loop->on_fd(loop, filemon_inotify_fd, OOP_READ, filemon_inotify_readable, 0);
dbg("filemon inotify init filemon_inotify_fd=%d", filemon_inotify_fd);
- mfstat_isreg(lockfd, &stabf, path_lock, "lockfile");
+ xfstat_isreg(lockfd, &stabf, path_lock, "lockfile");
- mlstat_isreg(path_lock, &stab, &lock_noent, "lockfile");
+ xlstat_isreg(path_lock, &stab, &lock_noent, "lockfile");
- mlstat_isreg(path_defer, &stabdefer, &defer_noent, "defer file");
+ xlstat_isreg(path_defer, &stabdefer, &defer_noent, "defer file");
- if (file_d) mfstat_isreg(file_d->fd, &stab_d, path_flushing,"flushing file");
+ if (file_d) xfstat_isreg(file_d->fd, &stab_d, path_flushing,"flushing file");
- mlstat_isreg(feedfile, &stab_f, &noent_f, "feedfile");
+ xlstat_isreg(feedfile, &stab_f, &noent_f, "feedfile");
if (!noent_f && file_d && samefile(&stab_f, &stab_d)) {
dbg("startup: F==D => Hardlinked");
if (!noent_f && file_d && samefile(&stab_f, &stab_d)) {
dbg("startup: F==D => Hardlinked");
- ? masprintf("%s","") /* GCC produces a stupid warning for printf("") ! */
- : masprintf(" inprogress=%ld", ipf->inprogress);
+ ? xasprintf("%s","") /* GCC produces a stupid warning for printf("") ! */
+ : xasprintf(" inprogress=%ld", ipf->inprogress);
info("%s %s%s read=%d (+bl=%d,+err=%d)%s%s"
" missing=%d offered=%d (ch=%d,nc=%d) accepted=%d (ch=%d,nc=%d)"
info("%s %s%s read=%d (+bl=%d,+err=%d)%s%s"
" missing=%d offered=%d (ch=%d,nc=%d) accepted=%d (ch=%d,nc=%d)"
- mfstat_isreg(fileno(defer), &stab, path_defer, "newly opened defer file");
+ xfstat_isreg(fileno(defer), &stab, path_defer, "newly opened defer file");
if (stab.st_size > LONG_MAX)
crash("defer file %s size is far too large", path_defer);
if (stab.st_size > LONG_MAX)
crash("defer file %s size is far too large", path_defer);
- mfstat_isreg(fileno(defer), &stab, path_defer, "defer file");
+ xfstat_isreg(fileno(defer), &stab, path_defer, "defer file");
(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))
double age= difftime(now, oldest_mtime);
long age_deficiency= (backlog_retry_minperiods * period_seconds) - age;
double age= difftime(now, oldest_mtime);
long age_deficiency= (backlog_retry_minperiods * period_seconds) - age;
- msetnonblock(signal_self_pipe[0],1);
- msetnonblock(signal_self_pipe[1],1);
+ xsetnonblock(signal_self_pipe[0],1);
+ xsetnonblock(signal_self_pipe[1],1);
struct sigaction sa;
memset(&sa,0,sizeof(sa));
sa.sa_handler= sigarrived_handler;
sa.sa_flags= SA_RESTART;
struct sigaction sa;
memset(&sa,0,sizeof(sa));
sa.sa_handler= sigarrived_handler;
sa.sa_flags= SA_RESTART;
- msigaction(SIGTERM,&sa);
- msigaction(SIGINT,&sa);
+ xsigaction(SIGTERM,&sa);
+ xsigaction(SIGINT,&sa);
static void *inndcomm_event(oop_source *lp, int fd, oop_event e, void *u) {
assert(inndcomm_child);
assert(fd == inndcomm_sentinel_fd);
static void *inndcomm_event(oop_source *lp, int fd, oop_event e, void *u) {
assert(inndcomm_child);
assert(fd == inndcomm_sentinel_fd);
inndcomm_sentinel_fd= pipefds[0];
assert(inndcomm_sentinel_fd);
on_fd_read_except(inndcomm_sentinel_fd, inndcomm_event);
inndcomm_sentinel_fd= pipefds[0];
assert(inndcomm_sentinel_fd);
on_fd_read_except(inndcomm_sentinel_fd, inndcomm_event);
- msigsetdefault(SIGTERM);
- msigsetdefault(SIGINT);
- msigsetdefault(SIGPIPE);
+ xsigsetdefault(SIGTERM);
+ xsigsetdefault(SIGINT);
+ xsigsetdefault(SIGPIPE);
const char *slash= strrchr(ipf->path,'/');
const char *path= slash ? slash+1 : ipf->path;
const char *slash= strrchr(ipf->path,'/');
const char *path= slash ? slash+1 : ipf->path;
- return masprintf("%p/%s:queue=%d,ip=%ld,autodef=%ld,off=%ld,fd=%d%s%s%s",
+ return xasprintf("%p/%s:queue=%d,ip=%ld,autodef=%ld,off=%ld,fd=%d%s%s%s",
ipf, path,
ipf->queue.count, ipf->inprogress, ipf->autodefer,
(long)ipf->offset, ipf->fd,
ipf, path,
ipf->queue.count, ipf->inprogress, ipf->autodefer,
(long)ipf->offset, ipf->fd,
- case xk_Const: dinfo= masprintf("Const"); break;
- case xk_Artdata: dinfo= masprintf("A%p", xd->info.sm_art); break;
+ case xk_Const: dinfo= xasprintf("Const"); break;
+ case xk_Artdata: dinfo= xasprintf("A%p", xd->info.sm_art); break;
static void vbadusage(const char *fmt, va_list al) NORET_PRINTF(1,0);
static void vbadusage(const char *fmt, va_list al) {
static void vbadusage(const char *fmt, va_list al) NORET_PRINTF(1,0);
static void vbadusage(const char *fmt, va_list al) {
fprintf(stderr, "bad usage: %s\n"
"say --help for help, or read the manpage\n",
m);
fprintf(stderr, "bad usage: %s\n"
"say --help for help, or read the manpage\n",
m);
const Option *o;
for (o=options; o->shrt || o->lng; o++) {
char shrt[2] = { o->shrt, 0 };
const Option *o;
for (o=options; o->shrt || o->lng; o++) {
char shrt[2] = { o->shrt, 0 };
o->shrt ? "-" : "", shrt,
o->shrt && o->lng ? "|" : "",
DELIMPERHAPS("--", o->lng));
o->shrt ? "-" : "", shrt,
o->shrt && o->lng ? "|" : "",
DELIMPERHAPS("--", o->lng));
if (!feedfile) feedfile= sitename;
if (!feedfile[0]) badusage("feed filename, if specified, must be nonempty");
if (path_ends_slash(feedfile))
if (!feedfile) feedfile= sitename;
if (!feedfile[0]) badusage("feed filename, if specified, must be nonempty");
if (path_ends_slash(feedfile))
if (!path_cli) {
path_cli_dir= "innduct";
} else if (!path_cli[0] || !strcmp(path_cli,"none")) {
path_cli= 0; /* ok, don't then */
} else if (path_ends_slash(path_cli)) {
if (!path_cli) {
path_cli_dir= "innduct";
} else if (!path_cli[0] || !strcmp(path_cli,"none")) {
path_cli= 0; /* ok, don't then */
} else if (path_ends_slash(path_cli)) {
- path_lock= masprintf("%s_lock", feedfile);
- path_flushing= masprintf("%s_flushing", feedfile);
- path_defer= masprintf("%s_defer", feedfile);
- path_dump= masprintf("%s_dump", feedfile);
- globpat_backlog= masprintf("%s_backlog*", feedfile);
+ path_lock= xasprintf("%s_lock", feedfile);
+ path_flushing= xasprintf("%s_flushing", feedfile);
+ path_defer= xasprintf("%s_defer", feedfile);
+ path_dump= xasprintf("%s_dump", feedfile);
+ globpat_backlog= xasprintf("%s_backlog*", feedfile);
oop_source_sys *sysloop= oop_sys_new();
if (!sysloop) syscrash("could not create liboop event loop");
oop_source_sys *sysloop= oop_sys_new();
if (!sysloop) syscrash("could not create liboop event loop");