cleanup connections every 10s.

This commit is contained in:
Martin Preuss
2023-09-16 15:47:39 +02:00
parent cf005fa60c
commit 8c60c3c8e4

View File

@@ -31,8 +31,9 @@
//#define WRITE_INTERVAL_IN_SECS (5*60)
#define WRITE_INTERVAL_IN_SECS (60)
#define PING_INTERVAL 120
#define WRITE_INTERVAL_IN_SECS 60
#define PING_INTERVAL 120
#define CONNCLEAN_INTERVAL_IN_SECS 10
@@ -133,11 +134,13 @@ void _runService(AQHOME_DATA *aqh)
{
time_t timeStart;
time_t timeLastWrite;
time_t timeLastConnectionCleanup;
int timeout;
timeout=AqHomeData_GetTimeout(aqh);
timeStart=time(NULL);
timeLastWrite=time(NULL);
timeLastConnectionCleanup=time(NULL);
while(!stopService) {
time_t now;
@@ -147,6 +150,12 @@ void _runService(AQHOME_DATA *aqh)
now=time(NULL);
if (((int)difftime(now, timeLastConnectionCleanup))>CONNCLEAN_INTERVAL_IN_SECS) {
DBG_INFO(NULL, "Cleanup connections");
GWEN_MsgEndpoint_RemoveUnconnectedAndEmptyChildren(AqHomeData_GetIpcdEndpoint(aqh));
timeLastConnectionCleanup=now;
}
if (((int)difftime(now, timeLastWrite))>WRITE_INTERVAL_IN_SECS) {
DBG_INFO(NULL, "Write time");
_writeCurrentState(aqh);