diff options
author | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-08-27 17:45:50 +0000 |
---|---|---|
committer | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-08-27 17:45:50 +0000 |
commit | e88c4269660e3dd537e61f6de62f807525ab390d (patch) | |
tree | 3a3b200e13fc67f45d6ab520316813e8861fdc5c | |
parent | bf7a671d87a46d5e558980efc16e1fe5d693714d (diff) |
Changed the default stack size since some OS's have a stack size which is
too small.
-rw-r--r-- | src/thread.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/thread.c b/src/thread.c index 4a4704e..c2e736b 100644 --- a/src/thread.c +++ b/src/thread.c @@ -1,4 +1,4 @@ -/* $Id: thread.c,v 1.6 2001-08-26 21:14:30 rjkaes Exp $ +/* $Id: thread.c,v 1.7 2001-08-27 17:45:50 rjkaes Exp $ * * Handles the creation/destruction of the various threads required for * processing incoming connections. @@ -42,6 +42,9 @@ struct thread_s { static struct thread_s *thread_ptr; static pthread_mutex_t mlock = PTHREAD_MUTEX_INITIALIZER; +/* Used to override the default statck size. */ +static pthread_attr_t thread_attr; + static struct thread_config_s { unsigned int maxclients, maxrequestsperchild; unsigned int maxspareservers, minspareservers, startservers; @@ -146,6 +149,13 @@ int thread_pool_create(void) { unsigned int i; + /* + * Initialize thread_attr to contain a non-default stack size + * because the default on some OS's is too small. + */ + pthread_attr_init(&thread_attr); + pthread_attr_setstacksize(&thread_attr, (1024 * 1024)); + if (thread_config.maxclients == 0) { log_message(LOG_ERR, "You must set MaxClients to a value greater than 0"); return -1; @@ -167,7 +177,7 @@ int thread_pool_create(void) for (i = 0; i < thread_config.startservers; i++) { thread_ptr[i].status = T_WAITING; servers_waiting++; - pthread_create(&thread_ptr[i].tid, NULL, &thread_main, &thread_ptr[i]); + pthread_create(&thread_ptr[i].tid, &thread_attr, &thread_main, &thread_ptr[i]); } for (i = thread_config.startservers; i < thread_config.maxclients; i++) { thread_ptr[i].status = T_EMPTY; @@ -189,7 +199,7 @@ int thread_main_loop(void) if (servers_waiting < thread_config.minspareservers) { for (i = 0; i < thread_config.maxclients; i++) { if (thread_ptr[i].status == T_EMPTY) { - pthread_create(&thread_ptr[i].tid, NULL, &thread_main, &thread_ptr[i]); + pthread_create(&thread_ptr[i].tid, &thread_attr, &thread_main, &thread_ptr[i]); thread_ptr[i].status = T_WAITING; thread_ptr[i].connects = 0; |