fix bug when recover memory

This commit is contained in:
hebo
2019-11-01 17:51:57 +08:00
parent c9bdcceba9
commit 2b42cd4b3a
4 changed files with 23 additions and 67 deletions

View File

@@ -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) {

View File

@@ -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{},