From 29ff963194bc5c93be12f69d253edc9052671efa Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Mon, 17 Jul 2023 20:29:37 +0200 Subject: [PATCH] Minor changes --- Makefile | 2 +- src/logger.c | 32 ++++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index d832451..46ad715 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ subscriber: src/subscriber.c src/utils.c config.mk $(CC) -lzmq $(filter-out config.mk,$^) -o $@ $(MACROS) logger: src/logger.c src/utils.c config.mk - $(CC) -lzmq $(filter-out config.mk,$^) -o $@ $(MACROS) + $(CC) -lzmq -lpthread $(filter-out config.mk,$^) -o $@ $(MACROS) publish: publisher logger for client in $$(basename -a /sys/kernel/ina260/*); \ diff --git a/src/logger.c b/src/logger.c index 9f9d78d..2aa565b 100644 --- a/src/logger.c +++ b/src/logger.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "utils.h" #ifndef LOGGERS_DELAY @@ -28,7 +29,7 @@ void sighandler(int signo){ } } -void publish(int queue_id, void* publisher); +void *publish(void *publisher); typedef struct queue { int size; @@ -87,6 +88,7 @@ int main (int argc, char *argv []) //----- Start logging + pthread_t zmq_thread; printf("Logger started [client=%s,interval=%ds]\n",__client,__loginterval); FILE *regptr,*logptr; @@ -102,6 +104,7 @@ int main (int argc, char *argv []) for(int i=0;i 0 + usleep(LOGGERS_DELAY*1000); +#endif + continue; + } + queue_id++; + if(queue_id>=MAX_QUEUES) + queue_id=0; + } + pthread_exit(EXIT_SUCCESS); } \ No newline at end of file