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

Handling error during initOp response to kernel #151

Merged
merged 2 commits into from
Oct 3, 2023
Merged
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
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
Loading