Commit 22d9c9dc authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse: retain interface types

This avoids one allocation under lock (calling sync.Pool.Put converts to
interface{})

Change-Id: Icfe155e34300dca398cea99b73bc5e10fd362ae3
parent fc2c4d3d
...@@ -325,8 +325,10 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) { ...@@ -325,8 +325,10 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) {
ms.reqReaders++ ms.reqReaders++
ms.reqMu.Unlock() ms.reqMu.Unlock()
req = ms.reqPool.Get().(*request) reqIface := ms.reqPool.Get()
dest := ms.readPool.Get().([]byte) req = reqIface.(*request)
destIface := ms.readPool.Get()
dest := destIface.([]byte)
var n int var n int
err := handleEINTR(func() error { err := handleEINTR(func() error {
...@@ -336,7 +338,7 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) { ...@@ -336,7 +338,7 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) {
}) })
if err != nil { if err != nil {
code = ToStatus(err) code = ToStatus(err)
ms.reqPool.Put(req) ms.reqPool.Put(reqIface)
ms.reqMu.Lock() ms.reqMu.Lock()
ms.reqReaders-- ms.reqReaders--
ms.reqMu.Unlock() ms.reqMu.Unlock()
...@@ -357,8 +359,7 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) { ...@@ -357,8 +359,7 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) {
req.inflightIndex = len(ms.reqInflight) req.inflightIndex = len(ms.reqInflight)
ms.reqInflight = append(ms.reqInflight, req) ms.reqInflight = append(ms.reqInflight, req)
if !gobbled { if !gobbled {
ms.readPool.Put(dest) ms.readPool.Put(destIface)
dest = nil
} }
ms.reqReaders-- ms.reqReaders--
if !ms.singleReader && ms.reqReaders <= 0 { if !ms.singleReader && ms.reqReaders <= 0 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment