From: Pierre Habouzit Date: Thu, 23 Aug 2007 22:14:22 +0000 (+0200) Subject: More administrivia. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=79ff3ad0aaa667dc9ce658460632177c8ffcf39e;p=apps%2Fpfixtools.git More administrivia. Signed-off-by: Pierre Habouzit --- diff --git a/postlicyd.c b/postlicyd.c index bc8eeea..bd887e4 100644 --- a/postlicyd.c +++ b/postlicyd.c @@ -39,8 +39,9 @@ #include "postlicyd.h" -static bool cleanexit = false; -static bool sigint = false; +static sig_atomic_t cleanexit = false; +static sig_atomic_t sigint = false; +static volatile int nbthreads = 0; static void main_sighandler(int sig) { @@ -78,19 +79,31 @@ static void main_initialize(void) syslog(LOG_INFO, "Starting..."); } +void *job_run(void *_fd) +{ + int fd = (intptr_t)_fd; + + close(fd); + return NULL; +} + static void main_loop(void) { while (!sigint) { int fd = accept(-1, NULL, 0); + pthread_attr_t attr; + pthread_t dummy; if (fd < 0) { - if (errno == EINTR || errno == EAGAIN) - continue; - syslog(LOG_ERR, "accept error: %m"); - return; + if (errno != EINTR || errno != EAGAIN) + UNIXERR("accept"); + continue; } - //pthread_create(NULL, NULL, job_run, (intptr_t)fd); + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + pthread_create(&dummy, &attr, job_run, (void *)(intptr_t)fd); + pthread_attr_destroy(&attr); } } diff --git a/postlicyd.h b/postlicyd.h index 3c6003c..6a885d9 100644 --- a/postlicyd.h +++ b/postlicyd.h @@ -38,6 +38,7 @@ #include #include +#include #include #include #include