From e0c9ce2c7a75505707e8e4a08db6bea947715b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=B3=BD=E8=BD=A9?= Date: Mon, 28 Oct 2024 09:58:34 +0800 Subject: [PATCH] fix: change inner req hdr caused race (#782) https://github.com/mosn/htnn/pull/775 doesn't really fix the problem. Since we already create the wrapper, we should pass the wrapper directly to OnLog, instead of setting the reqHdr field. Signed-off-by: spacewander --- api/pkg/filtermanager/filtermanager_dev.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/api/pkg/filtermanager/filtermanager_dev.go b/api/pkg/filtermanager/filtermanager_dev.go index 85aac872..8502847c 100644 --- a/api/pkg/filtermanager/filtermanager_dev.go +++ b/api/pkg/filtermanager/filtermanager_dev.go @@ -32,10 +32,7 @@ func (m *filterManager) OnLog(reqHdr capi.RequestHeaderMap, reqTrailer capi.Requ wrappedReqHdr := &filterManagerRequestHeaderMap{ RequestHeaderMap: reqHdr, } - m.hdrLock.Lock() - m.reqHdr = wrappedReqHdr - m.hdrLock.Unlock() - m.runOnLogPhase(m.reqHdr, reqTrailer, rspHdr, rspTrailer) + m.runOnLogPhase(wrappedReqHdr, reqTrailer, rspHdr, rspTrailer) } func wrapFilterManager(fm *filterManager) capi.StreamFilter {