diff --git a/src/global_perl.h b/src/global_perl.h index f821af4..476f160 100644 --- a/src/global_perl.h +++ b/src/global_perl.h @@ -50,8 +50,14 @@ extern PerlInterpreter* my_perl; extern HV* template_files; extern pthread_mutex_t perllock_mutex; +#ifndef SINGLE_THREADED #define perl_lock() do { pthread_mutex_lock(&perllock_mutex); } while (0) #define perl_unlock() do { pthread_mutex_unlock(&perllock_mutex); } while (0) +#else +// NOOP +#define perl_lock() ;; +#define perl_unlock() ;; +#endif #define ARG_UNDEFINED() do { XPUSHs(&PL_sv_undef); } while (0) diff --git a/src/main.c b/src/main.c index 48416f3..c4ed041 100644 --- a/src/main.c +++ b/src/main.c @@ -200,6 +200,14 @@ static void* threaded_fcgi_start(void* arg) return NULL; } +#else +void cgi_start(mastodont_t* api) +{ + while (FCGI_Accept() >= 0) + { + application(api, NULL); + } +} #endif EXTERN_C void xs_init(pTHX) @@ -238,15 +246,17 @@ int main(int argc, char **argv, char **env) pthread_t id[THREAD_COUNT]; for (unsigned i = 0; i < THREAD_COUNT; ++i) - pthread_create(&id[i], NULL, cgi_start, &api); + pthread_create(&id[i], NULL, threaded_fcgi_start, &api); // Hell, let's not sit around here either -threaded_fcgi_start(&api); + threaded_fcgi_start(&api); FCGX_ShutdownPending(); for (unsigned i = 0; i < THREAD_COUNT; ++i) pthread_join(id[i], NULL); +#else + cgi_start(&api); #endif free_instance_info_cache();