Skip to content

Commit

Permalink
Return errors during initOp response to kernel (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
raj-prince committed Oct 3, 2023
1 parent ab21db1 commit d0f3daf
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ func (c *Connection) Init() error {
initOp.Flags |= fusekernel.InitNoOpendirSupport
}

c.Reply(ctx, nil)
return nil
return c.Reply(ctx, nil)
}

// Log information for an operation with the given ID. calldepth is the depth
Expand Down Expand Up @@ -471,7 +470,7 @@ func (c *Connection) shouldLogError(
// (or nil if successful). The context must be the context returned by ReadOp.
//
// LOCKS_EXCLUDED(c.mu)
func (c *Connection) Reply(ctx context.Context, opErr error) {
func (c *Connection) Reply(ctx context.Context, opErr error) error {
// Extract the state we stuffed in earlier.
var key interface{} = contextKey
foo := ctx.Value(key)
Expand Down Expand Up @@ -516,11 +515,17 @@ func (c *Connection) Reply(ctx context.Context, opErr error) {
} else {
err = c.writeMessage(outMsg.OutHeaderBytes())
}
if err != nil && c.errorLogger != nil {
c.errorLogger.Printf("writeMessage: %v %v", err, outMsg.OutHeaderBytes())
if err != nil {
writeErrMsg := fmt.Sprintf("writeMessage: %v %v", err, outMsg.OutHeaderBytes())
if c.errorLogger != nil {
c.errorLogger.Print(writeErrMsg)
}
return fmt.Errorf(writeErrMsg)
}
outMsg.Sglist = nil
}

return nil
}

// Close the connection. Must not be called until operations that were read
Expand Down

0 comments on commit d0f3daf

Please sign in to comment.