Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
9d459bc5
Commit
9d459bc5
authored
Jun 23, 2014
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuse: use sync.Pool for the request pool.
parent
4d73e177
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
12 deletions
+6
-12
fuse/server.go
fuse/server.go
+6
-12
No files found.
fuse/server.go
View file @
9d459bc5
...
...
@@ -39,8 +39,8 @@ type Server struct {
started
chan
struct
{}
reqPool
sync
.
Pool
reqMu
sync
.
Mutex
reqPool
[]
*
request
readPool
[][]
byte
reqReaders
int
outstandingReadBufs
int
...
...
@@ -139,7 +139,7 @@ func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server
started
:
make
(
chan
struct
{}),
opts
:
&
o
,
}
ms
.
reqPool
.
New
=
func
()
interface
{}
{
return
new
(
request
)
}
optStrs
:=
opts
.
Options
if
opts
.
AllowOther
{
optStrs
=
append
(
optStrs
,
"allow_other"
)
...
...
@@ -203,14 +203,8 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) {
ms
.
reqMu
.
Unlock
()
return
nil
,
OK
}
l
:=
len
(
ms
.
reqPool
)
if
l
>
0
{
req
=
ms
.
reqPool
[
l
-
1
]
ms
.
reqPool
=
ms
.
reqPool
[
:
l
-
1
]
}
else
{
req
=
new
(
request
)
}
l
=
len
(
ms
.
readPool
)
req
=
ms
.
reqPool
.
Get
()
.
(
*
request
)
l
:=
len
(
ms
.
readPool
)
if
l
>
0
{
dest
=
ms
.
readPool
[
l
-
1
]
ms
.
readPool
=
ms
.
readPool
[
:
l
-
1
]
...
...
@@ -224,8 +218,8 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) {
n
,
err
:=
syscall
.
Read
(
ms
.
mountFd
,
dest
)
if
err
!=
nil
{
code
=
ToStatus
(
err
)
ms
.
reqPool
.
Put
(
req
)
ms
.
reqMu
.
Lock
()
ms
.
reqPool
=
append
(
ms
.
reqPool
,
req
)
ms
.
reqReaders
--
ms
.
reqMu
.
Unlock
()
return
nil
,
code
...
...
@@ -268,7 +262,7 @@ func (ms *Server) returnRequest(req *request) {
ms
.
outstandingReadBufs
--
req
.
bufferPoolInputBuf
=
nil
}
ms
.
reqPool
=
append
(
ms
.
reqPool
,
req
)
ms
.
reqPool
.
Put
(
req
)
ms
.
reqMu
.
Unlock
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment