mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-21 10:43:36 +00:00
Updated chain viewer to show timeouts
This commit is contained in:
@@ -2403,7 +2403,7 @@ duk_ret_t ILibDuktape_ChainViewer_getSnapshot(duk_context *ctx)
|
|||||||
duk_push_c_function(ctx, ILibDuktape_ChainViewer_getSnapshot_promise, 2); // [viewer][list][promise][func]
|
duk_push_c_function(ctx, ILibDuktape_ChainViewer_getSnapshot_promise, 2); // [viewer][list][promise][func]
|
||||||
duk_new(ctx, 1); // [viewer][list][promise]
|
duk_new(ctx, 1); // [viewer][list][promise]
|
||||||
duk_dup(ctx, -1); // [viewer][list][promise][promise]
|
duk_dup(ctx, -1); // [viewer][list][promise][promise]
|
||||||
duk_put_prop_index(ctx, -3, (duk_uarridx_t)duk_get_length(ctx, -3)); // [viewer][list][promise]
|
duk_put_prop_index(ctx, -3, (duk_uarridx_t)duk_get_length(ctx, -3)); // [viewer][list][promise]
|
||||||
ILibForceUnBlockChain(duk_ctx_chain(ctx));
|
ILibForceUnBlockChain(duk_ctx_chain(ctx));
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -969,6 +969,7 @@ typedef struct ILibBaseChain
|
|||||||
HANDLE WaitHandles[FD_SETSIZE * 2];
|
HANDLE WaitHandles[FD_SETSIZE * 2];
|
||||||
HANDLE currentHandle;
|
HANDLE currentHandle;
|
||||||
ILibChain_WaitHandleInfo *currentInfo;
|
ILibChain_WaitHandleInfo *currentInfo;
|
||||||
|
DWORD currentWaitTimeout;
|
||||||
#else
|
#else
|
||||||
pthread_t ChainThreadID;
|
pthread_t ChainThreadID;
|
||||||
int TerminatePipe[2];
|
int TerminatePipe[2];
|
||||||
@@ -2428,10 +2429,10 @@ ILibExportMethod void ILibChain_Continue(void *Chain, ILibChain_Link **modules,
|
|||||||
chain->PreSelectCount++;
|
chain->PreSelectCount++;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int x = 0;
|
int x = 0;
|
||||||
DWORD waitTimeout = 0;
|
chain->currentWaitTimeout = 0;
|
||||||
|
|
||||||
ILibChain_SetupWindowsWaitObject(chain->WaitHandles, &x, &tv, &waitTimeout, &readset, &writeset, &errorset, chain->auxSelectHandles, handles);
|
ILibChain_SetupWindowsWaitObject(chain->WaitHandles, &x, &tv, &(chain->currentWaitTimeout), &readset, &writeset, &errorset, chain->auxSelectHandles, handles);
|
||||||
slct = ILibChain_WindowsSelect(chain, &readset, &writeset, &errorset, chain->WaitHandles, x, waitTimeout);
|
slct = ILibChain_WindowsSelect(chain, &readset, &writeset, &errorset, chain->WaitHandles, x, chain->currentWaitTimeout);
|
||||||
#else
|
#else
|
||||||
slct = select(FD_SETSIZE, &readset, &writeset, &errorset, &tv);
|
slct = select(FD_SETSIZE, &readset, &writeset, &errorset, &tv);
|
||||||
#endif
|
#endif
|
||||||
@@ -3083,7 +3084,6 @@ char *ILibChain_GetMetaDataFromDescriptorSet(void *chain, fd_set *inr, fd_set *i
|
|||||||
struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 0;
|
struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 0;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
|
|
||||||
while (node != NULL && (module = (ILibChain_Link*)ILibLinkedList_GetDataFromNode(node)) != NULL)
|
while (node != NULL && (module = (ILibChain_Link*)ILibLinkedList_GetDataFromNode(node)) != NULL)
|
||||||
{
|
{
|
||||||
if (module->PreSelectHandler != NULL)
|
if (module->PreSelectHandler != NULL)
|
||||||
@@ -3123,79 +3123,121 @@ char *ILibChain_GetMetaDataFromDescriptorSetEx(void *chain, fd_set *inr, fd_set
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
ILibBaseChain *bchain = (ILibBaseChain*)chain;
|
ILibBaseChain *bchain = (ILibBaseChain*)chain;
|
||||||
#endif
|
#endif
|
||||||
char *retStr = (char*)ILibMemory_SmartAllocate(65535);
|
char *retStr = NULL;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
void *node = ILibLinkedList_GetNode_Head(((ILibBaseChain*)chain)->Links);
|
void *node;
|
||||||
ILibChain_Link *module;
|
ILibChain_Link *module;
|
||||||
fd_set readset;
|
fd_set readset;
|
||||||
fd_set errorset;
|
fd_set errorset;
|
||||||
fd_set writeset;
|
fd_set writeset;
|
||||||
fd_set emptyset; FD_ZERO(&emptyset);
|
fd_set emptyset; FD_ZERO(&emptyset);
|
||||||
int selectTimeout = UPNP_MAX_WAIT * 1000;
|
int selectTimeout = UPNP_MAX_WAIT * 1000;
|
||||||
int f;
|
int f, r;
|
||||||
size_t tmp;
|
size_t tmp;
|
||||||
|
size_t buflen = 0;
|
||||||
|
|
||||||
while (node != NULL && (module = (ILibChain_Link*)ILibLinkedList_GetDataFromNode(node)) != NULL)
|
while(1)
|
||||||
{
|
{
|
||||||
if (module->PreSelectHandler != NULL)
|
node = ILibLinkedList_GetNode_Head(((ILibBaseChain*)chain)->Links);
|
||||||
|
while (node != NULL && (module = (ILibChain_Link*)ILibLinkedList_GetDataFromNode(node)) != NULL)
|
||||||
{
|
{
|
||||||
FD_ZERO(&readset);
|
if (module->PreSelectHandler != NULL)
|
||||||
FD_ZERO(&errorset);
|
|
||||||
FD_ZERO(&writeset);
|
|
||||||
|
|
||||||
module->PreSelectHandler(module, &readset, &writeset, &errorset, &selectTimeout);
|
|
||||||
if (memcmp(&readset, &emptyset, sizeof(fd_set)) != 0 || memcmp(&writeset, &emptyset, sizeof(fd_set)) != 0 || memcmp(&errorset, &emptyset, sizeof(fd_set)) != 0)
|
|
||||||
{
|
{
|
||||||
// Descriptors were added
|
FD_ZERO(&readset);
|
||||||
|
FD_ZERO(&errorset);
|
||||||
|
FD_ZERO(&writeset);
|
||||||
|
|
||||||
|
module->PreSelectHandler(module, &readset, &writeset, &errorset, &selectTimeout);
|
||||||
|
if (memcmp(&readset, &emptyset, sizeof(fd_set)) != 0 || memcmp(&writeset, &emptyset, sizeof(fd_set)) != 0 || memcmp(&errorset, &emptyset, sizeof(fd_set)) != 0)
|
||||||
|
{
|
||||||
|
// Descriptors were added
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
SOCKET slist[FD_SETSIZE];
|
SOCKET slist[FD_SETSIZE];
|
||||||
int scount = 0;
|
int scount = 0;
|
||||||
for (f = 0; f < (int)readset.fd_count; ++f)
|
for (f = 0; f < (int)readset.fd_count; ++f)
|
||||||
{
|
|
||||||
slist[scount++] = readset.fd_array[f];
|
|
||||||
}
|
|
||||||
for (f = 0; f < (int)writeset.fd_count; ++f)
|
|
||||||
{
|
|
||||||
if (FD_ISSET(writeset.fd_array[f], &readset) == 0)
|
|
||||||
{
|
{
|
||||||
slist[scount++] = writeset.fd_array[f];
|
slist[scount++] = readset.fd_array[f];
|
||||||
}
|
}
|
||||||
}
|
for (f = 0; f < (int)writeset.fd_count; ++f)
|
||||||
for (f = 0; f < (int)errorset.fd_count; ++f)
|
|
||||||
{
|
|
||||||
if (FD_ISSET(errorset.fd_array[f], &readset) == 0 && FD_ISSET(errorset.fd_array[f], &writeset) == 0)
|
|
||||||
{
|
{
|
||||||
slist[scount++] = errorset.fd_array[f];
|
if (FD_ISSET(writeset.fd_array[f], &readset) == 0)
|
||||||
|
{
|
||||||
|
slist[scount++] = writeset.fd_array[f];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (f = 0; f < (int)errorset.fd_count; ++f)
|
||||||
|
{
|
||||||
|
if (FD_ISSET(errorset.fd_array[f], &readset) == 0 && FD_ISSET(errorset.fd_array[f], &writeset) == 0)
|
||||||
|
{
|
||||||
|
slist[scount++] = errorset.fd_array[f];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (f = 0; f < scount; ++f)
|
||||||
|
{
|
||||||
|
if (retStr == NULL)
|
||||||
|
{
|
||||||
|
buflen += snprintf(NULL, 0, " FD[%d] (R: %d, W: %d, E: %d) => %s\n", (int)slist[f], FD_ISSET(slist[f], inr), FD_ISSET(slist[f], inw), FD_ISSET(slist[f], ine), ((ILibChain_Link*)module)->QueryHandler != NULL ? ((ILibChain_Link*)module)->QueryHandler(chain, module, (int)slist[f], &tmp) : ((ILibChain_Link*)module)->MetaData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(r = sprintf_s(retStr + len, ILibMemory_Size(retStr) - len, " FD[%d] (R: %d, W: %d, E: %d) => %s\n", (int)slist[f], FD_ISSET(slist[f], inr), FD_ISSET(slist[f], inw), FD_ISSET(slist[f], ine), ((ILibChain_Link*)module)->QueryHandler != NULL ? ((ILibChain_Link*)module)->QueryHandler(chain, module, (int)slist[f], &tmp) : ((ILibChain_Link*)module)->MetaData));
|
||||||
|
if (r > 0) { len += r; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (f = 0; f < scount; ++f)
|
|
||||||
{
|
|
||||||
len += sprintf_s(retStr + len, ILibMemory_Size(retStr) - len, " FD[%d] (R: %d, W: %d, E: %d) => %s\n", (int)slist[f], FD_ISSET(slist[f], inr), FD_ISSET(slist[f], inw), FD_ISSET(slist[f], ine), ((ILibChain_Link*)module)->QueryHandler != NULL ? ((ILibChain_Link*)module)->QueryHandler(chain, module, (int)slist[f], &tmp) : ((ILibChain_Link*)module)->MetaData);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
for (f = 0; f < FD_SETSIZE; ++f)
|
for (f = 0; f < FD_SETSIZE; ++f)
|
||||||
{
|
|
||||||
if (FD_ISSET(f, &readset) || FD_ISSET(f, &writeset) || FD_ISSET(f, &errorset))
|
|
||||||
{
|
{
|
||||||
len += sprintf_s(retStr + len, ILibMemory_Size(retStr) - len, " FD[%d] (R: %d, W: %d, E: %d) => %s\n", f, FD_ISSET(f, inr), FD_ISSET(f, inw), FD_ISSET(f, ine), ((ILibChain_Link*)module)->QueryHandler != NULL ? ((ILibChain_Link*)module)->QueryHandler(chain, module, f, &tmp) : ((ILibChain_Link*)module)->MetaData);
|
if (FD_ISSET(f, &readset) || FD_ISSET(f, &writeset) || FD_ISSET(f, &errorset))
|
||||||
|
{
|
||||||
|
if (retStr == NULL)
|
||||||
|
{
|
||||||
|
buflen += snprintf(NULL, 0, " FD[%d] (R: %d, W: %d, E: %d) => %s\n", f, FD_ISSET(f, inr), FD_ISSET(f, inw), FD_ISSET(f, ine), ((ILibChain_Link*)module)->QueryHandler != NULL ? ((ILibChain_Link*)module)->QueryHandler(chain, module, f, &tmp) : ((ILibChain_Link*)module)->MetaData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r = sprintf_s(retStr + len, ILibMemory_Size(retStr) - len, " FD[%d] (R: %d, W: %d, E: %d) => %s\n", f, FD_ISSET(f, inr), FD_ISSET(f, inw), FD_ISSET(f, ine), ((ILibChain_Link*)module)->QueryHandler != NULL ? ((ILibChain_Link*)module)->QueryHandler(chain, module, f, &tmp) : ((ILibChain_Link*)module)->MetaData);
|
||||||
|
if (r > 0) { len += r; }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
node = ILibLinkedList_GetNextNode(node);
|
||||||
}
|
}
|
||||||
node = ILibLinkedList_GetNextNode(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
for (f = 0; f < FD_SETSIZE && f < bchain->lastDescriptorCount; ++f)
|
for (f = 0; f < FD_SETSIZE && f < bchain->lastDescriptorCount; ++f)
|
||||||
{
|
|
||||||
if (bchain->WaitHandles[f] != NULL && bchain->WaitHandles[ILibChain_HandleInfoIndex(f)] != NULL)
|
|
||||||
{
|
{
|
||||||
len += sprintf_s(retStr + len, ILibMemory_Size(retStr) - len, " H[%p] (Signaled: %d) => %s\n", bchain->WaitHandles[f], WaitForSingleObjectEx(bchain->WaitHandles[f], 0, FALSE) == 0, ((ILibChain_WaitHandleInfo*)bchain->WaitHandles[ILibChain_HandleInfoIndex(f)])->metaData);
|
if (bchain->WaitHandles[f] != NULL && bchain->WaitHandles[ILibChain_HandleInfoIndex(f)] != NULL)
|
||||||
|
{
|
||||||
|
if (retStr == NULL)
|
||||||
|
{
|
||||||
|
buflen += snprintf(NULL, 0, " H[%p] (Signaled: %d) => %s\n", bchain->WaitHandles[f], WaitForSingleObjectEx(bchain->WaitHandles[f], 0, FALSE) == 0, ((ILibChain_WaitHandleInfo*)bchain->WaitHandles[ILibChain_HandleInfoIndex(f)])->metaData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r = sprintf_s(retStr + len, ILibMemory_Size(retStr) - len, " H[%p] (Signaled: %d) => %s\n", bchain->WaitHandles[f], WaitForSingleObjectEx(bchain->WaitHandles[f], 0, FALSE) == 0, ((ILibChain_WaitHandleInfo*)bchain->WaitHandles[ILibChain_HandleInfoIndex(f)])->metaData);
|
||||||
|
if (r > 0) { len += r; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (retStr == NULL)
|
||||||
|
{
|
||||||
|
retStr = ILibMemory_SmartAllocate(buflen + 1024);
|
||||||
|
#ifdef WIN32
|
||||||
|
len += sprintf_s(retStr, ILibMemory_Size(retStr), " Chain Timeout: %u milliseconds\n", bchain->currentWaitTimeout);
|
||||||
|
#else
|
||||||
|
len += sprintf_s(retStr, ILibMemory_Size(retStr), " Chain Timeout: %u milliseconds\n", selectTimeout);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
retStr[len] = 0;
|
retStr[len] = 0;
|
||||||
return(retStr);
|
return(retStr);
|
||||||
@@ -3782,11 +3824,11 @@ ILibExportMethod void ILibStartChain(void *Chain)
|
|||||||
chain->PreSelectCount++;
|
chain->PreSelectCount++;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int x = 0;
|
int x = 0;
|
||||||
DWORD waitTimeout = 0;
|
chain->currentWaitTimeout = 0;
|
||||||
|
|
||||||
ILibChain_SetupWindowsWaitObject(chain->WaitHandles, &x, &tv, &waitTimeout, &readset, &writeset, &errorset, chain->auxSelectHandles, NULL);
|
ILibChain_SetupWindowsWaitObject(chain->WaitHandles, &x, &tv, &(chain->currentWaitTimeout), &readset, &writeset, &errorset, chain->auxSelectHandles, NULL);
|
||||||
chain->lastDescriptorCount = x;
|
chain->lastDescriptorCount = x;
|
||||||
slct = ILibChain_WindowsSelect(chain, &readset, &writeset, &errorset, chain->WaitHandles, x, waitTimeout);
|
slct = ILibChain_WindowsSelect(chain, &readset, &writeset, &errorset, chain->WaitHandles, x, chain->currentWaitTimeout);
|
||||||
#else
|
#else
|
||||||
if (chain->lastDescriptorCount < 0)
|
if (chain->lastDescriptorCount < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user