-/* $OpenBSD: logger.c,v 1.16 2016/08/16 18:41:57 tedu Exp $ */
+/* $OpenBSD: logger.c,v 1.17 2016/08/26 10:46:39 rzalamena Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
int logger_start(void);
int logger_log(struct imsg *);
-static struct httpd *env = NULL;
int proc_id;
static uint32_t last_log_id = 0;
pid_t
logger(struct privsep *ps, struct privsep_proc *p)
{
- env = ps->ps_env;
return (proc_run(ps, p, procs, nitems(procs), logger_init, NULL));
}
logger_shutdown(void)
{
logger_close();
- config_purge(env, CONFIG_ALL);
+ config_purge(httpd_env, CONFIG_ALL);
}
void
iov[1].iov_base = log->log_name;
iov[1].iov_len = strlen(log->log_name) + 1;
- if (proc_composev(env->sc_ps, PROC_PARENT, IMSG_LOG_OPEN,
+ if (proc_composev(httpd_env->sc_ps, PROC_PARENT, IMSG_LOG_OPEN,
iov, 2) != 0) {
log_warn("%s: failed to compose IMSG_LOG_OPEN imsg", __func__);
goto err;
if ((size_t)snprintf(name, sizeof(name), "/%s", p) >= sizeof(name))
return (-1);
- if ((len = strlcpy(path, env->sc_logdir, sizeof(path)))
+ if ((len = strlcpy(path, httpd_env->sc_logdir, sizeof(path)))
>= sizeof(path))
return (-1);
return (-1);
}
- proc_compose_imsg(env->sc_ps, PROC_LOGGER, -1, IMSG_LOG_OPEN, -1, fd,
+ proc_compose_imsg(httpd_env->sc_ps, PROC_LOGGER, -1, IMSG_LOG_OPEN, -1, fd,
&id, sizeof(id));
DPRINTF("%s: opened log file %s, fd %d", __func__, path, fd);
{
switch (imsg->hdr.type) {
case IMSG_CFG_SERVER:
- config_getserver(env, imsg);
+ config_getserver(httpd_env, imsg);
break;
case IMSG_CFG_DONE:
- config_getcfg(env, imsg);
+ config_getcfg(httpd_env, imsg);
break;
case IMSG_CTL_START:
case IMSG_CTL_REOPEN:
logger_start();
break;
case IMSG_CTL_RESET:
- config_getreset(env, imsg);
+ config_getreset(httpd_env, imsg);
break;
case IMSG_LOG_OPEN:
return (logger_open_fd(imsg));
-/* $OpenBSD: server.c,v 1.92 2016/08/22 15:02:18 jsing Exp $ */
+/* $OpenBSD: server.c,v 1.93 2016/08/26 10:46:39 rzalamena Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
volatile int server_inflight = 0;
uint32_t server_cltid;
-static struct httpd *env = NULL;
int proc_id;
static struct privsep_proc procs[] = {
server(struct privsep *ps, struct privsep_proc *p)
{
pid_t pid;
- env = ps->ps_env;
pid = proc_run(ps, p, procs, nitems(procs), server_init, NULL);
- server_http(env);
+ server_http();
return (pid);
}
void
server_shutdown(void)
{
- config_purge(env, CONFIG_ALL);
+ config_purge(httpd_env, CONFIG_ALL);
usleep(200); /* XXX server needs to shutdown last */
}
* There's no need to open a new socket if a server with the
* same address already exists.
*/
- TAILQ_FOREACH(s, env->sc_servers, srv_entry) {
+ TAILQ_FOREACH(s, httpd_env->sc_servers, srv_entry) {
if (s != srv && s->srv_s != -1 &&
s->srv_conf.port == srv->srv_conf.port &&
sockaddr_cmp((struct sockaddr *)&s->srv_conf.ss,
void
server_init(struct privsep *ps, struct privsep_proc *p, void *arg)
{
- server_http(ps->ps_env);
+ server_http();
if (config_init(ps->ps_env) == -1)
fatal("failed to initialize configuration");
#if 0
/* Schedule statistics timer */
- evtimer_set(&env->sc_statev, server_statistics, NULL);
- memcpy(&tv, &env->sc_statinterval, sizeof(tv));
- evtimer_add(&env->sc_statev, &tv);
+ evtimer_set(&ps->ps_env->sc_statev, server_statistics, NULL);
+ memcpy(&tv, &ps->ps_env->sc_statinterval, sizeof(tv));
+ evtimer_add(&ps->ps_env->sc_statev, &tv);
#endif
}
{
struct server *srv;
- TAILQ_FOREACH(srv, env->sc_servers, srv_entry) {
+ TAILQ_FOREACH(srv, httpd_env->sc_servers, srv_entry) {
log_debug("%s: configuring server %s", __func__,
srv->srv_conf.name);
if (srv->srv_s != -1)
close(srv->srv_s);
- TAILQ_REMOVE(env->sc_servers, srv, srv_entry);
+ TAILQ_REMOVE(httpd_env->sc_servers, srv, srv_entry);
/* cleanup sessions */
while ((clt =
{
struct server *srv;
- TAILQ_FOREACH(srv, env->sc_servers, srv_entry) {
+ TAILQ_FOREACH(srv, httpd_env->sc_servers, srv_entry) {
if (port == srv->srv_conf.port &&
sockaddr_cmp((struct sockaddr *)&srv->srv_conf.ss,
addr, srv->srv_conf.prefixlen) == 0)
struct server *srv;
struct server_config *srv_conf;
- TAILQ_FOREACH(srv, env->sc_servers, srv_entry) {
+ TAILQ_FOREACH(srv, httpd_env->sc_servers, srv_entry) {
if (srv->srv_conf.id == id)
return (&srv->srv_conf);
TAILQ_FOREACH(srv_conf, &srv->srv_hosts, entry) {
struct server *srv;
struct server_config *srv_conf;
- TAILQ_FOREACH(srv, env->sc_servers, srv_entry) {
+ TAILQ_FOREACH(srv, httpd_env->sc_servers, srv_entry) {
if ((srv_cb)(srv, &srv->srv_conf, arg) == -1)
return (-1);
TAILQ_FOREACH(srv_conf, &srv->srv_hosts, entry) {
struct server *s1;
/* Attempt to find matching server. */
- TAILQ_FOREACH(s1, env->sc_servers, srv_entry) {
+ TAILQ_FOREACH(s1, httpd_env->sc_servers, srv_entry) {
if ((s1->srv_conf.flags & SRVFLAG_LOCATION) != 0)
continue;
if (match_name) {
iov[1].iov_base = msg;
iov[1].iov_len = strlen(msg) + 1;
- if (proc_composev(env->sc_ps, PROC_LOGGER, cmd, iov, 2) != 0) {
+ if (proc_composev(httpd_env->sc_ps, PROC_LOGGER, cmd, iov, 2) != 0) {
log_warn("%s: failed to compose imsg", __func__);
return;
}
{
switch (imsg->hdr.type) {
case IMSG_CFG_MEDIA:
- config_getmedia(env, imsg);
+ config_getmedia(httpd_env, imsg);
break;
case IMSG_CFG_AUTH:
- config_getauth(env, imsg);
+ config_getauth(httpd_env, imsg);
break;
case IMSG_CFG_SERVER:
- config_getserver(env, imsg);
+ config_getserver(httpd_env, imsg);
break;
case IMSG_CFG_TLS:
- config_gettls(env, imsg);
+ config_gettls(httpd_env, imsg);
break;
case IMSG_CFG_DONE:
- config_getcfg(env, imsg);
+ config_getcfg(httpd_env, imsg);
break;
case IMSG_CTL_START:
server_launch();
break;
case IMSG_CTL_RESET:
- config_getreset(env, imsg);
+ config_getreset(httpd_env, imsg);
break;
default:
return (-1);