Skip to content

Commit

Permalink
Ping: Fixed timing issue with FinishAction
Browse files Browse the repository at this point in the history
  • Loading branch information
brianferguson committed Aug 6, 2023
1 parent f4d3757 commit cadf1b4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Plugins/PluginPing/Ping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ PLUGIN_EXPORT double Update(void* data)
{
MeasureData* measure = (MeasureData*)data;

double value = 0.0;

EnterCriticalSection(&g_CriticalSection);
if (!measure->threadActive)
{
Expand All @@ -184,7 +186,7 @@ PLUGIN_EXPORT double Update(void* data)
}
}

double value = measure->value;
value = measure->value;
LeaveCriticalSection(&g_CriticalSection);

return value;
Expand Down Expand Up @@ -221,6 +223,8 @@ DWORD WINAPI NetworkThreadProc(void* pParam)
MeasureData* measure = (MeasureData*)pParam;
double value = measure->timeoutValue;

bool doFinishAction = false;

if (measure->destAddrInfo)
{
bool useIPv6 = false;
Expand Down Expand Up @@ -293,10 +297,7 @@ DWORD WINAPI NetworkThreadProc(void* pParam)
}
IcmpCloseHandle(hIcmpFile);

if (!measure->finishAction.empty())
{
RmExecute(measure->skin, measure->finishAction.c_str());
}
doFinishAction = true;
}

delete [] buffer;
Expand Down Expand Up @@ -330,6 +331,11 @@ DWORD WINAPI NetworkThreadProc(void* pParam)
// the last instance.
FreeLibraryAndExitThread(module, 0UL);
}
else if (doFinishAction && !measure->finishAction.empty())
{
// Perform the FinishAction
RmExecute(measure->skin, measure->finishAction.c_str());
}

return 0;
}
Expand Down

0 comments on commit cadf1b4

Please sign in to comment.