summaryrefslogtreecommitdiff
path: root/error_buffer.go
diff options
context:
space:
mode:
Diffstat (limited to 'error_buffer.go')
-rw-r--r--error_buffer.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/error_buffer.go b/error_buffer.go
index fec789a9..0eaf03b6 100644
--- a/error_buffer.go
+++ b/error_buffer.go
@@ -73,9 +73,8 @@ func newErrBuffer() *errBuffer {
// Listen attaches error stream even listener.
func (eb *errBuffer) Listen(l func(event int, ctx interface{})) {
eb.mu.Lock()
- defer eb.mu.Unlock()
-
eb.lsn = l
+ eb.mu.Unlock()
}
// Len returns the number of buf of the unread portion of the errBuffer;
@@ -88,14 +87,13 @@ func (eb *errBuffer) Len() int {
return len(eb.buf)
}
-// Write appends the contents of p to the errBuffer, growing the errBuffer as
-// needed. The return value n is the length of p; err is always nil.
+// Write appends the contents of pool to the errBuffer, growing the errBuffer as
+// needed. The return value n is the length of pool; err is always nil.
func (eb *errBuffer) Write(p []byte) (int, error) {
eb.mu.Lock()
- defer eb.mu.Unlock()
-
eb.buf = append(eb.buf, p...)
eb.update <- nil
+ eb.mu.Unlock()
return len(p), nil
}