From 99c803238419cf5d0bf62b7f2df9edaa81069a89 Mon Sep 17 00:00:00 2001 From: JessonChan Date: Wed, 20 Apr 2016 12:54:21 +0800 Subject: [PATCH] fix a bug when high qps --- worker/agent.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/worker/agent.go b/worker/agent.go index 659960a..3367ad3 100644 --- a/worker/agent.go +++ b/worker/agent.go @@ -90,16 +90,22 @@ func (a *agent) work() { leftdata = data continue } - if inpack, l, err = decodeInPack(data); err != nil { - a.worker.err(err) - leftdata = data - continue - } - leftdata = nil - inpack.a = a - a.worker.in <- inpack - if len(data) > l { - leftdata = data[l:] + for { + if inpack, l, err = decodeInPack(data); err != nil { + a.worker.err(err) + leftdata = data + break + } else { + leftdata = nil + inpack.a = a + a.worker.in <- inpack + if len(data) == l { + break + } + if len(data) > l { + data = data[l:] + } + } } } }