Skip to content

Commit

Permalink
AuthManager: added retry mechanism for delayed save.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShreyasZare committed Jun 1, 2024
1 parent 1522eab commit 4aaee38
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions DnsServerCore/Auth/AuthManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,20 @@ public AuthManager(string configFolder, LogManager log)
{
lock (_saveLock)
{
try
{
SaveConfigFileInternal();
}
catch (Exception ex)
if (_pendingSave)
{
_log.Write(ex);
}
finally
{
_pendingSave = false;
try
{
SaveConfigFileInternal();
_pendingSave = false;
}
catch (Exception ex)
{
_log.Write(ex);

//set timer to retry again
_saveTimer.Change(SAVE_TIMER_INITIAL_INTERVAL, Timeout.Infinite);
}
}
}
});
Expand All @@ -93,10 +96,11 @@ public void Dispose()
if (_disposed)
return;

_saveTimer?.Dispose();

lock (_saveLock)
{
_saveTimer?.Dispose();

//always save config here
try
{
SaveConfigFileInternal();
Expand Down

0 comments on commit 4aaee38

Please sign in to comment.