diff --git a/callbacks.go b/callbacks.go index c56db28..ed11fbe 100644 --- a/callbacks.go +++ b/callbacks.go @@ -29,11 +29,13 @@ const ( NGHTTP2_ERR_DEFERRED = -508 ) +/* var bufPool = &sync.Pool{ New: func() interface{} { return make([]byte, 16*1024) }, } +*/ // onDataSourceReadCallback callback function for libnghttp2 library // 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") return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE } - //gobuf := make([]byte, int(length)) - _length := int(length) - gobuf := bufPool.Get().([]byte) - if len(gobuf) < _length { - gobuf = make([]byte, _length) - } - defer bufPool.Put(gobuf) + gobuf := make([]byte, int(length)) + /* + _length := int(length) + gobuf := bufPool.Get().([]byte) + if len(gobuf) < _length { + gobuf = make([]byte, _length) + } + defer bufPool.Put(gobuf) + */ - n, err := s.dp.Read(gobuf[:_length]) + n, err := s.dp.Read(gobuf[0:]) if err != nil { if err == io.EOF { //log.Println("onDataSourceReadCallback end")