X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=postlicyd.c;h=bd887e45a1ba9e6888545de8859f87e62d59c0d5;hb=79ff3ad0aaa667dc9ce658460632177c8ffcf39e;hp=bc8eeea02b9fb56c305b785b7f360c8119d16588;hpb=c0cfcd4c414bd423e4766ff6c90850ee25c9b449;p=apps%2Fpfixtools.git 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); } }