-/* $OpenBSD: httpd.c,v 1.57 2016/08/16 18:41:57 tedu Exp $ */
+/* $OpenBSD: httpd.c,v 1.58 2016/08/26 12:24:21 rzalamena Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
log_info("startup");
ps->ps_instances[PROC_SERVER] = env->sc_prefork_server;
- ps->ps_ninstances = env->sc_prefork_server;
if (env->sc_chroot == NULL)
env->sc_chroot = ps->ps_pw->pw_dir;
-/* $OpenBSD: httpd.h,v 1.109 2016/08/26 10:46:39 rzalamena Exp $ */
+/* $OpenBSD: httpd.h,v 1.110 2016/08/26 12:24:21 rzalamena Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
uint8_t ps_what[PROC_MAX];
unsigned int ps_instances[PROC_MAX];
- unsigned int ps_ninstances;
unsigned int ps_instance;
struct control_sock ps_csock;
-/* $OpenBSD: proc.c,v 1.15 2015/12/07 16:05:56 reyk Exp $ */
+/* $OpenBSD: proc.c,v 1.16 2016/08/26 12:24:21 rzalamena Exp $ */
/*
* Copyright (c) 2010 - 2014 Reyk Floeter <reyk@openbsd.org>
unsigned int i, j, src, dst;
struct privsep_pipes *pp;
+ for (src = 0; src < PROC_MAX; src++) {
+ /* Default to 1 process instance */
+ if (ps->ps_instances[src] < 1)
+ ps->ps_instances[src] = 1;
+ }
+
/*
* Allocate pipes for all process instances (incl. parent)
*
*/
for (src = 0; src < PROC_MAX; src++) {
/* Allocate destination array for each process */
- if ((ps->ps_pipes[src] = calloc(ps->ps_ninstances,
+ if ((ps->ps_pipes[src] = calloc(ps->ps_instances[src],
sizeof(struct privsep_pipes))) == NULL)
fatal("proc_init: calloc");
- for (i = 0; i < ps->ps_ninstances; i++) {
+ for (i = 0; i < ps->ps_instances[src]; i++) {
pp = &ps->ps_pipes[src][i];
for (dst = 0; dst < PROC_MAX; dst++) {
/* Allocate maximum fd integers */
if ((pp->pp_pipes[dst] =
- calloc(ps->ps_ninstances,
+ calloc(ps->ps_instances[dst],
sizeof(int))) == NULL)
fatal("proc_init: calloc");
/* Mark fd as unused */
- for (j = 0; j < ps->ps_ninstances; j++)
+ for (j = 0; j < ps->ps_instances[dst]; j++)
pp->pp_pipes[dst][j] = -1;
}
}
ps->ps_pid[PROC_PARENT] = getpid();
ps->ps_pp = &ps->ps_pipes[privsep_process][0];
- for (i = 0; i < nproc; i++) {
- /* Default to 1 process instance */
- if (ps->ps_instances[procs[i].p_id] < 1)
- ps->ps_instances[procs[i].p_id] = 1;
+ for (i = 0; i < nproc; i++)
ps->ps_title[procs[i].p_id] = procs[i].p_title;
- }
proc_open(ps, NULL, procs, nproc);