commit - aa627c91fcd7b6d56b9a9864fa89f8fa615ff0d2
commit + 376a540764c3778330b4f744031bcdb5c6e73647
blob - 0d0247e5a8d267f9cc2fd7407490b29fe25b3fe5
blob + d14891ab6dfa1a4a68e79ee7c51da7fe78924c50
--- gmid.c
+++ gmid.c
struct vhost hosts[HOSTSLEN];
-int exfd, sock4, sock6;
+int exfd, logfd, sock4, sock6;
+struct imsgbuf logpibuf, logcibuf;
+
const char *config_path, *certs_dir, *hostname;
struct conf conf;
me);
}
+static void
+logger_init(void)
+{
+ int p[2];
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, p) == -1)
+ err(1, "socketpair");
+
+ switch (fork()) {
+ case -1:
+ err(1, "fork");
+ case 0:
+ logfd = p[1];
+ close(p[0]);
+ setproctitle("logger");
+ imsg_init(&logcibuf, p[1]);
+ drop_priv();
+ _exit(logger_main(p[1], &logcibuf));
+ default:
+ logfd = p[0];
+ close(p[1]);
+ imsg_init(&logpibuf, p[0]);
+ return;
+ }
+}
+
+
static int
serve(int argc, char **argv, int *p)
{
blob - 454ddd3c2f24e0fb14a12b84c93856b0e69f748a
blob + e926f9c5b69fa2e933874dbb5c5a69e6f6ea0a5d
--- gmid.h
+++ gmid.h
extern const char *config_path;
extern struct conf conf;
-extern int exfd;
+extern int exfd, logfd;
+
+extern struct imsgbuf logpibuf, logcibuf;
extern volatile sig_atomic_t hupped;
void log_info(struct client*, const char*, ...) LOG_ATTR_FMT;
void log_debug(struct client*, const char*, ...) LOG_ATTR_FMT;
void log_request(struct client*, char*, size_t);
-void logger_init(void);
+int logger_main(int, struct imsgbuf*);
/* mime.c */
void init_mime(struct mime*);
blob - 6bb84f131f85407de99c5dd8ce931ce60aa6ef37
blob + 19b72b9790045ccc1c901644026500c808a5124e
--- log.c
+++ log.c
#include <string.h>
#include <syslog.h>
-static struct imsgbuf parent_ibuf, child_ibuf;
static struct event inlog;
-static int logfd;
static void handle_log(int, short, void*);
-static int logger_main(int, struct imsgbuf*);
void
fatal(const char *fmt, ...)
static inline void
send_log(const char *msg, size_t len)
{
- imsg_compose(&parent_ibuf, 0, 0, 0, -1, msg, len);
+ imsg_compose(&logpibuf, 0, 0, 0, -1, msg, len);
/* XXX: use event_once() */
- imsg_flush(&parent_ibuf);
+ imsg_flush(&logpibuf);
}
static inline void
}
}
-static int
+int
logger_main(int fd, struct imsgbuf *ibuf)
{
event_init();
return 0;
}
-
-void
-logger_init(void)
-{
- int p[2];
-
- if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, p) == -1)
- err(1, "socketpair");
-
- switch (fork()) {
- case -1:
- err(1, "fork");
- case 0:
- logfd = p[1];
- close(p[0]);
- setproctitle("logger");
- imsg_init(&child_ibuf, p[1]);
- drop_priv();
- _exit(logger_main(p[1], &child_ibuf));
- default:
- logfd = p[0];
- close(p[1]);
- imsg_init(&parent_ibuf, p[0]);
- return;
- }
-}