fixed another memory leak: handle received result responses

just remove them from the queue.
This commit is contained in:
Martin Preuss
2023-10-06 18:05:14 +02:00
parent 38ae2d3d1d
commit e98afa80d9
4 changed files with 117 additions and 0 deletions

View File

@@ -38,6 +38,7 @@
init.h
fini.h
loop.h
loop_broker.h
loop_tty.h
loop_tty_ipc.h
loop_tty_broker.h
@@ -53,6 +54,7 @@
init.c
fini.c
loop.c
loop_broker.c
loop_tty.c
loop_tty_ipc.c
loop_tty_broker.c

View File

@@ -14,6 +14,7 @@
#include "./loop.h"
#include "./loop_tty.h"
#include "./loop_ipc.h"
#include "./loop_broker.h"
#include "./aqhomed_p.h"
#include "./tty_log.h"
#include "./db.h"
@@ -61,6 +62,21 @@ void AqHomed_Loop(AQHOMED *aqh, int timeoutInMsecs)
GWEN_MsgEndpoint_ChildrenIoLoop(aqh->rootEndpoint, timeoutInMsecs);
AqHomed_ReadAndHandleTtyMessages(aqh);
AqHomed_ReadAndHandleIpcMessages(aqh);
AqHomed_ReadAndHandleBrokerMessages(aqh);
#if 0
DBG_ERROR(NULL, "Messages in TTY queue: %d in, %d out",
GWEN_Msg_List_GetCount(GWEN_MsgEndpoint_GetReceivedMessageList(aqh->ttyEndpoint)),
GWEN_Msg_List_GetCount(GWEN_MsgEndpoint_GetSendMessageList(aqh->ttyEndpoint)));
DBG_ERROR(NULL, "Messages in IPC queue: %d in, %d out",
GWEN_Msg_List_GetCount(GWEN_MsgEndpoint_GetReceivedMessageList(aqh->ipcdEndpoint)),
GWEN_Msg_List_GetCount(GWEN_MsgEndpoint_GetSendMessageList(aqh->ipcdEndpoint)));
DBG_ERROR(NULL, "Messages in Broker queue: %d in, %d out",
GWEN_Msg_List_GetCount(GWEN_MsgEndpoint_GetReceivedMessageList(aqh->brokerEndpoint)),
GWEN_Msg_List_GetCount(GWEN_MsgEndpoint_GetSendMessageList(aqh->brokerEndpoint)));
#endif
if (AQH_NodeDb_IsModified(aqh->nodeDb)) {
if (aqh->dbFile) {

View File

@@ -0,0 +1,76 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "./loop_broker.h"
#include "./aqhomed_p.h"
#include "./tty_log.h"
#include "./db.h"
#include "aqhome/msg/endpoint_tty.h"
#include "aqhome/msg/msg_node.h"
#include "aqhome/msg/msg_value2.h"
#include "aqhome/msg/msg_ping.h"
#include "aqhome/ipc/endpoint_ipc.h"
#include "aqhome/ipc/msg_ipc_result.h"
#include <gwenhywfar/gwenhywfar.h>
#include <gwenhywfar/args.h>
#include <gwenhywfar/debug.h>
#include <gwenhywfar/endpoint_tcpd.h>
/* ------------------------------------------------------------------------------------------------
* defines
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* forward declarations
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* implementations
* ------------------------------------------------------------------------------------------------
*/
void AqHomed_ReadAndHandleBrokerMessages(AQHOMED *aqh)
{
if (aqh->brokerEndpoint) {
GWEN_MSG_ENDPOINT *epTcp;
GWEN_MSG *msg;
epTcp=aqh->brokerEndpoint;
while( (msg=GWEN_MsgEndpoint_TakeFirstReceivedMessage(epTcp)) ) {
uint16_t code;
code=GWEN_IpcMsg_GetCode(msg);
DBG_DEBUG(AQH_LOGDOMAIN, "Received IPC packet %d (%x)", (int) code, code);
GWEN_Msg_free(msg);
}
}
}

View File

@@ -0,0 +1,23 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifndef AQHOMED_LOOP_BROKER_H
#define AQHOMED_LOOP_BROKER_H
#include "./aqhomed.h"
void AqHomed_ReadAndHandleBrokerMessages(AQHOMED *aqh);
#endif