Commit fc9297d3 authored by Aaron Jacobs's avatar Aaron Jacobs

commonOp.init

parent 36e4dd83
...@@ -20,7 +20,6 @@ import ( ...@@ -20,7 +20,6 @@ import (
"reflect" "reflect"
"strings" "strings"
"github.com/jacobsa/fuse/internal/fuseshim"
"github.com/jacobsa/reqtrace" "github.com/jacobsa/reqtrace"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
...@@ -36,8 +35,9 @@ type internalOp interface { ...@@ -36,8 +35,9 @@ type internalOp interface {
} }
// A function that sends a reply message back to the kernel for the request // A function that sends a reply message back to the kernel for the request
// with the given fuse unique ID. // with the given fuse unique ID. The error argument is for informational
type replyFunc func(uint64, []byte) error // purposes only; the error to hand to the kernel is encoded in the message.
type replyFunc func(uint64, []byte, error) error
// A helper for embedding common behavior. // A helper for embedding common behavior.
type commonOp struct { type commonOp struct {
...@@ -88,27 +88,28 @@ func (o *commonOp) ShortDesc() (desc string) { ...@@ -88,27 +88,28 @@ func (o *commonOp) ShortDesc() (desc string) {
func (o *commonOp) init( func (o *commonOp) init(
ctx context.Context, ctx context.Context,
op internalOp, op internalOp,
bazilReq fuseshim.Request, fuseID uint64,
sendReply replyFunc,
debugLog func(int, string, ...interface{}), debugLog func(int, string, ...interface{}),
errorLogger *log.Logger, errorLogger *log.Logger) {
finished func(error)) {
// Initialize basic fields. // Initialize basic fields.
o.ctx = ctx o.ctx = ctx
o.op = op o.op = op
o.bazilReq = bazilReq o.fuseID = fuseID
o.sendReply = sendReply
o.debugLog = debugLog o.debugLog = debugLog
o.errorLogger = errorLogger o.errorLogger = errorLogger
o.finished = finished
// Set up a trace span for this op. // Set up a trace span for this op.
var reportForTrace reqtrace.ReportFunc var reportForTrace reqtrace.ReportFunc
o.ctx, reportForTrace = reqtrace.StartSpan(o.ctx, o.op.ShortDesc()) o.ctx, reportForTrace = reqtrace.StartSpan(o.ctx, o.op.ShortDesc())
// When the op is finished, report to both reqtrace and the connection. // When the op is finished, report to both reqtrace and the connection.
prevFinish := o.finished prevSendReply := o.sendReply
o.finished = func(err error) { o.sendReply = func(fuseID uint64, msg []byte, opErr error) (err error) {
reportForTrace(err) reportForTrace(opErr)
prevFinish(err) err = prevSendReply(fuseID, msg, opErr)
return
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment