summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c/fastcgi.c4
-rw-r--r--src/c/http.c4
-rw-r--r--src/c/request.c32
3 files changed, 34 insertions, 6 deletions
diff --git a/src/c/fastcgi.c b/src/c/fastcgi.c
index 161cb834..dcfdec78 100644
--- a/src/c/fastcgi.c
+++ b/src/c/fastcgi.c
@@ -569,7 +569,7 @@ int main(int argc, char *argv[]) {
{
pthread_t thread;
- if (pthread_create(&thread, NULL, client_pruner, &ls)) {
+ if (pthread_create_big(&thread, NULL, client_pruner, &ls)) {
fprintf(stderr, "Error creating pruner thread\n");
return 1;
}
@@ -578,7 +578,7 @@ int main(int argc, char *argv[]) {
for (i = 0; i < nthreads; ++i) {
pthread_t thread;
names[i] = i;
- if (pthread_create(&thread, NULL, worker, &names[i])) {
+ if (pthread_create_big(&thread, NULL, worker, &names[i])) {
fprintf(stderr, "Error creating worker thread #%d\n", i);
return 1;
}
diff --git a/src/c/http.c b/src/c/http.c
index 4b2f0576..df9d3080 100644
--- a/src/c/http.c
+++ b/src/c/http.c
@@ -311,7 +311,7 @@ int main(int argc, char *argv[]) {
{
pthread_t thread;
- if (pthread_create(&thread, NULL, client_pruner, &ls)) {
+ if (pthread_create_big(&thread, NULL, client_pruner, &ls)) {
fprintf(stderr, "Error creating pruner thread\n");
return 1;
}
@@ -320,7 +320,7 @@ int main(int argc, char *argv[]) {
for (i = 0; i < nthreads; ++i) {
pthread_t thread;
names[i] = i;
- if (pthread_create(&thread, NULL, worker, &names[i])) {
+ if (pthread_create_big(&thread, NULL, worker, &names[i])) {
fprintf(stderr, "Error creating worker thread #%d\n", i);
return 1;
}
diff --git a/src/c/request.c b/src/c/request.c
index 3fd12ff6..9f8cab36 100644
--- a/src/c/request.c
+++ b/src/c/request.c
@@ -123,12 +123,40 @@ static void *periodic_loop(void *data) {
};
}
+static unsigned long long stackSize;
+
+int pthread_create_big(pthread_t *outThread, void *foo, void *threadFunc, void *arg)
+{
+ int err;
+ pthread_attr_t stackSizeAttribute;
+
+ err = pthread_attr_init(&stackSizeAttribute);
+ if (err) return err;
+
+ if (stackSize > 0) {
+ err = pthread_attr_setstacksize(&stackSizeAttribute, stackSize);
+ if (err) return err;
+ }
+
+ return pthread_create(outThread, &stackSizeAttribute, threadFunc, arg);
+}
+
void uw_request_init(uw_app *app, void *logger_data, uw_logger log_error, uw_logger log_debug) {
uw_context ctx;
failure_kind fk;
uw_periodic *ps;
loggers *ls = malloc(sizeof(loggers));
int id;
+ char *stackSize_s;
+
+ if ((stackSize_s = getenv("URWEB_STACK_SIZE")) != NULL && stackSize_s[0] != 0) {
+ stackSize = atoll(stackSize_s);
+
+ if (stackSize <= 0) {
+ fprintf(stderr, "Invalid stack size \"%s\"\n", stackSize_s);
+ exit(1);
+ }
+ }
ls->app = app;
ls->logger_data = logger_data;
@@ -141,7 +169,7 @@ void uw_request_init(uw_app *app, void *logger_data, uw_logger log_error, uw_log
{
pthread_t thread;
- if (uw_time_max && pthread_create(&thread, NULL, ticker, NULL)) {
+ if (uw_time_max && pthread_create_big(&thread, NULL, ticker, NULL)) {
fprintf(stderr, "Error creating ticker thread\n");
exit(1);
}
@@ -174,7 +202,7 @@ void uw_request_init(uw_app *app, void *logger_data, uw_logger log_error, uw_log
arg->ls = ls;
arg->pdic = *ps;
- if (pthread_create(&thread, NULL, periodic_loop, arg)) {
+ if (pthread_create_big(&thread, NULL, periodic_loop, arg)) {
fprintf(stderr, "Error creating periodic thread\n");
exit(1);
}