Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add context.Context to the Debug reporting method, and all serving/response handling. #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package fuse

import (
"runtime"

"golang.org/x/net/context"
)

func stack() string {
buf := make([]byte, 1024)
return string(buf[:runtime.Stack(buf, false)])
}

func nop(msg interface{}) {}
func nop(ctx context.Context, msg interface{}) {}

// Debug is called to output debug messages, including protocol
// traces. The default behavior is to do nothing.
Expand All @@ -18,4 +20,4 @@ func nop(msg interface{}) {}
// safe to marshal to JSON.
//
// Implementations must not retain msg.
var Debug func(msg interface{}) = nop
var Debug func(ctx context.Context, msg interface{}) = nop
5 changes: 3 additions & 2 deletions fs/fstestutil/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"

"bazil.org/fuse"
"golang.org/x/net/context"
)

type flagDebug bool
Expand All @@ -18,7 +19,7 @@ func (f *flagDebug) IsBoolFlag() bool {
return true
}

func nop(msg interface{}) {}
func nop(ctx context.Context, msg interface{}) {}

func (f *flagDebug) Set(s string) error {
v, err := strconv.ParseBool(s)
Expand All @@ -38,7 +39,7 @@ func (f *flagDebug) String() string {
return strconv.FormatBool(bool(*f))
}

func logMsg(msg interface{}) {
func logMsg(ctx context.Context, msg interface{}) {
log.Printf("FUSE: %s\n", msg)
}

Expand Down
5 changes: 3 additions & 2 deletions fs/fstestutil/mounted.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"bazil.org/fuse"
"bazil.org/fuse/fs"
"golang.org/x/net/context"
)

// Mount contains information about the mount for the test to use.
Expand Down Expand Up @@ -75,7 +76,7 @@ func Mounted(srv *fs.Server, options ...fuse.MountOption) (*Mount, error) {
}
go func() {
defer close(done)
serveErr <- srv.Serve(c)
serveErr <- srv.Serve(context.Background(), c)
}()

select {
Expand Down Expand Up @@ -105,7 +106,7 @@ func MountedT(t testing.TB, filesys fs.FS, options ...fuse.MountOption) (*Mount,
FS: filesys,
}
if debug {
srv.Debug = func(msg interface{}) {
srv.Debug = func(ctx context.Context, msg interface{}) {
t.Logf("FUSE: %s", msg)
}
}
Expand Down
Loading