core: 评测机离线后停止未完成的任务分配

fixes #60
This commit is contained in:
undefined committed 2021-03-24 22:12:21 +08:00
1 parent 8018a79418
commit 2ac6cb3745
4 files changed
+8 -2

No files matched your search

+5
View File
@@ -112,8 +112,10 @@ export class JudgeFilesDownloadHandler extends Handler {
class JudgeConnectionHandler extends ConnectionHandler {
processing: any = null;
closed = false;
async prepare() {
logger.info('Judge daemon connected from ', this.request.ip);
this.newTask();
}
@@ -123,6 +125,7 @@ class JudgeConnectionHandler extends ConnectionHandler {
while (!t) {
// eslint-disable-next-line no-await-in-loop
await sleep(100);
if (this.closed) return;
// eslint-disable-next-line no-await-in-loop
t = await task.getFirst({ type: 'judge' });
}
@@ -146,10 +149,12 @@ class JudgeConnectionHandler extends ConnectionHandler {
}
async cleanup() {
logger.info('Judge daemon disconnected from ', this.request.ip);
if (this.processing) {
await record.reset(this.processing.domainId, this.processing.rid, false);
await task.add(this.processing);
}
this.closed = true;
}
}