From 0b8a78427fc14fa69437a11a9b8bb5aa87923fe8 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 9 Jun 2016 22:08:39 +0200 Subject: [PATCH] Prevent race of contidion from panic Due to race of condition nextCh can be already null when we try to close it Resolves https://github.com/ipfs/go-ipfs/issues/2732 --- .gx/lastpubver | 2 +- package.json | 4 ++-- writer.go | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gx/lastpubver b/.gx/lastpubver index 185a5796d1d3..a89acbad96e8 100644 --- a/.gx/lastpubver +++ b/.gx/lastpubver @@ -1 +1 @@ -1.1.0: QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8 +1.1.1: QmYtB7Qge8cJpXc4irsEp8zRqfnZMBeB7aTrMEkPk67DRv diff --git a/package.json b/package.json index 3ec276834987..0db3fedb6dcc 100644 --- a/package.json +++ b/package.json @@ -23,5 +23,5 @@ "language": "go", "license": "", "name": "go-log", - "version": "1.1.0" -} \ No newline at end of file + "version": "1.1.1" +} diff --git a/writer.go b/writer.go index 50cdf76ad8fe..06a1856da559 100644 --- a/writer.go +++ b/writer.go @@ -230,7 +230,9 @@ func (bw *bufWriter) loop() { if bufsize > MaxWriterBuffer { // if we have too many messages buffered, kill the writer bw.die() - close(nextCh) + if nextCh != nil { + close(nextCh) + } nextCh = nil // explicity keep going here to drain incoming }