MINOR: config: make MAX_PROCS configurable at build time
For some embedded systems, it's pointless to have 32- or even 64- large
arrays of processes when it's known that much fewer processes will be
used in the worst case. Let's introduce this MAX_PROCS define which
contains the highest number of processes allowed to run at once. It
still defaults to LONGBITS but may be lowered.
diff --git a/include/common/defaults.h b/include/common/defaults.h
index b2c2583..cdc6665 100644
--- a/include/common/defaults.h
+++ b/include/common/defaults.h
@@ -22,6 +22,14 @@
#ifndef _COMMON_DEFAULTS_H
#define _COMMON_DEFAULTS_H
+/* MAX_PROCS defines the highest limit for the global "nbproc" value. It
+ * defaults to the number of bits in a long integer but may be lowered to save
+ * resources on embedded systems.
+ */
+#ifndef MAX_PROCS
+#define MAX_PROCS LONGBITS
+#endif
+
/*
* BUFSIZE defines the size of a read and write buffer. It is the maximum
* amount of bytes which can be stored by the proxy for each stream. However,
diff --git a/include/types/global.h b/include/types/global.h
index 178b2c1..b26553b 100644
--- a/include/types/global.h
+++ b/include/types/global.h
@@ -173,8 +173,8 @@
struct vars vars; /* list of variables for the process scope. */
#ifdef USE_CPU_AFFINITY
struct {
- unsigned long proc[LONGBITS]; /* list of CPU masks for the 32/64 first processes */
- unsigned long thread[LONGBITS][MAX_THREADS]; /* list of CPU masks for the 32/64 first threads per process */
+ unsigned long proc[MAX_PROCS]; /* list of CPU masks for the 32/64 first processes */
+ unsigned long thread[MAX_PROCS][MAX_THREADS]; /* list of CPU masks for the 32/64 first threads per process */
} cpu_map;
#endif
};
diff --git a/include/types/listener.h b/include/types/listener.h
index df0dd36..9c0ebde 100644
--- a/include/types/listener.h
+++ b/include/types/listener.h
@@ -166,7 +166,7 @@
int is_ssl; /* SSL is required for these listeners */
int generate_certs; /* 1 if generate-certificates option is set, else 0 */
unsigned long bind_proc; /* bitmask of processes allowed to use these listeners */
- unsigned long bind_thread[LONGBITS]; /* bitmask of threads (per processes) allowed to use these listeners */
+ unsigned long bind_thread[MAX_PROCS]; /* bitmask of threads (per processes) allowed to use these listeners */
struct { /* UNIX socket permissions */
uid_t uid; /* -1 to leave unchanged */
gid_t gid; /* -1 to leave unchanged */