From e005ea44421d7acef6a460449c854a861a5c7c30 Mon Sep 17 00:00:00 2001 From: Gabriel Cristian Alecu Date: Thu, 21 Aug 2014 10:41:23 +0300 Subject: [PATCH] Fixed WORK_FAIL needing 2 arguments According to http://gearman.org/protocol/ , WORK_FAIL only has 1 argument: the handle --- client/response.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/response.go b/client/response.go index bcafc53..ce8e509 100644 --- a/client/response.go +++ b/client/response.go @@ -76,7 +76,7 @@ func decodeResponse(data []byte) (resp *Response, l int, err error) { case dtJobCreated: resp.Handle = string(dt) case dtStatusRes, dtWorkData, dtWorkWarning, dtWorkStatus, - dtWorkComplete, dtWorkFail, dtWorkException: + dtWorkComplete, dtWorkException: s := bytes.SplitN(dt, []byte{'\x00'}, 2) if len(s) >= 2 { resp.Handle = string(s[0]) @@ -85,6 +85,14 @@ func decodeResponse(data []byte) (resp *Response, l int, err error) { err = fmt.Errorf("Invalid data: %v", data) return } + case dtWorkFail: + s := bytes.SplitN(dt, []byte{'\x00'}, 2) + if len(s) >= 1 { + resp.Handle = string(s[0]) + } else { + err = fmt.Errorf("Invalid data: %v", data) + return + } case dtEchoRes: fallthrough default: