projects
/
apps
/
pfixtools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clean tests on clean.
[apps/pfixtools.git]
/
postlicyd.c
diff --git
a/postlicyd.c
b/postlicyd.c
index
bc8eeea
..
e9eb1c2
100644
(file)
--- a/
postlicyd.c
+++ b/
postlicyd.c
@@
-37,10
+37,11
@@
#include <time.h>
#include <getopt.h>
#include <time.h>
#include <getopt.h>
-#include "
postlicyd
.h"
+#include "
common
.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)
{
static void main_sighandler(int sig)
{
@@
-78,20
+79,37
@@
static void main_initialize(void)
syslog(LOG_INFO, "Starting...");
}
syslog(LOG_INFO, "Starting...");
}
+void *job_run(void *_fd)
+{
+ int fd = (intptr_t)_fd;
+
+ close(fd);
+ return NULL;
+}
+
static void main_loop(void)
{
static void main_loop(void)
{
+ int sock = -1;
+
while (!sigint) {
while (!sigint) {
- int fd = accept(-1, NULL, 0);
+ int fd = accept(sock, NULL, 0);
+ pthread_attr_t attr;
+ pthread_t dummy;
if (fd < 0) {
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);
}
}
+
+ cleanexit = true;
+ close(sock);
}
static void main_shutdown(void)
}
static void main_shutdown(void)
@@
-109,7
+127,6
@@
int main(void)
main_initialize();
main_loop();
main_initialize();
main_loop();
- cleanexit = true;
main_shutdown();
return EXIT_SUCCESS;
}
main_shutdown();
return EXIT_SUCCESS;
}