use GetGracefulShutdownRemainingTime instead direct access to g_GracefulShutdownEndtime

This commit is contained in:
orignal 2025-09-22 13:52:39 -04:00
parent 40c96dcf69
commit c16c6976fa
3 changed files with 20 additions and 12 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2024, The PurpleI2P Project
* Copyright (c) 2013-2025, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@ -44,7 +44,7 @@ namespace i2p
{
namespace win32
{
DWORD g_GracefulShutdownEndtime = 0;
static DWORD g_GracefulShutdownEndtime = 0;
bool g_isWinService;
static void ShowPopupMenu (HWND hWnd, POINT *curpos, int wDefaultItem)
@ -195,10 +195,10 @@ namespace win32
s << "; ";
s << "Success Rate: " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate() << "%\n";
s << "Uptime: "; ShowUptime(s, i2p::context.GetUptime ());
if (g_GracefulShutdownEndtime != 0)
auto gracefulTimeLeft = GetGracefulShutdownRemainingTime ();
if (gracefulTimeLeft > 0)
{
DWORD GracefulTimeLeft = (g_GracefulShutdownEndtime - GetTickCount()) / 1000;
s << "Graceful shutdown, time left: "; ShowUptime(s, GracefulTimeLeft);
s << "Graceful shutdown, time left: "; ShowUptime(s, gracefulTimeLeft);
}
else
s << "\n";
@ -498,5 +498,13 @@ namespace win32
PostMessage (hWnd, WM_COMMAND, MAKEWPARAM(ID_STOP_GRACEFUL_SHUTDOWN, 0), 0);
return hWnd;
}
int GetGracefulShutdownRemainingTime ()
{
if (!g_GracefulShutdownEndtime) return 0;
auto remains = (g_GracefulShutdownEndtime - GetTickCount()) / 1000;
if (remains < 0) remains = 0;
return remains;
}
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2020, The PurpleI2P Project
* Copyright (c) 2013-2025, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@ -15,13 +15,12 @@ namespace i2p
{
namespace win32
{
extern DWORD g_GracefulShutdownEndtime;
bool StartWin32App (bool isWinService);
void StopWin32App ();
int RunWin32App ();
bool GracefulShutdown ();
bool StopGracefulShutdown ();
int GetGracefulShutdownRemainingTime ();
}
}
#endif // WIN32APP_H__

View file

@ -307,8 +307,9 @@ namespace http {
s << "<br>\r\n";
}
#elif defined(WIN32_APP)
if (i2p::win32::g_GracefulShutdownEndtime != 0) {
uint16_t remains = (i2p::win32::g_GracefulShutdownEndtime - GetTickCount()) / 1000;
auto remains = i2p::win32::GetGracefulShutdownRemainingTime ();
if (remains > 0)
{
s << "<b>" << tr("Stopping in") << ":</b> ";
ShowUptime(s, remains);
s << "<br>\r\n";