Skip to content

Commit

Permalink
GUACAMOLE-663: Set pthread stack size for guacd
Browse files Browse the repository at this point in the history
  • Loading branch information
necouchman committed Mar 14, 2023
1 parent 47b9360 commit 1ab81c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/guacd/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
* under the License.
*/

/**
* This is required for pthread_setattr_default_np() to be
* available and function correctly.
*/
#define _GNU_SOURCE 1

#include "config.h"

#include "conf.h"
Expand All @@ -35,6 +41,7 @@
#include <libgen.h>
#include <netdb.h>
#include <netinet/in.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -275,6 +282,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))
Expand Down
5 changes: 5 additions & 0 deletions src/guacd/proc-map.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 1ab81c7

Please sign in to comment.