mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-08-31 10:58:28 +00:00
Merge pull request #1469 from PepperDash/hotfix/ssh-stopprog-timing
fix(core-ssh): stop reconnect loop during stopprog
This commit is contained in:
commit
7f05654638
1 changed files with 23 additions and 11 deletions
|
|
@ -151,6 +151,8 @@ namespace PepperDash.Core
|
|||
// Thread-safety lock for state changes
|
||||
private readonly object _stateLock = new object();
|
||||
|
||||
private volatile bool _isProgramStopping;
|
||||
|
||||
private bool disconnectLogged = false;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -207,13 +209,11 @@ namespace PepperDash.Core
|
|||
{
|
||||
if (programEventType == eProgramStatusEventType.Stopping)
|
||||
{
|
||||
if (client != null)
|
||||
{
|
||||
_isProgramStopping = true;
|
||||
this.LogDebug("Program stopping. Closing connection");
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connect method
|
||||
|
|
@ -228,6 +228,12 @@ namespace PepperDash.Core
|
|||
return;
|
||||
}
|
||||
|
||||
if (_isProgramStopping)
|
||||
{
|
||||
this.LogDebug("Skipping connect because program is stopping");
|
||||
return;
|
||||
}
|
||||
|
||||
ConnectEnabled = true;
|
||||
|
||||
try
|
||||
|
|
@ -308,7 +314,7 @@ namespace PepperDash.Core
|
|||
|
||||
disconnectLogged = true;
|
||||
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
|
||||
if (AutoReconnect)
|
||||
if (AutoReconnect && ConnectEnabled && !_isProgramStopping)
|
||||
{
|
||||
this.LogDebug("Checking autoreconnect: {autoReconnect}, {autoReconnectInterval}ms", AutoReconnect, AutoReconnectIntervalMs);
|
||||
StartReconnectTimer();
|
||||
|
|
@ -320,7 +326,7 @@ namespace PepperDash.Core
|
|||
|
||||
disconnectLogged = true;
|
||||
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
|
||||
if (AutoReconnect)
|
||||
if (AutoReconnect && ConnectEnabled && !_isProgramStopping)
|
||||
{
|
||||
this.LogDebug("Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
|
||||
StartReconnectTimer();
|
||||
|
|
@ -332,7 +338,7 @@ namespace PepperDash.Core
|
|||
this.LogVerbose(e, "Exception details: ");
|
||||
disconnectLogged = true;
|
||||
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
|
||||
if (AutoReconnect)
|
||||
if (AutoReconnect && ConnectEnabled && !_isProgramStopping)
|
||||
{
|
||||
this.LogDebug("Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
|
||||
StartReconnectTimer();
|
||||
|
|
@ -467,7 +473,7 @@ namespace PepperDash.Core
|
|||
{
|
||||
connectLock.Release();
|
||||
}
|
||||
if (AutoReconnect && ConnectEnabled)
|
||||
if (AutoReconnect && ConnectEnabled && !_isProgramStopping)
|
||||
{
|
||||
this.LogDebug("Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
|
||||
StartReconnectTimer();
|
||||
|
|
@ -510,8 +516,11 @@ namespace PepperDash.Core
|
|||
this.LogError("ObjectDisposedException sending '{message}'. Restarting connection...", text.Trim());
|
||||
|
||||
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
|
||||
if (AutoReconnect && ConnectEnabled && !_isProgramStopping)
|
||||
{
|
||||
StartReconnectTimer();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.LogException(ex, "Exception sending text: '{message}'", text);
|
||||
|
|
@ -543,8 +552,11 @@ namespace PepperDash.Core
|
|||
this.LogException(ex, "ObjectDisposedException sending {message}", ComTextHelper.GetEscapedText(bytes));
|
||||
|
||||
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
|
||||
if (AutoReconnect && ConnectEnabled && !_isProgramStopping)
|
||||
{
|
||||
StartReconnectTimer();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.LogException(ex, "Exception sending {message}", ComTextHelper.GetEscapedText(bytes));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue