Fixed more meory leaks.

This commit is contained in:
Martin Preuss
2023-10-06 00:17:15 +02:00
parent 8613fbdad7
commit ab6480ebca
5 changed files with 14 additions and 16 deletions

View File

@@ -55,6 +55,11 @@ void AqHomeMqtt_Fini(AQHOME_MQTT *aqh)
aqh->brokerEndpoint=NULL; aqh->brokerEndpoint=NULL;
aqh->mqttEndpoint=NULL; aqh->mqttEndpoint=NULL;
AQHMQTT_Device_List_free(aqh->availableDeviceList);
aqh->availableDeviceList=NULL;
AQHMQTT_Device_List_free(aqh->registeredDeviceList);
aqh->registeredDeviceList=NULL;
if (aqh->pidFile) if (aqh->pidFile)
remove(aqh->pidFile); remove(aqh->pidFile);
} }

View File

@@ -58,7 +58,7 @@
* ------------------------------------------------------------------------------------------------ * ------------------------------------------------------------------------------------------------
*/ */
static int _serve(AQHOME_MQTT *aqh); static void _serve(AQHOME_MQTT *aqh);
#ifdef HAVE_SIGNAL_H #ifdef HAVE_SIGNAL_H
static int _setSignalHandlers(void); static int _setSignalHandlers(void);
@@ -124,11 +124,7 @@ int main(int argc, char **argv)
GWEN_Gui_SetCharSet(gui, s); GWEN_Gui_SetCharSet(gui, s);
GWEN_Gui_SetGui(gui); GWEN_Gui_SetGui(gui);
rv=_serve(aqh); _serve(aqh);
if (rv<0) {
DBG_INFO(NULL, "here (%d)", rv);
return 2;
}
AqHomeMqtt_Fini(aqh); AqHomeMqtt_Fini(aqh);
AqHomeMqtt_free(aqh); AqHomeMqtt_free(aqh);
@@ -141,9 +137,8 @@ int main(int argc, char **argv)
int _serve(AQHOME_MQTT *aqh) void _serve(AQHOME_MQTT *aqh)
{ {
GWEN_MSG_ENDPOINT *epTcp;
int rv; int rv;
int timeout; int timeout;
time_t startTime; time_t startTime;
@@ -156,16 +151,14 @@ int _serve(AQHOME_MQTT *aqh)
rv=_setSignalHandlers(); rv=_setSignalHandlers();
if (rv<0) { if (rv<0) {
DBG_INFO(NULL, "here (%d)", rv); DBG_ERROR(NULL, "Error setting signal handlers (%d)", rv);
return rv; return;
} }
timeout=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 0); timeout=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 0);
lastPingSendTime=time(NULL); lastPingSendTime=time(NULL);
epTcp=AqHomeMqtt_GetMqttEndpoint(aqh);
while(!stopService) { while(!stopService) {
DBG_DEBUG(NULL, "Next loop"); DBG_DEBUG(NULL, "Next loop");
AqHomeMqttLog_Loop(aqh, 2000); AqHomeMqttLog_Loop(aqh, 2000);
@@ -175,7 +168,7 @@ int _serve(AQHOME_MQTT *aqh)
now=time(NULL); now=time(NULL);
if ((now-startTime)>timeout) { if ((now-startTime)>timeout) {
DBG_INFO(NULL, "Timeout, stopping service"); DBG_ERROR(NULL, "Timeout, stopping service");
break; break;
} }
} }
@@ -192,9 +185,6 @@ int _serve(AQHOME_MQTT *aqh)
} }
} }
} }
GWEN_MsgEndpoint_free(epTcp);
return 0;
} }

View File

@@ -63,6 +63,7 @@
<access>public</access> <access>public</access>
<flags>own noconst</flags> <flags>own noconst</flags>
<getflags>none</getflags> <getflags>none</getflags>
<setflags>none</setflags>
</member> </member>

View File

@@ -96,6 +96,7 @@
<access>public</access> <access>public</access>
<flags>own</flags> <flags>own</flags>
<getflags>none</getflags> <getflags>none</getflags>
<setflags>none</setflags>
</member> </member>
</members> </members>

View File

@@ -80,6 +80,7 @@
<access>public</access> <access>public</access>
<flags>own</flags> <flags>own</flags>
<getflags>none</getflags> <getflags>none</getflags>
<setflags>none</setflags>
</member> </member>