mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-10-17 09:10:21 +01:00
use GetGracefulShutdownRemainingTime instead direct access to g_GracefulShutdownEndtime
This commit is contained in:
parent
40c96dcf69
commit
c16c6976fa
3 changed files with 20 additions and 12 deletions
|
@ -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
|
* This file is part of Purple i2pd project and licensed under BSD3
|
||||||
*
|
*
|
||||||
|
@ -44,7 +44,7 @@ namespace i2p
|
||||||
{
|
{
|
||||||
namespace win32
|
namespace win32
|
||||||
{
|
{
|
||||||
DWORD g_GracefulShutdownEndtime = 0;
|
static DWORD g_GracefulShutdownEndtime = 0;
|
||||||
bool g_isWinService;
|
bool g_isWinService;
|
||||||
|
|
||||||
static void ShowPopupMenu (HWND hWnd, POINT *curpos, int wDefaultItem)
|
static void ShowPopupMenu (HWND hWnd, POINT *curpos, int wDefaultItem)
|
||||||
|
@ -195,11 +195,11 @@ namespace win32
|
||||||
s << "; ";
|
s << "; ";
|
||||||
s << "Success Rate: " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate() << "%\n";
|
s << "Success Rate: " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate() << "%\n";
|
||||||
s << "Uptime: "; ShowUptime(s, i2p::context.GetUptime ());
|
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
|
else
|
||||||
s << "\n";
|
s << "\n";
|
||||||
s << "Inbound: " << i2p::transport::transports.GetInBandwidth() / 1024 << " KiB/s; ";
|
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);
|
PostMessage (hWnd, WM_COMMAND, MAKEWPARAM(ID_STOP_GRACEFUL_SHUTDOWN, 0), 0);
|
||||||
return hWnd;
|
return hWnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetGracefulShutdownRemainingTime ()
|
||||||
|
{
|
||||||
|
if (!g_GracefulShutdownEndtime) return 0;
|
||||||
|
auto remains = (g_GracefulShutdownEndtime - GetTickCount()) / 1000;
|
||||||
|
if (remains < 0) remains = 0;
|
||||||
|
return remains;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* This file is part of Purple i2pd project and licensed under BSD3
|
||||||
*
|
*
|
||||||
|
@ -15,13 +15,12 @@ namespace i2p
|
||||||
{
|
{
|
||||||
namespace win32
|
namespace win32
|
||||||
{
|
{
|
||||||
extern DWORD g_GracefulShutdownEndtime;
|
|
||||||
|
|
||||||
bool StartWin32App (bool isWinService);
|
bool StartWin32App (bool isWinService);
|
||||||
void StopWin32App ();
|
void StopWin32App ();
|
||||||
int RunWin32App ();
|
int RunWin32App ();
|
||||||
bool GracefulShutdown ();
|
bool GracefulShutdown ();
|
||||||
bool StopGracefulShutdown ();
|
bool StopGracefulShutdown ();
|
||||||
|
int GetGracefulShutdownRemainingTime ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // WIN32APP_H__
|
#endif // WIN32APP_H__
|
||||||
|
|
|
@ -307,8 +307,9 @@ namespace http {
|
||||||
s << "<br>\r\n";
|
s << "<br>\r\n";
|
||||||
}
|
}
|
||||||
#elif defined(WIN32_APP)
|
#elif defined(WIN32_APP)
|
||||||
if (i2p::win32::g_GracefulShutdownEndtime != 0) {
|
auto remains = i2p::win32::GetGracefulShutdownRemainingTime ();
|
||||||
uint16_t remains = (i2p::win32::g_GracefulShutdownEndtime - GetTickCount()) / 1000;
|
if (remains > 0)
|
||||||
|
{
|
||||||
s << "<b>" << tr("Stopping in") << ":</b> ";
|
s << "<b>" << tr("Stopping in") << ":</b> ";
|
||||||
ShowUptime(s, remains);
|
ShowUptime(s, remains);
|
||||||
s << "<br>\r\n";
|
s << "<br>\r\n";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue