More work on IPC code, added aqhomed daemon.

This commit is contained in:
Martin Preuss
2023-03-18 23:25:21 +01:00
parent c26119d34c
commit d1c21322b8
23 changed files with 1127 additions and 61 deletions

View File

@@ -27,10 +27,8 @@ GWEN_INHERIT(GWEN_MSG_ENDPOINT_MGR, AQH_MSG_ENDPOINT_MGR);
static void GWENHYWFAR_CB _freeData(void *bp, void *p);
static void _msgLoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr);
static void _handleEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep);
static void _handleNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep);
static void _handleIpcEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep);
static void _distributeMsgFromNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *srcEp, const GWEN_MSG *msg);
@@ -64,19 +62,19 @@ void _freeData(void *bp, void *p)
int AQH_MsgEndpointMgr_LoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr)
int AQH_MsgEndpointMgr_LoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr, int groupId)
{
int rv;
rv=GWEN_MsgEndpointMgr_IoLoopOnce(emgr);
_msgLoopOnce(emgr);
AQH_MsgEndpointMgr_LoopOnceOverNodeEndpoints(emgr, groupId);
GWEN_MsgEndpointMgr_RunAllEndpoints(emgr);
return rv;
}
void _msgLoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr)
void AQH_MsgEndpointMgr_LoopOnceOverNodeEndpoints(GWEN_MSG_ENDPOINT_MGR *emgr, int groupId)
{
GWEN_MSG_ENDPOINT_LIST *endpointList;
@@ -88,7 +86,8 @@ void _msgLoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr)
ep=GWEN_MsgEndpoint_List_First(endpointList);
while(ep) {
DBG_DEBUG(AQH_LOGDOMAIN, "- endpoint(%s)", GWEN_MsgEndpoint_GetName(ep));
_handleEndpoint(emgr, ep);
if (GWEN_MsgEndpoint_GetGroupId(ep)==groupId)
_handleNodeEndpoint(emgr, ep);
ep=GWEN_MsgEndpoint_List_Next(ep);
}
}
@@ -96,17 +95,6 @@ void _msgLoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr)
void _handleEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep)
{
switch(GWEN_MsgEndpoint_GetGroupId(ep)) {
case AQH_MSG_ENDPOINTGROUP_NODE: _handleNodeEndpoint(emgr, ep); break;
case AQH_MSG_ENDPOINTGROUP_IPC: _handleIpcEndpoint(emgr, ep); break;
default: break;
}
}
void _handleNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep)
{
GWEN_MSG *msg;
@@ -122,13 +110,6 @@ void _handleNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep)
void _handleIpcEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep)
{
/* TODO: handle IPC messages */
}
void _distributeMsgFromNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *srcEp, const GWEN_MSG *msg)
{
GWEN_MSG_ENDPOINT_LIST *endpointList;
@@ -159,7 +140,7 @@ void _distributeMsgFromNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOI
) {
/* endpoint accepts this message */
DBG_DEBUG(AQH_LOGDOMAIN, " - endpoint %s accepts message", GWEN_MsgEndpoint_GetName(ep));
GWEN_MsgEndpoint_AddSendMessage(ep, GWEN_Msg_dup(msg));
GWEN_MsgEndpoint_ProcessOutMessage(ep, GWEN_Msg_dup(msg));
}
else {
DBG_DEBUG(AQH_LOGDOMAIN, " - endpoint %s does not accept message", GWEN_MsgEndpoint_GetName(ep));