diff --git a/Win32/Win32App.cpp b/Win32/Win32App.cpp
index 0e29c517..2afc1651 100644
--- a/Win32/Win32App.cpp
+++ b/Win32/Win32App.cpp
@@ -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,11 +195,11 @@ namespace win32
s << "; ";
s << "Success Rate: " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate() << "%\n";
s << "Uptime: "; ShowUptime(s, i2p::context.GetUptime ());
- if (g_GracefulShutdownEndtime != 0)
- {
- DWORD GracefulTimeLeft = (g_GracefulShutdownEndtime - GetTickCount()) / 1000;
- s << "Graceful shutdown, time left: "; ShowUptime(s, GracefulTimeLeft);
- }
+ auto gracefulTimeLeft = GetGracefulShutdownRemainingTime ();
+ if (gracefulTimeLeft > 0)
+ {
+ s << "Graceful shutdown, time left: "; ShowUptime(s, gracefulTimeLeft);
+ }
else
s << "\n";
s << "Inbound: " << i2p::transport::transports.GetInBandwidth() / 1024 << " KiB/s; ";
@@ -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;
+ }
}
}
diff --git a/Win32/Win32App.h b/Win32/Win32App.h
index 614de738..668a444d 100644
--- a/Win32/Win32App.h
+++ b/Win32/Win32App.h
@@ -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__
diff --git a/daemon/HTTPServer.cpp b/daemon/HTTPServer.cpp
index bb2f44db..46041457 100644
--- a/daemon/HTTPServer.cpp
+++ b/daemon/HTTPServer.cpp
@@ -307,8 +307,9 @@ namespace http {
s << "
\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 << "" << tr("Stopping in") << ": ";
ShowUptime(s, remains);
s << "
\r\n";