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.
This commit is contained in:
Tom MTT. 2022-11-29 10:38:00 +01:00
parent 43be904636
commit bf42903592

View file

@ -293,20 +293,20 @@ int main(int argc, char *argv[])
} }
/* OpenBSD-only security measures */ #ifdef __OpenBSD__ /* OpenBSD-only security measures */
#ifdef __OpenBSD__
pledge("proc stdio rpath wpath cpath inet", "stdio rpath wpath cpath inet"); pledge("proc stdio rpath wpath cpath inet", "stdio rpath wpath cpath inet");
#endif #endif
int pid;
#ifndef DEBUG /* do not fork if in DEBUG mode */
/* create a thread pool for incoming connections */ /* create a thread pool for incoming connections */
verbose(1, "initializing worker pool..."); verbose(1, "initializing worker pool...");
int pid;
for (int i = 1; i <= settings.worker_count; i++) { for (int i = 1; i <= settings.worker_count; i++) {
if ((pid = fork()) == 0) { if ((pid = fork()) == 0) {
verbose(2, " worker n. %d...", i); verbose(2, " worker n. %d...", i);
#endif
pid = getpid(); pid = getpid();
/* feed the random number god */ /* feed the random number god */
@ -380,10 +380,11 @@ int main(int argc, char *argv[])
/* close connection */ /* close connection */
close_connection(connection); close_connection(connection);
} }
#ifndef DEBUG
} else if (pid < 0) } else if (pid < 0)
die(errno, "Could not initialize worker n. %d: %s\n", i, strerror(errno)); die(errno, "Could not initialize worker n. %d: %s\n", i, strerror(errno));
} }
#endif
sleep(1); sleep(1);