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 {
...
@@ -39,8 +39,8 @@ type Server struct {
started
chan
struct
{}
started
chan
struct
{}
reqPool
sync
.
Pool
reqMu
sync
.
Mutex
reqMu
sync
.
Mutex
reqPool
[]
*
request
readPool
[][]
byte
readPool
[][]
byte
reqReaders
int
reqReaders
int
outstandingReadBufs
int
outstandingReadBufs
int
...
@@ -139,7 +139,7 @@ func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server
...
@@ -139,7 +139,7 @@ func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server
started
:
make
(
chan
struct
{}),
started
:
make
(
chan
struct
{}),
opts
:
&
o
,
opts
:
&
o
,
}
}
ms
.
reqPool
.
New
=
func
()
interface
{}
{
return
new
(
request
)
}
optStrs
:=
opts
.
Options
optStrs
:=
opts
.
Options
if
opts
.
AllowOther
{
if
opts
.
AllowOther
{
optStrs
=
append
(
optStrs
,
"allow_other"
)
optStrs
=
append
(
optStrs
,
"allow_other"
)
...
@@ -203,14 +203,8 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) {
...
@@ -203,14 +203,8 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) {
ms
.
reqMu
.
Unlock
()
ms
.
reqMu
.
Unlock
()
return
nil
,
OK
return
nil
,
OK
}
}
l
:=
len
(
ms
.
reqPool
)
req
=
ms
.
reqPool
.
Get
()
.
(
*
request
)
if
l
>
0
{
l
:=
len
(
ms
.
readPool
)
req
=
ms
.
reqPool
[
l
-
1
]
ms
.
reqPool
=
ms
.
reqPool
[
:
l
-
1
]
}
else
{
req
=
new
(
request
)
}
l
=
len
(
ms
.
readPool
)
if
l
>
0
{
if
l
>
0
{
dest
=
ms
.
readPool
[
l
-
1
]
dest
=
ms
.
readPool
[
l
-
1
]
ms
.
readPool
=
ms
.
readPool
[
:
l
-
1
]
ms
.
readPool
=
ms
.
readPool
[
:
l
-
1
]
...
@@ -224,8 +218,8 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) {
...
@@ -224,8 +218,8 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) {
n
,
err
:=
syscall
.
Read
(
ms
.
mountFd
,
dest
)
n
,
err
:=
syscall
.
Read
(
ms
.
mountFd
,
dest
)
if
err
!=
nil
{
if
err
!=
nil
{
code
=
ToStatus
(
err
)
code
=
ToStatus
(
err
)
ms
.
reqPool
.
Put
(
req
)
ms
.
reqMu
.
Lock
()
ms
.
reqMu
.
Lock
()
ms
.
reqPool
=
append
(
ms
.
reqPool
,
req
)
ms
.
reqReaders
--
ms
.
reqReaders
--
ms
.
reqMu
.
Unlock
()
ms
.
reqMu
.
Unlock
()
return
nil
,
code
return
nil
,
code
...
@@ -268,7 +262,7 @@ func (ms *Server) returnRequest(req *request) {
...
@@ -268,7 +262,7 @@ func (ms *Server) returnRequest(req *request) {
ms
.
outstandingReadBufs
--
ms
.
outstandingReadBufs
--
req
.
bufferPoolInputBuf
=
nil
req
.
bufferPoolInputBuf
=
nil
}
}
ms
.
reqPool
=
append
(
ms
.
reqPool
,
req
)
ms
.
reqPool
.
Put
(
req
)
ms
.
reqMu
.
Unlock
()
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