Skip to content

Commit 33153a2

Browse files
committed
Applies mutex in codex CidChecker
1 parent ac8f01c commit 33153a2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Tools/BiblioTech/CodexCidChecker.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class CodexCidChecker
1010
private static readonly string nl = Environment.NewLine;
1111
private readonly Configuration config;
1212
private readonly ILog log;
13+
private readonly Mutex checkMutex = new Mutex();
1314
private CodexApi? currentCodexNode;
1415

1516
public CodexCidChecker(Configuration config, ILog log)
@@ -27,6 +28,7 @@ public async Task<CheckResponse> PerformCheck(string cid)
2728

2829
try
2930
{
31+
checkMutex.WaitOne();
3032
var codex = GetCodex();
3133
var nodeCheck = await CheckCodex(codex);
3234
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 @@ public async Task<CheckResponse> PerformCheck(string cid)
3739
{
3840
return new CheckResponse(false, "Internal server error", ex.ToString());
3941
}
42+
finally
43+
{
44+
checkMutex.ReleaseMutex();
45+
}
4046
}
4147

4248
private async Task<CheckResponse> PerformCheck(CodexApi codex, string cid)

0 commit comments

Comments
 (0)