summaryrefslogtreecommitdiffstats
path: root/usr.sbin/httpd/proc.c
diff options
context:
space:
mode:
authorrzalamena <rzalamena@openbsd.org>2016-08-27 11:13:16 +0000
committerrzalamena <rzalamena@openbsd.org>2016-08-27 11:13:16 +0000
commitb607ef5af6e8cb4789f3820224e0c20a3727d708 (patch)
tree78204b2e00f5fb06ae9fce140d062671b14b28f6 /usr.sbin/httpd/proc.c
parentAdd missing $OpenBSD$ line and remove an unnecessary comment line. (diff)
downloadwireguard-openbsd-b607ef5af6e8cb4789f3820224e0c20a3727d708.tar.xz
wireguard-openbsd-b607ef5af6e8cb4789f3820224e0c20a3727d708.zip
Kill p_instance from proc.c and remove static proc_id unused variables.
To keep the debug functionality intact and correct we'll use the pid field in the imsg header to pass the instance number. Remember to always pass 'ps_instance + 1' otherwise libutil will fill imsg header pid field with the imsgbuf pid (which is the current process pid). ok reyk@
Diffstat (limited to 'usr.sbin/httpd/proc.c')
-rw-r--r--usr.sbin/httpd/proc.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/usr.sbin/httpd/proc.c b/usr.sbin/httpd/proc.c
index 94f23e2f094..6f6b8db3560 100644
--- a/usr.sbin/httpd/proc.c
+++ b/usr.sbin/httpd/proc.c
@@ -1,4 +1,4 @@
-/* $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>
@@ -247,7 +247,6 @@ proc_listen(struct privsep *ps, struct privsep_proc *procs, size_t nproc)
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,
@@ -391,7 +390,7 @@ proc_run(struct privsep *ps, struct privsep_proc *p,
/* 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;
}
}
@@ -478,7 +477,7 @@ proc_dispatch(int fd, short event, void *arg)
#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
/*
@@ -504,7 +503,7 @@ proc_dispatch(int fd, short event, void *arg)
"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);
@@ -587,7 +586,7 @@ proc_compose_imsg(struct privsep *ps, enum privsep_procid id, int n,
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);
}
@@ -610,7 +609,7 @@ proc_composev_imsg(struct privsep *ps, enum privsep_procid id, int n,
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);