mirror of https://github.com/omar-polo/gmid.git
move log_init & vars to gmid.c, retain logger_main in log.c
this is to let the regression suite compile
This commit is contained in:
parent
aa627c91fc
commit
376a540764
31
gmid.c
31
gmid.c
|
@ -29,7 +29,9 @@ volatile sig_atomic_t hupped;
|
|||
|
||||
struct vhost hosts[HOSTSLEN];
|
||||
|
||||
int exfd, sock4, sock6;
|
||||
int exfd, logfd, sock4, sock6;
|
||||
|
||||
struct imsgbuf logpibuf, logcibuf;
|
||||
|
||||
const char *config_path, *certs_dir, *hostname;
|
||||
|
||||
|
@ -331,6 +333,33 @@ usage(const char *me)
|
|||
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)
|
||||
{
|
||||
|
|
6
gmid.h
6
gmid.h
|
@ -114,7 +114,9 @@ struct conf {
|
|||
|
||||
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;
|
||||
|
||||
|
@ -219,7 +221,7 @@ void log_notice(struct client*, const char*, ...) LOG_ATTR_FMT;
|
|||
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*);
|
||||
|
|
35
log.c
35
log.c
|
@ -28,12 +28,9 @@
|
|||
#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, ...)
|
||||
|
@ -74,9 +71,9 @@ should_log(int priority)
|
|||
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
|
||||
|
@ -267,7 +264,7 @@ handle_log(int fd, short ev, void *d)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
logger_main(int fd, struct imsgbuf *ibuf)
|
||||
{
|
||||
event_init();
|
||||
|
@ -284,29 +281,3 @@ logger_main(int fd, struct imsgbuf *ibuf)
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue