Fixed error and debug logging.
parent
9c2f2652f7
commit
85cd1cb299
|
@ -234,6 +234,7 @@ func (c *Connection) ReadOp() (op fuseops.Op, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sendReply := func(
|
sendReply := func(
|
||||||
|
op fuseops.Op,
|
||||||
fuseID uint64,
|
fuseID uint64,
|
||||||
replyMsg []byte,
|
replyMsg []byte,
|
||||||
opErr error) (err error) {
|
opErr error) (err error) {
|
||||||
|
@ -244,6 +245,20 @@ func (c *Connection) ReadOp() (op fuseops.Op, err error) {
|
||||||
// Clean up state for this op.
|
// Clean up state for this op.
|
||||||
c.finishOp(m.Hdr.Opcode, m.Hdr.Unique)
|
c.finishOp(m.Hdr.Opcode, m.Hdr.Unique)
|
||||||
|
|
||||||
|
// Debug logging
|
||||||
|
if c.debugLogger != nil {
|
||||||
|
if opErr == nil {
|
||||||
|
op.Logf("-> %s OK", op.ShortDesc())
|
||||||
|
} else {
|
||||||
|
op.Logf("-> %s error: %v", op.ShortDesc(), opErr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error logging
|
||||||
|
if opErr != nil && c.errorLogger != nil {
|
||||||
|
c.errorLogger.Printf("(%s) error: %v", op.ShortDesc(), opErr)
|
||||||
|
}
|
||||||
|
|
||||||
// Send the reply to the kernel.
|
// Send the reply to the kernel.
|
||||||
err = c.wrapped.WriteToKernel(replyMsg)
|
err = c.wrapped.WriteToKernel(replyMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -40,7 +40,7 @@ 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. The error argument is for informational
|
// with the given fuse unique ID. The error argument is for informational
|
||||||
// purposes only; the error to hand to the kernel is encoded in the message.
|
// purposes only; the error to hand to the kernel is encoded in the message.
|
||||||
type replyFunc func(uint64, []byte, error) error
|
type replyFunc func(Op, uint64, []byte, error) error
|
||||||
|
|
||||||
// A helper for embedding common behavior.
|
// A helper for embedding common behavior.
|
||||||
type commonOp struct {
|
type commonOp struct {
|
||||||
|
@ -111,9 +111,9 @@ func (o *commonOp) init(
|
||||||
|
|
||||||
// When the op is finished, report to both reqtrace and the connection.
|
// When the op is finished, report to both reqtrace and the connection.
|
||||||
prevSendReply := o.sendReply
|
prevSendReply := o.sendReply
|
||||||
o.sendReply = func(fuseID uint64, msg []byte, opErr error) (err error) {
|
o.sendReply = func(op Op, fuseID uint64, msg []byte, opErr error) (err error) {
|
||||||
reportForTrace(opErr)
|
reportForTrace(opErr)
|
||||||
err = prevSendReply(fuseID, msg, opErr)
|
err = prevSendReply(op, fuseID, msg, opErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,25 +155,8 @@ func (o *commonOp) Respond(err error) {
|
||||||
h.Error = -int32(errno)
|
h.Error = -int32(errno)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log the error, if any.
|
|
||||||
if err != nil {
|
|
||||||
if o.debugLog != nil {
|
|
||||||
o.Logf(
|
|
||||||
"-> (%s) error: %v",
|
|
||||||
o.op.ShortDesc(),
|
|
||||||
err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if o.errorLogger != nil {
|
|
||||||
o.errorLogger.Printf(
|
|
||||||
"(%s) error: %v",
|
|
||||||
o.op.ShortDesc(),
|
|
||||||
err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reply.
|
// Reply.
|
||||||
replyErr := o.sendReply(o.fuseID, msg, err)
|
replyErr := o.sendReply(o.op, o.fuseID, msg, err)
|
||||||
if replyErr != nil && o.errorLogger != nil {
|
if replyErr != nil && o.errorLogger != nil {
|
||||||
o.errorLogger.Printf("Error from sendReply: %v", replyErr)
|
o.errorLogger.Printf("Error from sendReply: %v", replyErr)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue