~mdw
/
fwd
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
configure.ac: Hack around Termux syslog weirdness.
[fwd]
/
fwd.c
diff --git
a/fwd.c
b/fwd.c
index
5b4e248
..
9d170e1
100644
(file)
--- a/
fwd.c
+++ b/
fwd.c
@@
-29,6
+29,7
@@
/*----- Global variables --------------------------------------------------*/
sel_state *sel; /* Multiplexor for nonblocking I/O */
/*----- Global variables --------------------------------------------------*/
sel_state *sel; /* Multiplexor for nonblocking I/O */
+unsigned flags = 0; /* Global state flags */
/*----- Static variables --------------------------------------------------*/
/*----- Static variables --------------------------------------------------*/
@@
-37,14
+38,9
@@
typedef struct conffile {
char *name;
} conffile;
char *name;
} conffile;
-static unsigned flags = 0; /* Global state flags */
static unsigned active = 0; /* Number of active things */
static conffile *conffiles = 0; /* List of configuration files */
static unsigned active = 0; /* Number of active things */
static conffile *conffiles = 0; /* List of configuration files */
-#define FW_SYSLOG 1u
-#define FW_QUIET 2u
-#define FW_SET 4u
-
/*----- Configuration parsing ---------------------------------------------*/
/* --- @parse@ --- *
/*----- Configuration parsing ---------------------------------------------*/
/* --- @parse@ --- *
@@
-156,6
+152,7
@@
void parse(scanner *sc)
s->ops->attach(s, sc, t);
if (t->ops->confirm)
t->ops->confirm(t);
s->ops->attach(s, sc, t);
if (t->ops->confirm)
t->ops->confirm(t);
+ source_dec(s); target_dec(t);
}
/* --- Include configuration from a file --- *
}
/* --- Include configuration from a file --- *
@@
-241,11
+238,11
@@
void fw_log(time_t t, const char *fmt, ...)
if (flags & FW_QUIET)
return;
if (flags & FW_QUIET)
return;
- if (t ==
-1
)
+ if (t ==
NOW
)
t = time(0);
tm = localtime(&t);
DENSURE(&d, 64);
t = time(0);
tm = localtime(&t);
DENSURE(&d, 64);
- d.len += strftime(d.buf, d.sz, "%Y-%m-%d %H:%M:%S ", tm);
+ d.len += strftime(d.buf, d.sz, "%Y-%m-%d %H:%M:%S
%z
", tm);
va_start(ap, fmt);
dstr_vputf(&d, fmt, &ap);
va_end(ap);
va_start(ap, fmt);
dstr_vputf(&d, fmt, &ap);
va_end(ap);
@@
-305,7
+302,7
@@
static void fw_tidy(int n, void *p)
default: abort();
}
default: abort();
}
- fw_log(
-1
, "closing down gracefully on %s", sn);
+ fw_log(
NOW
, "closing down gracefully on %s", sn);
source_killall();
}
source_killall();
}
@@
-327,7
+324,7
@@
static void fw_die(int n, void *p)
default: abort();
}
default: abort();
}
- fw_log(
-1
, "closing down abruptly on %s", sn);
+ fw_log(
NOW
, "closing down abruptly on %s", sn);
source_killall();
endpt_killall();
}
source_killall();
endpt_killall();
}
@@
-350,20
+347,20
@@
static void fw_reload(int n, void *p)
assert(n == SIGHUP);
if (!conffiles) {
assert(n == SIGHUP);
if (!conffiles) {
- fw_log(
-1
, "no configuration files to reload: ignoring SIGHUP");
+ fw_log(
NOW
, "no configuration files to reload: ignoring SIGHUP");
return;
}
return;
}
- fw_log(
-1
, "reloading configuration files...");
+ fw_log(
NOW
, "reloading configuration files...");
source_killall();
scan_create(&sc);
for (cf = conffiles; cf; cf = cf->next) {
if ((fp = fopen(cf->name, "r")) == 0)
source_killall();
scan_create(&sc);
for (cf = conffiles; cf; cf = cf->next) {
if ((fp = fopen(cf->name, "r")) == 0)
- fw_log(
-1
, "error loading `%s': %s", cf->name, strerror(errno));
+ fw_log(
NOW
, "error loading `%s': %s", cf->name, strerror(errno));
else
scan_add(&sc, scan_file(fp, cf->name, 0));
}
parse(&sc);
else
scan_add(&sc, scan_file(fp, cf->name, 0));
}
parse(&sc);
- fw_log(
-1
, "... reload completed OK");
+ fw_log(
NOW
, "... reload completed OK");
}
/*----- Startup and options parsing ---------------------------------------*/
}
/*----- Startup and options parsing ---------------------------------------*/
@@
-487,7
+484,7
@@
int main(int argc, char *argv[])
/* --- Standard GNU help options --- */
/* --- Standard GNU help options --- */
- { "help", 0, 0, 'h' },
+ { "help",
0, 0, 'h' },
{ "version", 0, 0, 'v' },
{ "usage", 0, 0, 'u' },
{ "version", 0, 0, 'v' },
{ "usage", 0, 0, 'u' },
@@
-702,10
+699,10
@@
int main(int argc, char *argv[])
if (!sel_select(sel))
selerr = 0;
else if (errno != EINTR && errno != EAGAIN) {
if (!sel_select(sel))
selerr = 0;
else if (errno != EINTR && errno != EAGAIN) {
- fw_log(
-1
, "error from select: %s", strerror(errno));
+ fw_log(
NOW
, "error from select: %s", strerror(errno));
selerr++;
if (selerr > 8) {
selerr++;
if (selerr > 8) {
- fw_log(
-1
, "too many consecutive select errors: bailing out");
+ fw_log(
NOW
, "too many consecutive select errors: bailing out");
exit(EXIT_FAILURE);
}
}
exit(EXIT_FAILURE);
}
}