Applies mutex in codex CidChecker
This commit is contained in:
parent
ac8f01c922
commit
33153a2b76
|
@ -10,6 +10,7 @@ namespace BiblioTech
|
||||||
private static readonly string nl = Environment.NewLine;
|
private static readonly string nl = Environment.NewLine;
|
||||||
private readonly Configuration config;
|
private readonly Configuration config;
|
||||||
private readonly ILog log;
|
private readonly ILog log;
|
||||||
|
private readonly Mutex checkMutex = new Mutex();
|
||||||
private CodexApi? currentCodexNode;
|
private CodexApi? currentCodexNode;
|
||||||
|
|
||||||
public CodexCidChecker(Configuration config, ILog log)
|
public CodexCidChecker(Configuration config, ILog log)
|
||||||
|
@ -27,6 +28,7 @@ namespace BiblioTech
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
checkMutex.WaitOne();
|
||||||
var codex = GetCodex();
|
var codex = GetCodex();
|
||||||
var nodeCheck = await CheckCodex(codex);
|
var nodeCheck = await CheckCodex(codex);
|
||||||
if (!nodeCheck) return new CheckResponse(false, "Codex node is not available. Cannot perform check.", $"Codex node at '{config.CodexEndpoint}' did not respond correctly to debug/info.");
|
if (!nodeCheck) return new CheckResponse(false, "Codex node is not available. Cannot perform check.", $"Codex node at '{config.CodexEndpoint}' did not respond correctly to debug/info.");
|
||||||
|
@ -37,6 +39,10 @@ namespace BiblioTech
|
||||||
{
|
{
|
||||||
return new CheckResponse(false, "Internal server error", ex.ToString());
|
return new CheckResponse(false, "Internal server error", ex.ToString());
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
checkMutex.ReleaseMutex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<CheckResponse> PerformCheck(CodexApi codex, string cid)
|
private async Task<CheckResponse> PerformCheck(CodexApi codex, string cid)
|
||||||
|
|
Loading…
Reference in New Issue