From 4351815a4ad0f7ef499b05a6d9ad83da0f70e26d Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Sun, 12 Apr 2020 11:35:24 +0100 Subject: [PATCH] fix stale code --- internal/multiplex/datagramBuffer.go | 3 +-- internal/multiplex/datagramBuffer_test.go | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/multiplex/datagramBuffer.go b/internal/multiplex/datagramBuffer.go index d7664e0..3b8d784 100644 --- a/internal/multiplex/datagramBuffer.go +++ b/internal/multiplex/datagramBuffer.go @@ -6,7 +6,6 @@ import ( "bytes" "io" "sync" - "sync/atomic" "time" ) @@ -35,7 +34,7 @@ func (d *datagramBuffer) Read(target []byte) (int, error) { d.buf = new(bytes.Buffer) } for { - if atomic.LoadUint32(&d.closed) == 1 && len(d.pLens) == 0 { + if d.closed && len(d.pLens) == 0 { return 0, io.EOF } diff --git a/internal/multiplex/datagramBuffer_test.go b/internal/multiplex/datagramBuffer_test.go index add8e86..91d8b33 100644 --- a/internal/multiplex/datagramBuffer_test.go +++ b/internal/multiplex/datagramBuffer_test.go @@ -2,7 +2,6 @@ package multiplex import ( "bytes" - "sync/atomic" "testing" "time" ) @@ -67,7 +66,7 @@ func TestDatagramBuffer_RW(t *testing.T) { ) return } - if atomic.LoadUint32(&pipe.closed) != 1 { + if !pipe.closed { t.Error("expecting closed pipe, not closed") } })