mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-14 23:33:38 +00:00
1. Fixed bug where global-tunnel.end() didn't clear the proxy
2. Broke infinite loop that could occur with circular referenced list 3. Added NULL check
This commit is contained in:
@@ -125,18 +125,21 @@ void Duktape_RunOnEventLoop_AbortSink(void *chain, void *user)
|
|||||||
void Duktape_RunOnEventLoop_Sink(void *chain, void *user)
|
void Duktape_RunOnEventLoop_Sink(void *chain, void *user)
|
||||||
{
|
{
|
||||||
Duktape_EventLoopDispatchData *tmp = (Duktape_EventLoopDispatchData*)user;
|
Duktape_EventLoopDispatchData *tmp = (Duktape_EventLoopDispatchData*)user;
|
||||||
if (duk_ctx_is_alive(tmp->ctx) && duk_ctx_is_valid(tmp->nonce, tmp->ctx))
|
if (tmp != NULL)
|
||||||
{
|
{
|
||||||
// duk_context matches the intended context
|
if (duk_ctx_is_alive(tmp->ctx) && duk_ctx_is_valid(tmp->nonce, tmp->ctx))
|
||||||
if (tmp->handler != NULL) { tmp->handler(chain, tmp->user); }
|
{
|
||||||
|
// duk_context matches the intended context
|
||||||
|
if (tmp->handler != NULL) { tmp->handler(chain, tmp->user); }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// duk_context does not match the intended context
|
||||||
|
Duktape_RunOnEventLoop_AbortSink(chain, user);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ILibMemory_Free(tmp);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// duk_context does not match the intended context
|
|
||||||
Duktape_RunOnEventLoop_AbortSink(chain, user);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ILibMemory_Free(tmp);
|
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
void __stdcall Duktape_RunOnEventLoop_SanityCheck(ULONG_PTR u)
|
void __stdcall Duktape_RunOnEventLoop_SanityCheck(ULONG_PTR u)
|
||||||
|
|||||||
@@ -1898,8 +1898,16 @@ void ILibDuktape_net_PUSH_net(duk_context *ctx, void *chain)
|
|||||||
}
|
}
|
||||||
duk_ret_t ILibDuktape_globalTunnel_end(duk_context *ctx)
|
duk_ret_t ILibDuktape_globalTunnel_end(duk_context *ctx)
|
||||||
{
|
{
|
||||||
duk_push_heap_stash(ctx);
|
ILibDuktape_globalTunnel_data *data;
|
||||||
duk_del_prop_string(ctx, -1, ILibDuktape_GlobalTunnel_Stash);
|
ILibHashtable tmp;
|
||||||
|
duk_push_this(ctx);
|
||||||
|
duk_get_prop_string(ctx, -1, ILibDuktape_GlobalTunnel_DataPtr);
|
||||||
|
data = (ILibDuktape_globalTunnel_data*)Duktape_GetBuffer(ctx, -1, NULL);
|
||||||
|
tmp = data->exceptionsTable;
|
||||||
|
ILibHashtable_Clear(tmp);
|
||||||
|
|
||||||
|
memset(data, 0, sizeof(ILibDuktape_globalTunnel_data));
|
||||||
|
data->exceptionsTable = tmp;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
duk_ret_t ILibDuktape_globalTunnel_initialize(duk_context *ctx)
|
duk_ret_t ILibDuktape_globalTunnel_initialize(duk_context *ctx)
|
||||||
|
|||||||
@@ -919,7 +919,8 @@ struct ILibLifeTime
|
|||||||
|
|
||||||
void *Reserved;
|
void *Reserved;
|
||||||
char *CurrentTriggeredMetaData;
|
char *CurrentTriggeredMetaData;
|
||||||
|
|
||||||
|
void *DeleteList;
|
||||||
void *ObjectList;
|
void *ObjectList;
|
||||||
int ObjectCount;
|
int ObjectCount;
|
||||||
};
|
};
|
||||||
@@ -5218,7 +5219,7 @@ void *ILibQueue_DeQueue(ILibQueue q)
|
|||||||
void *node;
|
void *node;
|
||||||
|
|
||||||
node = ILibLinkedList_GetNode_Head((ILibLinkedList)q);
|
node = ILibLinkedList_GetNode_Head((ILibLinkedList)q);
|
||||||
if (node!=NULL)
|
if (node!=NULL && ILibMemory_CanaryOK(node))
|
||||||
{
|
{
|
||||||
RetVal = ILibLinkedList_GetDataFromNode(node);
|
RetVal = ILibLinkedList_GetDataFromNode(node);
|
||||||
ILibLinkedList_Remove(node);
|
ILibLinkedList_Remove(node);
|
||||||
@@ -7880,6 +7881,19 @@ void ILibLifeTime_Remove(void *LifeTimeToken, void *data)
|
|||||||
void *EventQueue;
|
void *EventQueue;
|
||||||
|
|
||||||
if (UPnPLifeTime == NULL || UPnPLifeTime->ObjectList == NULL) return;
|
if (UPnPLifeTime == NULL || UPnPLifeTime->ObjectList == NULL) return;
|
||||||
|
|
||||||
|
////
|
||||||
|
//// Check to see if we are on the Microstack Thread, to see if we can simplify this
|
||||||
|
////
|
||||||
|
//if (ILibIsRunningOnChainThread(UPnPLifeTime->ChainLink.ParentChain) == 0)
|
||||||
|
//{
|
||||||
|
// // Not on the right thread, so we need to defer processing to the Microstack Thread
|
||||||
|
// ILibQueue_Lock(NULL);
|
||||||
|
|
||||||
|
// ILibQueue_UnLock(NULL);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
EventQueue = ILibQueue_Create();
|
EventQueue = ILibQueue_Create();
|
||||||
ILibLinkedList_Lock(UPnPLifeTime->ObjectList);
|
ILibLinkedList_Lock(UPnPLifeTime->ObjectList);
|
||||||
|
|
||||||
@@ -8194,6 +8208,14 @@ void* ILibLinkedList_GetNode_Tail(void *LinkedList)
|
|||||||
*/
|
*/
|
||||||
void* ILibLinkedList_GetNextNode(void *LinkedList_Node)
|
void* ILibLinkedList_GetNextNode(void *LinkedList_Node)
|
||||||
{
|
{
|
||||||
|
if (ILibMemory_CanaryOK(LinkedList_Node))
|
||||||
|
{
|
||||||
|
if (((struct ILibLinkedListNode*)LinkedList_Node)->Next == LinkedList_Node)
|
||||||
|
{
|
||||||
|
// There is a circular reference, so we need to break the loop
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
return(ILibMemory_CanaryOK(LinkedList_Node) ? ((struct ILibLinkedListNode*)LinkedList_Node)->Next : NULL);
|
return(ILibMemory_CanaryOK(LinkedList_Node) ? ((struct ILibLinkedListNode*)LinkedList_Node)->Next : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user