diff --git a/fiche.c b/fiche.c index 370dbac..d4a4bfa 100644 --- a/fiche.c +++ b/fiche.c @@ -33,6 +33,7 @@ Use netcat to push text - example: #include #include +#include #include #include #include @@ -520,12 +521,18 @@ static void dispatch_connection(int socket, Fiche_Settings *settings) { // Spawn a new thread to handle this connection pthread_t id; + pthread_attr_t attr; - if ( pthread_create(&id, NULL, &handle_connection, c) != 0 ) { + if ( (errno = pthread_attr_init(&attr)) || + (errno = pthread_attr_setstacksize(&attr, 16*1024)) || + (errno = pthread_create(&id, &attr, &handle_connection, c)) ) { + pthread_attr_destroy(&attr); print_error("Couldn't spawn a thread!"); return; } + pthread_attr_destroy(&attr); + // Detach thread if created succesfully // TODO: consider using pthread_tryjoin_np pthread_detach(id);