Skip to content

Commit

Permalink
fix: respond to polling messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lynzrand committed May 29, 2021
1 parent 27c89c5 commit 9d3feb8
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions coordinator/Services/JudgerCoordinatorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,22 @@ async void OnJudgerStatusUpdateMessage(string clientId, ClientStatusMsg msg) {

async void OnJobRequestMessage(string clientId, JobRequestMsg msg) {
// should we dispatch a new job for this judger?
using (await connectionLock.LockAsync()) {
if (connections.TryGetValue(clientId, out var conn)) {
conn.CanAcceptNewTask = msg.ActiveTaskCount > 0;
conn.ActiveTaskCount = msg.ActiveTaskCount;
using var reqLock = await connectionLock.LockAsync();
if (connections.TryGetValue(clientId, out var conn)) {
conn.CanAcceptNewTask = msg.ActiveTaskCount > 0;
conn.ActiveTaskCount = msg.ActiveTaskCount;

var dispatchedCount = await TryDispatchJobFromDatabase(conn, msg.RequestForNewTask, msg.MessageId);
reqLock.Dispose();

if (dispatchedCount > 0)
logger.LogInformation("Sent {1} jobs to {0}", dispatchedCount, clientId);
var dispatchedCount = await TryDispatchJobFromDatabase(conn, msg.RequestForNewTask, msg.MessageId);

if (dispatchedCount > 0) {
logger.LogInformation("Sent {1} jobs to {0}", dispatchedCount, clientId);
} else {
logger.LogDebug("Sent no jobs to {0}", dispatchedCount, clientId);
}
}

}

public async void OnJobProgressMessage(string clientId, JobProgressMsg msg) {
Expand Down Expand Up @@ -376,7 +381,7 @@ static bool ShouldChangeStage(Job job) {
}

static bool ShouldAddResult(Job job) {
return job.Stage == JobStage.Running || job.Stage == JobStage.Finished;
return job.Stage != JobStage.Queued && job.Stage != JobStage.Skipped;
}

/// <summary>
Expand Down

0 comments on commit 9d3feb8

Please sign in to comment.