Add single-threaded NOOP

FossilOrigin-Name: 706225b5257311abdb37ed19ee3d4da2b2fe9cbf1aa88841f6f91b4ce66a4490
This commit is contained in:
nekobit 2022-08-24 01:00:46 +00:00
parent dce5df9821
commit 67a2f90c8b
2 changed files with 18 additions and 2 deletions

View file

@ -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)

View file

@ -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();