mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-14 23:33:38 +00:00
1. Updated LinkedList to use ILibMemory_SmartAllocate
2. Updated ILibChain_Continue to flag when it exits the processing loop 3. Updated main loop to reset continuation flag at the start of each loop
This commit is contained in:
@@ -255,6 +255,9 @@ typedef struct ILibLinkedListNode_Root
|
|||||||
void *ExtraMemory;
|
void *ExtraMemory;
|
||||||
}ILibLinkedListNode_Root;
|
}ILibLinkedListNode_Root;
|
||||||
|
|
||||||
|
const int ILibLinkedListNode_SIZE = sizeof(ILibLinkedListNode);
|
||||||
|
const int ILibLinkedListNodeRoot_Size = sizeof(ILibLinkedListNode_Root);
|
||||||
|
|
||||||
struct ILibReaderWriterLock_Data
|
struct ILibReaderWriterLock_Data
|
||||||
{
|
{
|
||||||
ILibChain_PreSelect Pre;
|
ILibChain_PreSelect Pre;
|
||||||
@@ -863,12 +866,6 @@ struct ILibBaseChain_SafeData
|
|||||||
void *Object;
|
void *Object;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum ILibChain_ContinuationStates
|
|
||||||
{
|
|
||||||
ILibChain_ContinuationState_INACTIVE = 0,
|
|
||||||
ILibChain_ContinuationState_CONTINUE = 1,
|
|
||||||
ILibChain_ContinuationState_END_CONTINUE= 2
|
|
||||||
}ILibChain_ContinuationStates;
|
|
||||||
|
|
||||||
typedef struct ILibBaseChain
|
typedef struct ILibBaseChain
|
||||||
{
|
{
|
||||||
@@ -1921,6 +1918,10 @@ void ILibChain_UpdateEventHook(ILibChain_EventHookToken token, int maxTimeout)
|
|||||||
memset(hook, 0, sizeof(ILibChain_Link_Hook));
|
memset(hook, 0, sizeof(ILibChain_Link_Hook));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ILibChain_ContinuationStates ILibChain_GetContinuationState(void *chain)
|
||||||
|
{
|
||||||
|
return(((ILibBaseChain*)chain)->continuationState);
|
||||||
|
}
|
||||||
ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules, int moduleCount, int maxTimeout)
|
ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules, int moduleCount, int maxTimeout)
|
||||||
{
|
{
|
||||||
ILibBaseChain *chain = (ILibBaseChain*)Chain;
|
ILibBaseChain *chain = (ILibBaseChain*)Chain;
|
||||||
@@ -1936,7 +1937,7 @@ ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules,
|
|||||||
ILibLinkedListNode tmpNode;
|
ILibLinkedListNode tmpNode;
|
||||||
memset(&tmpNode, 0, sizeof(tmpNode));
|
memset(&tmpNode, 0, sizeof(tmpNode));
|
||||||
|
|
||||||
if (root->continuationState != ILibChain_ContinuationState_INACTIVE) { return; }
|
if (root->continuationState != ILibChain_ContinuationState_INACTIVE && root->continuationState != ILibChain_ContinuationState_END_CONTINUE) { return; }
|
||||||
root->continuationState = ILibChain_ContinuationState_CONTINUE;
|
root->continuationState = ILibChain_ContinuationState_CONTINUE;
|
||||||
currentNode = root->node;
|
currentNode = root->node;
|
||||||
|
|
||||||
@@ -1977,17 +1978,8 @@ ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules,
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
nodeHook = (ILibChain_Link_Hook*)ILibLinkedList_GetExtendedMemory(chain->node);
|
|
||||||
if (nodeHook->MaxTimeout > 0 && nodeHook->MaxTimeout < chain->selectTimeout) { chain->selectTimeout = nodeHook->MaxTimeout; }
|
|
||||||
if (moduleCount > 0)
|
|
||||||
{
|
|
||||||
++mX;
|
++mX;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
chain->node = ILibLinkedList_GetNextNode(chain->node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tv.tv_sec = chain->selectTimeout / 1000;
|
tv.tv_sec = chain->selectTimeout / 1000;
|
||||||
tv.tv_usec = 1000 * (chain->selectTimeout % 1000);
|
tv.tv_usec = 1000 * (chain->selectTimeout % 1000);
|
||||||
|
|
||||||
@@ -2095,8 +2087,6 @@ ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ILibRemoteLogging_printf(ILibChainGetLogger(chain), ILibRemoteLogging_Modules_Microstack_Generic, ILibRemoteLogging_Flags_VerbosityLevel_1, "ContinueChain...Ending...");
|
ILibRemoteLogging_printf(ILibChainGetLogger(chain), ILibRemoteLogging_Modules_Microstack_Generic, ILibRemoteLogging_Flags_VerbosityLevel_1, "ContinueChain...Ending...");
|
||||||
|
|
||||||
root->continuationState = ILibChain_ContinuationState_INACTIVE;
|
|
||||||
root->node = currentNode;
|
root->node = currentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2783,6 +2773,8 @@ ILibExportMethod void ILibStartChain(void *Chain)
|
|||||||
tv.tv_sec = UPNP_MAX_WAIT;
|
tv.tv_sec = UPNP_MAX_WAIT;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
|
if (chain->continuationState == ILibChain_ContinuationState_END_CONTINUE) { chain->continuationState = ILibChain_ContinuationState_INACTIVE; }
|
||||||
|
|
||||||
//
|
//
|
||||||
// Iterate through all the PreSelect function pointers in the chain
|
// Iterate through all the PreSelect function pointers in the chain
|
||||||
//
|
//
|
||||||
@@ -6694,15 +6686,14 @@ void* ILibLinkedList_GetTag(ILibLinkedList list)
|
|||||||
|
|
||||||
void* ILibLinkedList_AllocateNode(void *LinkedList)
|
void* ILibLinkedList_AllocateNode(void *LinkedList)
|
||||||
{
|
{
|
||||||
void* newNode;
|
void* newNode = ILibMemory_SmartAllocateEx(sizeof(ILibLinkedListNode), ILibMemory_GetExtraMemorySize(((ILibLinkedListNode_Root*)LinkedList)->ExtraMemory));
|
||||||
ILibMemory_Allocate(sizeof(ILibLinkedListNode), ILibMemory_GetExtraMemorySize(((ILibLinkedListNode_Root*)LinkedList)->ExtraMemory), &newNode, NULL);
|
|
||||||
return(newNode);
|
return(newNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* ILibLinkedList_GetExtendedMemory(void* LinkedList_Node)
|
void* ILibLinkedList_GetExtendedMemory(void* LinkedList_Node)
|
||||||
{
|
{
|
||||||
if (LinkedList_Node == NULL) { return(NULL); }
|
if (LinkedList_Node == NULL || !ILibMemory_CanaryOK(LinkedList_Node)) { return(NULL); }
|
||||||
return(ILibMemory_GetExtraMemory(LinkedList_Node, sizeof(ILibLinkedListNode)));
|
return(ILibMemory_Extra(LinkedList_Node));
|
||||||
}
|
}
|
||||||
/*! \fn ILibLinkedList_ShallowCopy(void *LinkedList)
|
/*! \fn ILibLinkedList_ShallowCopy(void *LinkedList)
|
||||||
\brief Create a shallow copy of a linked list. That is, the structure is copied, but none of the data contents are copied. The pointer values are just copied.
|
\brief Create a shallow copy of a linked list. That is, the structure is copied, but none of the data contents are copied. The pointer values are just copied.
|
||||||
@@ -6881,7 +6872,7 @@ void* ILibLinkedList_Remove(void *LinkedList_Node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
--r->count;
|
--r->count;
|
||||||
free(n);
|
ILibMemory_Free(n);
|
||||||
return RetVal;
|
return RetVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -310,6 +310,12 @@ int ILibIsRunningOnChainThread(void* chain);
|
|||||||
ILibServerScope_LocalSegment=2
|
ILibServerScope_LocalSegment=2
|
||||||
}ILibServerScope;
|
}ILibServerScope;
|
||||||
|
|
||||||
|
typedef enum ILibChain_ContinuationStates
|
||||||
|
{
|
||||||
|
ILibChain_ContinuationState_INACTIVE = 0,
|
||||||
|
ILibChain_ContinuationState_CONTINUE = 1,
|
||||||
|
ILibChain_ContinuationState_END_CONTINUE = 2
|
||||||
|
}ILibChain_ContinuationStates;
|
||||||
|
|
||||||
typedef void(*ILibChain_PreSelect)(void* object, fd_set *readset, fd_set *writeset, fd_set *errorset, int* blocktime);
|
typedef void(*ILibChain_PreSelect)(void* object, fd_set *readset, fd_set *writeset, fd_set *errorset, int* blocktime);
|
||||||
typedef void(*ILibChain_PostSelect)(void* object, int slct, fd_set *readset, fd_set *writeset, fd_set *errorset);
|
typedef void(*ILibChain_PostSelect)(void* object, int slct, fd_set *readset, fd_set *writeset, fd_set *errorset);
|
||||||
@@ -936,6 +942,7 @@ int ILibIsRunningOnChainThread(void* chain);
|
|||||||
ILibExportMethod void ILibStopChain(void *chain);
|
ILibExportMethod void ILibStopChain(void *chain);
|
||||||
ILibExportMethod void ILibChain_Continue(void *chain, ILibChain_Link **modules, int moduleCount, int maxTimeout);
|
ILibExportMethod void ILibChain_Continue(void *chain, ILibChain_Link **modules, int moduleCount, int maxTimeout);
|
||||||
ILibExportMethod void ILibChain_EndContinue(void *chain);
|
ILibExportMethod void ILibChain_EndContinue(void *chain);
|
||||||
|
ILibChain_ContinuationStates ILibChain_GetContinuationState(void *chain);
|
||||||
#define ILibChain_FreeLink(link) ((ILibChain_Link*)link)->RESERVED = 0xFFFFFFFF;free(link);
|
#define ILibChain_FreeLink(link) ((ILibChain_Link*)link)->RESERVED = 0xFFFFFFFF;free(link);
|
||||||
#define ILibChain_IsLinkAlive(link) (((ILibChain_Link*)link)->RESERVED == ILibMemory_Canary)
|
#define ILibChain_IsLinkAlive(link) (((ILibChain_Link*)link)->RESERVED == ILibMemory_Canary)
|
||||||
|
|
||||||
@@ -1092,6 +1099,9 @@ int ILibIsRunningOnChainThread(void* chain);
|
|||||||
void ILibLinkedList_SetTag(ILibLinkedList list, void *tag);
|
void ILibLinkedList_SetTag(ILibLinkedList list, void *tag);
|
||||||
void* ILibLinkedList_GetTag(ILibLinkedList list);
|
void* ILibLinkedList_GetTag(ILibLinkedList list);
|
||||||
int ILibLinkedList_GetIndex(void *node);
|
int ILibLinkedList_GetIndex(void *node);
|
||||||
|
extern const int ILibLinkedListNode_SIZE;
|
||||||
|
extern const int ILibLinkedListNodeRoot_Size;
|
||||||
|
|
||||||
|
|
||||||
//! Comparer delegate is called to compare two values. Mimics behavior of .NET IComparer..
|
//! Comparer delegate is called to compare two values. Mimics behavior of .NET IComparer..
|
||||||
//! obj2 == obj1 : 0
|
//! obj2 == obj1 : 0
|
||||||
|
|||||||
Reference in New Issue
Block a user