From 0042f992d80b59b97380bbbbeb271fd3030edd90 Mon Sep 17 00:00:00 2001 From: Deng Guangxing Date: Tue, 20 Jun 2017 11:56:25 +0800 Subject: [PATCH] fd leak and error handling Signed-off-by: Deng Guangxing --- daemon/logger/jsonfilelog/multireader/multireader.go | 8 ++++++-- layer/filestore.go | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/daemon/logger/jsonfilelog/multireader/multireader.go b/daemon/logger/jsonfilelog/multireader/multireader.go index 06a7307ce4..1993f1d76c 100644 --- a/daemon/logger/jsonfilelog/multireader/multireader.go +++ b/daemon/logger/jsonfilelog/multireader/multireader.go @@ -46,7 +46,9 @@ func (r *multiReadSeeker) Seek(offset int64, whence int) (int64, error) { rdrOffset := offset - tmpOffset idx := i - rdr.Seek(rdrOffset, os.SEEK_SET) + if _, err := rdr.Seek(rdrOffset, os.SEEK_SET); err != nil { + return -1, err + } // make sure all following readers are at 0 for _, rdr := range r.readers[i+1:] { rdr.Seek(0, os.SEEK_SET) @@ -67,7 +69,9 @@ func (r *multiReadSeeker) Seek(offset int64, whence int) (int64, error) { } tmpOffset += s } - r.Seek(tmpOffset+offset, os.SEEK_SET) + if _, err := r.Seek(tmpOffset+offset, os.SEEK_SET); err != nil { + return -1, err + } return tmpOffset + offset, nil case os.SEEK_CUR: if r.pos == nil { diff --git a/layer/filestore.go b/layer/filestore.go index 7ea418cd5a..533f45481a 100644 --- a/layer/filestore.go +++ b/layer/filestore.go @@ -226,6 +226,7 @@ func (fms *fileMetadataStore) TarSplitReader(layer ChainID) (io.ReadCloser, erro } f, err := gzip.NewReader(fz) if err != nil { + fz.Close() return nil, err }