Skip to content

Commit

Permalink
Opportunistically try re-opening file audit fd on error (#2999)
Browse files Browse the repository at this point in the history
Addresses a pain point from
#2863 (comment)
  • Loading branch information
jefferai authored Jul 14, 2017
1 parent e2fee08 commit ba64932
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions builtin/audit/file/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ func (b *Backend) LogRequest(auth *logical.Auth, req *logical.Request, outerErr
return err
}

if err := b.formatter.FormatRequest(b.f, b.formatConfig, auth, req, outerErr); err == nil {
return nil
}

// Opportunistically try to re-open the FD, once per call
b.f.Close()
b.f = nil

if err := b.open(); err != nil {
return err
}

return b.formatter.FormatRequest(b.f, b.formatConfig, auth, req, outerErr)
}

Expand All @@ -175,6 +187,18 @@ func (b *Backend) LogResponse(
return err
}

if err := b.formatter.FormatResponse(b.f, b.formatConfig, auth, req, resp, err); err == nil {
return nil
}

// Opportunistically try to re-open the FD, once per call
b.f.Close()
b.f = nil

if err := b.open(); err != nil {
return err
}

return b.formatter.FormatResponse(b.f, b.formatConfig, auth, req, resp, err)
}

Expand Down

0 comments on commit ba64932

Please sign in to comment.