mirror of https://github.com/OpenVPN/openvpn-gui
Bugfix AutoCloseHandler(): accommodate wraparound of 32 bit time
- GetTickcount() and current-time passed-in to the callback are both 32 bit which wraps around every ~50 days. In the stop condition compare the elasped ticks and timeout value instead of end-time and now. The latter can wraparound in a long-running process. Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/589/head
parent
e4089c2141
commit
6c6bf9e4e6
|
@ -453,15 +453,15 @@ AutoCloseHandler(HWND hwnd, UINT UNUSED msg, UINT_PTR id, DWORD now)
|
||||||
if (!ac)
|
if (!ac)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UINT end = ac->start + ac->timeout;
|
DWORD elapsed = now - ac->start;
|
||||||
if (now >= end)
|
if (elapsed >= ac->timeout)
|
||||||
{
|
{
|
||||||
SimulateButtonPress(hwnd, ac->btn);
|
SimulateButtonPress(hwnd, ac->btn);
|
||||||
AutoCloseCancel(hwnd);
|
AutoCloseCancel(hwnd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetDlgItemText(hwnd, ac->txtid, LoadLocalizedString(ac->txtres, (end - now)/1000));
|
SetDlgItemText(hwnd, ac->txtid, LoadLocalizedString(ac->txtres, (ac->timeout - elapsed)/1000));
|
||||||
SetTimer(hwnd, id, 500, AutoCloseHandler);
|
SetTimer(hwnd, id, 500, AutoCloseHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue