From 8c67ce08306fee9c0ffb0bd701be51a7f57b20cb Mon Sep 17 00:00:00 2001 From: mikespook Date: Tue, 25 Sep 2012 14:39:50 +0800 Subject: [PATCH] WORK_FAIL fixed --HG-- branch : dev --- worker/job.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/worker/job.go b/worker/job.go index 278216a..ccbb48c 100644 --- a/worker/job.go +++ b/worker/job.go @@ -45,9 +45,14 @@ func decodeJob(data []byte) (job *Job, err error) { // Encode a job to byte slice func (job *Job) Encode() (data []byte) { - l := len(job.Data) - if job.Handle != "" { - l += len(job.Handle) + 1 + var l int + if job.DataType == common.WORK_FAIL { + l = len(job.Handle) + } else { + l = len(job.Data) + if job.Handle != "" { + l += len(job.Handle) + 1 + } } data = make([]byte, 0, l + 12) @@ -60,7 +65,9 @@ func (job *Job) Encode() (data []byte) { data = append(data, datalength[:]...) if job.Handle != "" { data = append(data, []byte(job.Handle)...) - data = append(data, 0) + if job.DataType != common.WORK_FAIL { + data = append(data, 0) + } } data = append(data, job.Data...) return