Skip to content

Commit e88d02a

Browse files
committed
Cleanup writeRequests in connection
1 parent 48818d8 commit e88d02a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pulsar/internal/connection.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,18 @@ func (c *connection) failLeftRequestsWhenClose() {
396396
}
397397
}
398398

399+
func (c *connection) drainWriteRequests() {
400+
for {
401+
select {
402+
case req := <-c.writeRequestsCh:
403+
c.bufferPool.Put(req.data)
404+
405+
default:
406+
return
407+
}
408+
}
409+
}
410+
399411
func (c *connection) run() {
400412
pingSendTicker := time.NewTicker(c.keepAliveInterval)
401413
pingCheckTicker := time.NewTicker(c.keepAliveInterval)
@@ -423,6 +435,7 @@ func (c *connection) run() {
423435
select {
424436
case <-c.closeCh:
425437
c.failLeftRequestsWhenClose()
438+
c.drainWriteRequests()
426439
return
427440
case req := <-c.incomingRequestsCh:
428441
if req == nil {

0 commit comments

Comments
 (0)