WORK_FAIL fixed
--HG-- branch : dev
This commit is contained in:
parent
f74dc20e7e
commit
8c67ce0830
@ -45,10 +45,15 @@ func decodeJob(data []byte) (job *Job, err error) {
|
|||||||
|
|
||||||
// Encode a job to byte slice
|
// Encode a job to byte slice
|
||||||
func (job *Job) Encode() (data []byte) {
|
func (job *Job) Encode() (data []byte) {
|
||||||
l := len(job.Data)
|
var l int
|
||||||
|
if job.DataType == common.WORK_FAIL {
|
||||||
|
l = len(job.Handle)
|
||||||
|
} else {
|
||||||
|
l = len(job.Data)
|
||||||
if job.Handle != "" {
|
if job.Handle != "" {
|
||||||
l += len(job.Handle) + 1
|
l += len(job.Handle) + 1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
data = make([]byte, 0, l + 12)
|
data = make([]byte, 0, l + 12)
|
||||||
|
|
||||||
magiccode := common.Uint32ToBytes(job.magicCode)
|
magiccode := common.Uint32ToBytes(job.magicCode)
|
||||||
@ -60,8 +65,10 @@ func (job *Job) Encode() (data []byte) {
|
|||||||
data = append(data, datalength[:]...)
|
data = append(data, datalength[:]...)
|
||||||
if job.Handle != "" {
|
if job.Handle != "" {
|
||||||
data = append(data, []byte(job.Handle)...)
|
data = append(data, []byte(job.Handle)...)
|
||||||
|
if job.DataType != common.WORK_FAIL {
|
||||||
data = append(data, 0)
|
data = append(data, 0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
data = append(data, job.Data...)
|
data = append(data, job.Data...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user