remove buffer pool

master
fangdingjun 6 years ago
parent 8288f2a989
commit 0a79b2882d

@ -29,11 +29,13 @@ const (
NGHTTP2_ERR_DEFERRED = -508 NGHTTP2_ERR_DEFERRED = -508
) )
/*
var bufPool = &sync.Pool{ var bufPool = &sync.Pool{
New: func() interface{} { New: func() interface{} {
return make([]byte, 16*1024) return make([]byte, 16*1024)
}, },
} }
*/
// onDataSourceReadCallback callback function for libnghttp2 library // onDataSourceReadCallback callback function for libnghttp2 library
// want read data from data provider source, // want read data from data provider source,
@ -50,15 +52,17 @@ func onDataSourceReadCallback(ptr unsafe.Pointer, streamID C.int,
//log.Println("client dp callback, stream not exists") //log.Println("client dp callback, stream not exists")
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE
} }
//gobuf := make([]byte, int(length)) gobuf := make([]byte, int(length))
/*
_length := int(length) _length := int(length)
gobuf := bufPool.Get().([]byte) gobuf := bufPool.Get().([]byte)
if len(gobuf) < _length { if len(gobuf) < _length {
gobuf = make([]byte, _length) gobuf = make([]byte, _length)
} }
defer bufPool.Put(gobuf) defer bufPool.Put(gobuf)
*/
n, err := s.dp.Read(gobuf[:_length]) n, err := s.dp.Read(gobuf[0:])
if err != nil { if err != nil {
if err == io.EOF { if err == io.EOF {
//log.Println("onDataSourceReadCallback end") //log.Println("onDataSourceReadCallback end")

Loading…
Cancel
Save