From 0efdb40d5723661af7fc5d7e153f096de410a6aa Mon Sep 17 00:00:00 2001 From: MoZhonghua Date: Fri, 24 Jun 2016 10:54:53 +0800 Subject: [PATCH] Fix truncated data --- reader.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/reader.go b/reader.go index e0a6d60..a649f6a 100644 --- a/reader.go +++ b/reader.go @@ -107,6 +107,13 @@ func (this *Reader) Read(p []byte) (n int, err error) { if err != syscall.E2BIG || bytesWritten == 0 { // track anything else this.err = err + } else { + // Should not return this.err + // If we got EOF from source in last fillBuffer() call, and + // there is still more data to process in buffer, in this + // case, if we return this.err(=EOF), then data in buffer + // will be lost. + return n, nil } }