From 7cd5f5f085e91fdb2efe66f55c182d6d51a27393 Mon Sep 17 00:00:00 2001 From: Menci Date: Mon, 1 Apr 2019 13:18:52 +0800 Subject: [PATCH] Fix parsing Buffer of judge task's extraData, close syzoj/syzoj#111 --- src/daemon/index.ts | 7 ++++++- src/interfaces.ts | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/daemon/index.ts b/src/daemon/index.ts index 643fd62..f34fb94 100644 --- a/src/daemon/index.ts +++ b/src/daemon/index.ts @@ -6,7 +6,7 @@ import util = require('util'); import rmq = require('./rmq'); import remote = require('./remote'); import { judge } from './judge'; -import { JudgeResult, ErrorType, ProgressReportType, OverallResult } from '../interfaces'; +import { JudgeResult, ErrorType, ProgressReportType, OverallResult, SerializedBuffer } from '../interfaces'; (async function () { winston.info("Daemon starts."); @@ -14,6 +14,11 @@ import { JudgeResult, ErrorType, ProgressReportType, OverallResult } from '../in await rmq.connect(); winston.info("Start consuming the queue."); await remote.waitForTask(async (task) => { + if (task.extraData) { + const extraData: SerializedBuffer = task.extraData as any as SerializedBuffer; + if (extraData.type === "Buffer") task.extraData = new Buffer(extraData.data); + } + let result: OverallResult; try { await remote.reportProgress({ taskId: task.content.taskId, type: ProgressReportType.Started, progress: null }); diff --git a/src/interfaces.ts b/src/interfaces.ts index c8c3fc8..d29217b 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -161,5 +161,10 @@ export interface RPCReply { error?: string; } +export interface SerializedBuffer { + type: string; + data: Uint8Array; +} + export const redisBinarySuffix = '-bin'; export const redisMetadataSuffix = '-meta';