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

fix: change inner req hdr caused race #775

Merged
merged 1 commit into from
Oct 21, 2024
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
14 changes: 4 additions & 10 deletions api/pkg/filtermanager/filtermanager_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,11 @@ func (m *filterManager) OnLog(reqHdr capi.RequestHeaderMap, reqTrailer capi.Requ
return
}

m.hdrLock.Lock()
if m.reqHdr == nil {
m.reqHdr = &filterManagerRequestHeaderMap{
RequestHeaderMap: reqHdr,
}
} else {
// In our benchmark BenchmarkFilterManagerRegular, reuse the request header wrapper is 5% faster than create a new one,
// even the reusage requires holding the lock though it is running on fast path.
h, _ := m.reqHdr.(*filterManagerRequestHeaderMap)
h.RequestHeaderMap = reqHdr
wrappedReqHdr := &filterManagerRequestHeaderMap{
RequestHeaderMap: reqHdr,
}
m.hdrLock.Lock()
m.reqHdr = wrappedReqHdr
m.hdrLock.Unlock()
m.runOnLogPhase(m.reqHdr, reqTrailer, rspHdr, rspTrailer)
}
Expand Down
Loading