mirror of
https://github.com/zr-hebo/sniffer-agent.git
synced 2025-08-11 19:58:42 +08:00
fix bug when recover memory
This commit is contained in:
@@ -30,7 +30,12 @@ func (sbp *sliceBufferPool) Enqueue(buffer []byte) {
|
||||
return
|
||||
}
|
||||
|
||||
sbp.queue <- buffer
|
||||
select {
|
||||
case sbp.queue <- buffer:
|
||||
return
|
||||
default:
|
||||
buffer = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (sbp *sliceBufferPool) DequeueWithInit(initSize int) (buffer []byte) {
|
||||
|
@@ -19,7 +19,13 @@ func (mqpp *mysqlQueryPiecePool) Enqueue(pmqp *PooledMysqlQueryPiece) {
|
||||
mqpp.lock.Lock()
|
||||
defer mqpp.lock.Unlock()
|
||||
|
||||
mqpp.queue <- pmqp
|
||||
select {
|
||||
case mqpp.queue <- pmqp:
|
||||
return
|
||||
default:
|
||||
pmqp = nil
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (mqpp *mysqlQueryPiecePool) Dequeue() (pmqp *PooledMysqlQueryPiece) {
|
||||
@@ -29,6 +35,7 @@ func (mqpp *mysqlQueryPiecePool) Dequeue() (pmqp *PooledMysqlQueryPiece) {
|
||||
select {
|
||||
case pmqp = <- mqpp.queue:
|
||||
return
|
||||
|
||||
default:
|
||||
pmqp = &PooledMysqlQueryPiece{
|
||||
MysqlQueryPiece: MysqlQueryPiece{},
|
||||
|
Reference in New Issue
Block a user