From bf42903592a8c3495a7981adc1477dac78aeaf12 Mon Sep 17 00:00:00 2001 From: Tom MTT Date: Tue, 29 Nov 2022 10:38:00 +0100 Subject: [PATCH] feat(feuille.c): do not create thread pool if in DEBUG mode Will be useful when a batch of static/dynamic analysis tools will check feuille's code. --- feuille.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/feuille.c b/feuille.c index 1698be7..9673c85 100644 --- a/feuille.c +++ b/feuille.c @@ -293,20 +293,20 @@ int main(int argc, char *argv[]) } - /* OpenBSD-only security measures */ -#ifdef __OpenBSD__ +#ifdef __OpenBSD__ /* OpenBSD-only security measures */ pledge("proc stdio rpath wpath cpath inet", "stdio rpath wpath cpath inet"); #endif + int pid; +#ifndef DEBUG /* do not fork if in DEBUG mode */ /* create a thread pool for incoming connections */ verbose(1, "initializing worker pool..."); - int pid; for (int i = 1; i <= settings.worker_count; i++) { if ((pid = fork()) == 0) { verbose(2, " worker n. %d...", i); - +#endif pid = getpid(); /* feed the random number god */ @@ -380,10 +380,11 @@ int main(int argc, char *argv[]) /* close connection */ close_connection(connection); } - +#ifndef DEBUG } else if (pid < 0) die(errno, "Could not initialize worker n. %d: %s\n", i, strerror(errno)); } +#endif sleep(1);