Browse Source

check the size of byte array, greater or lesser

tags/0.2
mikespook 11 years ago
parent
commit
fee531f9c1
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      worker/agent.go

+ 4
- 2
worker/agent.go View File

@@ -139,12 +139,14 @@ func (a *agent) read() (data []byte, err error) {
l := int(common.BytesToUint32([4]byte{data[start+8],
data[start+9], data[start+10], data[start+11]}))
total := l + 12
if total == tl {
if total == tl { // data is what we want
return
} else {
} else if total < tl{ // data[:total] is what we want, data[total:] is the more
a.in <- data[total:]
data = data[:total]
return
} else { // ops!
break
}
} else {
start++


Loading…
Cancel
Save