Skip to content

Commit

Permalink
conn, pool: reset errors when putting request/write back to pool, rem…
Browse files Browse the repository at this point in the history
…ove erroneous request release when peer closes connection
  • Loading branch information
lithdew committed Jun 12, 2020
1 parent 02975bf commit d9ef724
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ func (c *Conn) close(err error) {
pr.wg.Done()

delete(c.reqs, seq)
releasePendingRequest(pr)
}

c.seq = 0
Expand Down
8 changes: 6 additions & 2 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func acquirePendingWrite(buf *bytebufferpool.ByteBuffer, wait bool) *pendingWrit
return pw
}

func releasePendingWrite(pw *pendingWrite) { pendingWritePool.Put(pw) }
func releasePendingWrite(pw *pendingWrite) { pw.err = nil; pendingWritePool.Put(pw) }

type pendingRequest struct {
dst []byte // dst to copy response to
Expand All @@ -72,7 +72,11 @@ func acquirePendingRequest(dst []byte) *pendingRequest {
return pr
}

func releasePendingRequest(pr *pendingRequest) { pendingRequestPool.Put(pr) }
func releasePendingRequest(pr *pendingRequest) {
pr.dst = nil
pr.err = nil
pendingRequestPool.Put(pr)
}

var zeroTime time.Time

Expand Down

0 comments on commit d9ef724

Please sign in to comment.