mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-10 07:05:41 +12:00
maybe? fix rare crashing when players disconnect
This commit is contained in:
parent
e6b0282245
commit
bd16f0386a
1 changed files with 11 additions and 1 deletions
|
@ -36,8 +36,11 @@ namespace HISP.Server
|
||||||
private int warnInterval = GameServer.IdleWarning * 60 * 1000;
|
private int warnInterval = GameServer.IdleWarning * 60 * 1000;
|
||||||
private int kickInterval = GameServer.IdleTimeout * 60 * 1000;
|
private int kickInterval = GameServer.IdleTimeout * 60 * 1000;
|
||||||
|
|
||||||
|
private bool dcLock = false;
|
||||||
|
|
||||||
private void minuteTimerTick(object state)
|
private void minuteTimerTick(object state)
|
||||||
{
|
{
|
||||||
|
dcLock = true;
|
||||||
totalMinutesElapsed++;
|
totalMinutesElapsed++;
|
||||||
if (LoggedIn)
|
if (LoggedIn)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +49,12 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
LoggedinUser.FreeMinutes = 0;
|
LoggedinUser.FreeMinutes = 0;
|
||||||
if (!LoggedinUser.Subscribed && !LoggedinUser.Moderator && !LoggedinUser.Administrator)
|
if (!LoggedinUser.Subscribed && !LoggedinUser.Moderator && !LoggedinUser.Administrator)
|
||||||
|
{
|
||||||
|
dcLock = false;
|
||||||
Kick(Messages.KickReasonNoTime);
|
Kick(Messages.KickReasonNoTime);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsure of actural timings, would be more or less impossible to know
|
// unsure of actural timings, would be more or less impossible to know
|
||||||
|
@ -86,6 +94,7 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
minuteTimer.Change(oneMinute, oneMinute);
|
minuteTimer.Change(oneMinute, oneMinute);
|
||||||
|
dcLock = false;
|
||||||
}
|
}
|
||||||
private void keepAliveTimerTick(object state)
|
private void keepAliveTimerTick(object state)
|
||||||
{
|
{
|
||||||
|
@ -173,13 +182,14 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
catch(SocketException e)
|
catch(SocketException e)
|
||||||
{
|
{
|
||||||
Logger.ErrorPrint("Socket exception occured: " + e.Message);
|
|
||||||
Disconnect();
|
Disconnect();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(dcLock) { }; // Refuse to shut down until dcLock is cleared. (prevents TOCTOU issues.)
|
||||||
|
|
||||||
// Shutdown sockets
|
// Shutdown sockets
|
||||||
if(updateTimer != null)
|
if(updateTimer != null)
|
||||||
updateTimer.Dispose();
|
updateTimer.Dispose();
|
||||||
|
|
Loading…
Add table
Reference in a new issue