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
0985694a
Commit
0985694a
authored
May 01, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow setting a parent context for all ops.
parent
a7674283
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
8 deletions
+30
-8
connection.go
connection.go
+11
-3
fuseops/common_op.go
fuseops/common_op.go
+4
-3
fuseops/convert.go
fuseops/convert.go
+4
-1
mounted_file_system.go
mounted_file_system.go
+11
-1
No files found.
connection.go
View file @
0985694a
...
...
@@ -21,6 +21,8 @@ import (
"runtime"
"sync"
"golang.org/x/net/context"
"github.com/jacobsa/bazilfuse"
"github.com/jacobsa/fuse/fuseops"
)
...
...
@@ -31,6 +33,9 @@ type Connection struct {
wrapped
*
bazilfuse
.
Conn
opsInFlight
sync
.
WaitGroup
// The context from which all op contexts inherit.
parentCtx
context
.
Context
// For logging purposes only.
nextOpID
uint32
}
...
...
@@ -38,11 +43,13 @@ type Connection struct {
// Responsibility for closing the wrapped connection is transferred to the
// result. You must call c.close() eventually.
func
newConnection
(
parentCtx
context
.
Context
,
logger
*
log
.
Logger
,
wrapped
*
bazilfuse
.
Conn
)
(
c
*
Connection
,
err
error
)
{
c
=
&
Connection
{
logger
:
logger
,
wrapped
:
wrapped
,
logger
:
logger
,
wrapped
:
wrapped
,
parentCtx
:
parentCtx
,
}
return
...
...
@@ -115,7 +122,8 @@ func (c *Connection) ReadOp() (op fuseops.Op, err error) {
c
.
log
(
opID
,
calldepth
+
1
,
format
,
v
...
)
}
if
op
=
fuseops
.
Convert
(
bfReq
,
logForOp
,
&
c
.
opsInFlight
);
op
==
nil
{
op
=
fuseops
.
Convert
(
c
.
parentCtx
,
bfReq
,
logForOp
,
&
c
.
opsInFlight
)
if
op
==
nil
{
c
.
log
(
opID
,
1
,
"-> ENOSYS: %v"
,
bfReq
)
bfReq
.
RespondError
(
ENOSYS
)
continue
...
...
fuseops/common_op.go
View file @
0985694a
...
...
@@ -25,12 +25,13 @@ import (
// A helper for embedding common behavior.
type
commonOp
struct
{
ctx
context
.
Context
opType
string
r
bazilfuse
.
Request
log
func
(
int
,
string
,
...
interface
{})
opsInFlight
*
sync
.
WaitGroup
report
reqtrace
.
ReportFunc
ctx
context
.
Context
report
reqtrace
.
ReportFunc
}
func
describeOpType
(
t
reflect
.
Type
)
(
desc
string
)
{
...
...
@@ -40,13 +41,13 @@ func describeOpType(t reflect.Type) (desc string) {
}
func
(
o
*
commonOp
)
init
(
ctx
context
.
Context
,
opType
reflect
.
Type
,
r
bazilfuse
.
Request
,
log
func
(
int
,
string
,
...
interface
{}),
opsInFlight
*
sync
.
WaitGroup
)
{
// Initialize basic fields.
o
.
opType
=
describeOpType
(
opType
)
o
.
ctx
=
context
.
Background
()
o
.
r
=
r
o
.
log
=
log
o
.
opsInFlight
=
opsInFlight
...
...
fuseops/convert.go
View file @
0985694a
...
...
@@ -19,6 +19,8 @@ import (
"sync"
"time"
"golang.org/x/net/context"
"github.com/jacobsa/bazilfuse"
)
...
...
@@ -28,6 +30,7 @@ import (
// This function is an implementation detail of the fuse package, and must not
// be called by anyone else.
func
Convert
(
parentCtx
context
.
Context
,
r
bazilfuse
.
Request
,
logForOp
func
(
int
,
string
,
...
interface
{}),
opsInFlight
*
sync
.
WaitGroup
)
(
o
Op
)
{
...
...
@@ -213,7 +216,7 @@ func Convert(
return
}
co
.
init
(
reflect
.
TypeOf
(
o
),
r
,
logForOp
,
opsInFlight
)
co
.
init
(
parentCtx
,
reflect
.
TypeOf
(
o
),
r
,
logForOp
,
opsInFlight
)
return
}
...
...
mounted_file_system.go
View file @
0985694a
...
...
@@ -61,6 +61,10 @@ func (mfs *MountedFileSystem) Join(ctx context.Context) error {
// Optional configuration accepted by Mount.
type
MountConfig
struct
{
// The context from which every op read from the connetion by the sever
// should inherit. If nil, context.Background() will be used.
OpContext
context
.
Context
// OS X only.
//
// Normally on OS X we mount with the novncache option
...
...
@@ -127,8 +131,14 @@ func Mount(
return
}
// Choose a parent context for ops.
opContext
:=
config
.
OpContext
if
opContext
==
nil
{
opContext
=
context
.
Background
()
}
// Create our own Connection object wrapping it.
connection
,
err
:=
newConnection
(
logger
,
bfConn
)
connection
,
err
:=
newConnection
(
opContext
,
logger
,
bfConn
)
if
err
!=
nil
{
bfConn
.
Close
()
err
=
fmt
.
Errorf
(
"newConnection: %v"
,
err
)
...
...
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