Added handling of timeout cmd arg for valgrind test. fixed memory leaks.

This commit is contained in:
Martin Preuss
2023-10-05 23:56:53 +02:00
parent b66f3d2ef4
commit 8613fbdad7
12 changed files with 123 additions and 6 deletions

View File

@@ -44,6 +44,7 @@
* ------------------------------------------------------------------------------------------------
*/
static void _runService(AQHOMED *aqh);
#ifdef HAVE_SIGNAL_H
static int _setSignalHandlers(void);
static int _setupSigAction(struct sigaction *sa, int sig);
@@ -108,10 +109,7 @@ int main(int argc, char **argv)
return 2;
}
while(!stopService) {
DBG_DEBUG(NULL, "Next loop");
AqHomed_Loop(aqh, 2000);
}
_runService(aqh);
AqHomed_Fini(aqh);
AqHomed_free(aqh);
@@ -124,6 +122,30 @@ int main(int argc, char **argv)
void _runService(AQHOMED *aqh)
{
time_t timeStart;
int timeout;
timeout=AqHomed_GetTimeout(aqh);
timeStart=time(NULL);
while(!stopService) {
AqHomed_Loop(aqh, 2000);
if (timeout) {
time_t now;
now=time(NULL);
if (timeout && ((int)difftime(now, timeStart))>timeout) {
DBG_INFO(NULL, "Timeout");
break;
}
}
} /* while */
}
int _setSignalHandlers(void)
{
#ifdef HAVE_SIGNAL_H