-/* $OpenBSD: control.c,v 1.9 2015/12/05 13:15:27 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.10 2016/08/27 11:13:16 rzalamena Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
"client requested notify more than once",
__func__);
imsg_compose_event(&c->iev, IMSG_CTL_FAIL,
- 0, 0, -1, NULL, 0);
+ 0, env->sc_ps->ps_instance + 1, -1, NULL, 0);
break;
}
c->flags |= CTL_CONN_NOTIFY;
proc_forward_imsg(env->sc_ps, &imsg, PROC_SERVER, -1);
memcpy(imsg.data, &verbose, sizeof(verbose));
- control_imsg_forward(&imsg);
+ control_imsg_forward(env->sc_ps, &imsg);
log_verbose(verbose);
break;
default:
}
void
-control_imsg_forward(struct imsg *imsg)
+control_imsg_forward(struct privsep *ps, struct imsg *imsg)
{
struct ctl_conn *c;
TAILQ_FOREACH(c, &ctl_conns, entry)
if (c->flags & CTL_CONN_NOTIFY)
imsg_compose_event(&c->iev, imsg->hdr.type,
- 0, imsg->hdr.pid, -1, imsg->data,
+ 0, ps->ps_instance + 1, -1, imsg->data,
imsg->hdr.len - IMSG_HEADER_SIZE);
}
-/* $OpenBSD: httpd.h,v 1.110 2016/08/26 12:24:21 rzalamena Exp $ */
+/* $OpenBSD: httpd.h,v 1.111 2016/08/27 11:13:16 rzalamena Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
pid_t (*p_init)(struct privsep *,
struct privsep_proc *);
void (*p_shutdown)(void);
- unsigned int p_instance;
const char *p_chroot;
struct privsep *p_ps;
struct httpd *p_env;
int control_listen(struct control_sock *);
void control_cleanup(struct control_sock *);
void control_dispatch_imsg(int, short, void *);
-void control_imsg_forward(struct imsg *);
+void control_imsg_forward(struct privsep *, struct imsg *);
struct ctl_conn *
control_connbyfd(int);
-/* $OpenBSD: logger.c,v 1.17 2016/08/26 10:46:39 rzalamena Exp $ */
+/* $OpenBSD: logger.c,v 1.18 2016/08/27 11:13:16 rzalamena Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
int logger_start(void);
int logger_log(struct imsg *);
-int proc_id;
static uint32_t last_log_id = 0;
static struct privsep_proc procs[] = {
if (config_init(ps->ps_env) == -1)
fatal("failed to initialize configuration");
- /* Set to current prefork id */
- proc_id = p->p_instance;
-
/* We use a custom shutdown callback */
p->p_shutdown = logger_shutdown;
-/* $OpenBSD: proc.c,v 1.16 2016/08/26 12:24:21 rzalamena Exp $ */
+/* $OpenBSD: proc.c,v 1.17 2016/08/27 11:13:16 rzalamena Exp $ */
/*
* Copyright (c) 2010 - 2014 Reyk Floeter <reyk@openbsd.org>
ps->ps_ievs[dst][n].events = EV_READ;
ps->ps_ievs[dst][n].proc = &procs[i];
ps->ps_ievs[dst][n].data = &ps->ps_ievs[dst][n];
- procs[i].p_instance = n;
event_set(&(ps->ps_ievs[dst][n].ev),
ps->ps_ievs[dst][n].ibuf.fd,
/* Fork child handlers */
for (n = 1; n < ps->ps_instances[p->p_id]; n++) {
if (fork() == 0) {
- ps->ps_instance = p->p_instance = n;
+ ps->ps_instance = n;
break;
}
}
#if DEBUG > 1
log_debug("%s: %s %d got imsg %d peerid %d from %s %d",
__func__, title, ps->ps_instance + 1,
- imsg.hdr.type, imsg.hdr.peerid, p->p_title, p->p_instance);
+ imsg.hdr.type, imsg.hdr.peerid, p->p_title, imsg.hdr.pid);
#endif
/*
"from %s %d",
__func__, title, ps->ps_instance + 1,
imsg.hdr.type, imsg.hdr.peerid,
- p->p_title, p->p_instance);
+ p->p_title, imsg.hdr.pid);
fatalx(__func__);
}
imsg_free(&imsg);
proc_range(ps, id, &n, &m);
for (; n < m; n++) {
if (imsg_compose_event(&ps->ps_ievs[id][n],
- type, peerid, 0, fd, data, datalen) == -1)
+ type, peerid, ps->ps_instance + 1, fd, data, datalen) == -1)
return (-1);
}
proc_range(ps, id, &n, &m);
for (; n < m; n++)
if (imsg_composev_event(&ps->ps_ievs[id][n],
- type, peerid, 0, fd, iov, iovcnt) == -1)
+ type, peerid, ps->ps_instance + 1, fd, iov, iovcnt) == -1)
return (-1);
return (0);
-/* $OpenBSD: server.c,v 1.93 2016/08/26 10:46:39 rzalamena Exp $ */
+/* $OpenBSD: server.c,v 1.94 2016/08/27 11:13:16 rzalamena Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
volatile int server_inflight = 0;
uint32_t server_cltid;
-int proc_id;
-
static struct privsep_proc procs[] = {
{ "parent", PROC_PARENT, server_dispatch_parent },
{ "logger", PROC_LOGGER, server_dispatch_logger }
if (config_init(ps->ps_env) == -1)
fatal("failed to initialize configuration");
- /* Set to current prefork id */
- proc_id = p->p_instance;
-
/* We use a custom shutdown callback */
p->p_shutdown = server_shutdown;
server_clients++;
SPLAY_INSERT(client_tree, &srv->srv_clients, clt);
- /* Increment the per-relay client counter */
- //srv->srv_stats[proc_id].last++;
-
/* Pre-allocate output buffer */
clt->clt_output = evbuffer_new();
if (clt->clt_output == NULL) {