Browse Source

Fix parsing Buffer of judge task's extraData, close syzoj/syzoj#111

master
Menci 6 years ago
parent
commit
7cd5f5f085
  1. 7
      src/daemon/index.ts
  2. 5
      src/interfaces.ts

7
src/daemon/index.ts

@ -6,7 +6,7 @@ import util = require('util');
import rmq = require('./rmq'); import rmq = require('./rmq');
import remote = require('./remote'); import remote = require('./remote');
import { judge } from './judge'; import { judge } from './judge';
import { JudgeResult, ErrorType, ProgressReportType, OverallResult } from '../interfaces'; import { JudgeResult, ErrorType, ProgressReportType, OverallResult, SerializedBuffer } from '../interfaces';
(async function () { (async function () {
winston.info("Daemon starts."); winston.info("Daemon starts.");
@ -14,6 +14,11 @@ import { JudgeResult, ErrorType, ProgressReportType, OverallResult } from '../in
await rmq.connect(); await rmq.connect();
winston.info("Start consuming the queue."); winston.info("Start consuming the queue.");
await remote.waitForTask(async (task) => { 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; let result: OverallResult;
try { try {
await remote.reportProgress({ taskId: task.content.taskId, type: ProgressReportType.Started, progress: null }); await remote.reportProgress({ taskId: task.content.taskId, type: ProgressReportType.Started, progress: null });

5
src/interfaces.ts

@ -161,5 +161,10 @@ export interface RPCReply {
error?: string; error?: string;
} }
export interface SerializedBuffer {
type: string;
data: Uint8Array;
}
export const redisBinarySuffix = '-bin'; export const redisBinarySuffix = '-bin';
export const redisMetadataSuffix = '-meta'; export const redisMetadataSuffix = '-meta';

Loading…
Cancel
Save