From 2de2cfcb79b645723e5c64de7975a8836c4f58be Mon Sep 17 00:00:00 2001 From: Virtually Nick Date: Sun, 2 Jan 2022 23:41:18 -0500 Subject: [PATCH] GUACAMOLE-663: Set pthread stack size for guacd --- src/guacd/daemon.c | 9 +++++++++ src/guacd/proc-map.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/guacd/daemon.c b/src/guacd/daemon.c index 2861cffeee..fa42aa7191 100644 --- a/src/guacd/daemon.c +++ b/src/guacd/daemon.c @@ -17,6 +17,8 @@ * under the License. */ +#define _GNU_SOURCE 1 + #include "config.h" #include "conf.h" @@ -35,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -275,6 +278,12 @@ int main(int argc, char* argv[]) { /* General */ int retval; + /* Set default stack size of 8MB */ + pthread_attr_t default_pthread_attr; + pthread_attr_init(&default_pthread_attr); + pthread_attr_setstacksize(&default_pthread_attr, GUACD_THREAD_STACK_SIZE); + pthread_setattr_default_np(&default_pthread_attr); + /* Load configuration */ guacd_config* config = guacd_conf_load(); if (config == NULL || guacd_conf_parse_args(config, argc, argv)) diff --git a/src/guacd/proc-map.h b/src/guacd/proc-map.h index a24218855b..6bb49c33e3 100644 --- a/src/guacd/proc-map.h +++ b/src/guacd/proc-map.h @@ -33,6 +33,11 @@ */ #define GUACD_CLIENT_MAX_CONNECTIONS 65536 +/** + * The pthread stack size for the guacd daemon. + */ +#define GUACD_THREAD_STACK_SIZE 8388608 + /** * The number of hash buckets in each process map. */