Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
Kirill Smelkov
jacobsa-fuse
Commits
c1d30a38
Commit
c1d30a38
authored
Jun 09, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Plain Diff
Moved in-flight waiting from Connection into Server.
For #9.
parents
683decb0
6c85a939
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
14 deletions
+17
-14
connection.go
connection.go
+2
-9
fuseutil/file_system.go
fuseutil/file_system.go
+13
-4
mounted_file_system.go
mounted_file_system.go
+2
-1
No files found.
connection.go
View file @
c1d30a38
...
...
@@ -43,7 +43,6 @@ type Connection struct {
debugLogger
*
log
.
Logger
errorLogger
*
log
.
Logger
wrapped
*
bazilfuse
.
Conn
opsInFlight
sync
.
WaitGroup
// The context from which all op contexts inherit.
parentCtx
context
.
Context
...
...
@@ -217,9 +216,6 @@ func (c *Connection) beginOp(
bfReq
bazilfuse
.
Request
)
(
ctx
context
.
Context
)
{
reqID
:=
bfReq
.
Hdr
()
.
ID
// Note that the op is in flight.
c
.
opsInFlight
.
Add
(
1
)
// Choose a parent context.
ctx
=
c
.
maybeTraceByPID
(
int
(
bfReq
.
Hdr
()
.
Pid
))
...
...
@@ -267,9 +263,6 @@ func (c *Connection) finishOp(bfReq bazilfuse.Request) {
cancel
()
delete
(
c
.
cancelFuncs
,
reqID
)
}
// Decrement the in-flight counter.
c
.
opsInFlight
.
Done
()
}
// LOCKS_EXCLUDED(c.mu)
...
...
@@ -365,9 +358,9 @@ func (c *Connection) waitForReady() (err error) {
return
}
// Close the connection and wait for in-flight ops.
// Close the connection. Must not be called until operations that were read
// from the connection have been responded to.
func
(
c
*
Connection
)
close
()
(
err
error
)
{
err
=
c
.
wrapped
.
Close
()
c
.
opsInFlight
.
Wait
()
return
}
fuseutil/file_system.go
View file @
c1d30a38
...
...
@@ -18,6 +18,7 @@ import (
"flag"
"io"
"math/rand"
"sync"
"time"
"github.com/jacobsa/fuse"
...
...
@@ -73,14 +74,19 @@ type FileSystem interface {
// cf. http://goo.gl/jnkHPO, fuse-devel thread "Fuse guarantees on concurrent
// requests").
func
NewFileSystemServer
(
fs
FileSystem
)
fuse
.
Server
{
return
fileSystemServer
{
fs
}
return
&
fileSystemServer
{
fs
:
fs
,
}
}
type
fileSystemServer
struct
{
fs
FileSystem
fs
FileSystem
opsInFlight
sync
.
WaitGroup
}
func
(
s
fileSystemServer
)
ServeOps
(
c
*
fuse
.
Connection
)
{
func
(
s
*
fileSystemServer
)
ServeOps
(
c
*
fuse
.
Connection
)
{
defer
s
.
opsInFlight
.
Wait
()
for
{
op
,
err
:=
c
.
ReadOp
()
if
err
==
io
.
EOF
{
...
...
@@ -91,11 +97,14 @@ func (s fileSystemServer) ServeOps(c *fuse.Connection) {
panic
(
err
)
}
s
.
opsInFlight
.
Add
(
1
)
go
s
.
handleOp
(
op
)
}
}
func
(
s
fileSystemServer
)
handleOp
(
op
fuseops
.
Op
)
{
func
(
s
*
fileSystemServer
)
handleOp
(
op
fuseops
.
Op
)
{
defer
s
.
opsInFlight
.
Done
()
// Delay if requested.
if
*
fRandomDelays
{
const
delayLimit
=
100
*
time
.
Microsecond
...
...
mounted_file_system.go
View file @
c1d30a38
...
...
@@ -26,7 +26,8 @@ import (
// A type that knows how to serve ops read from a connection.
type
Server
interface
{
// Read and serve ops from the supplied connection until EOF.
// Read and serve ops from the supplied connection until EOF. Do not return
// until all operations have been responded to.
ServeOps
(
*
Connection
)
}
...
...
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