From 9397caf144d0024ec9081d7bdebedecf3d76041c Mon Sep 17 00:00:00 2001 From: Patricio Whittingslow Date: Sat, 25 Jul 2026 19:51:06 -0300 Subject: [PATCH] claude found neat bugs --- http/httphi/httphi.go | 7 ++++--- http/httpraw/header.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/http/httphi/httphi.go b/http/httphi/httphi.go index 9590955..ccdc062 100644 --- a/http/httphi/httphi.go +++ b/http/httphi/httphi.go @@ -128,8 +128,6 @@ func (r *Router) Configure(cfg RouterConfig) error { } func (r *Router) Handle(conn conn) error { - r.mu.Lock() - defer r.mu.Unlock() exch := r.getExch(conn) if exch == nil { return lneto.ErrExhausted @@ -141,7 +139,9 @@ func (r *Router) Handle(conn conn) error { } select { case r.pendingConns <- job{exch: exch}: + return nil default: + // pendingConns cannot store another Conn, we drop and return error. exch.used.Store(false) // release. } return lneto.ErrPacketDrop @@ -286,6 +286,7 @@ func (exch *Exchange) Configure(rawbuf []byte, requestLim int, normalizeKeys boo if respSize < 0 { panic("request lim larger than buffer") } + exch.rawbuf = rawbuf exch.reqHdr.Reset(rawbuf[:0:requestLim]) exch.normalizeKeys = normalizeKeys } @@ -320,7 +321,7 @@ func (exch *Exchange) SetHeader(key, value string) (enoughMemory bool) { if exch.normalizeKeys { httpraw.NormalizeHeaderKey(exch.rawbuf[off : off+n]) } - exch.rawbuf[n] = ':' + exch.rawbuf[off+n] = ':' n++ n += copy(exch.rawbuf[off+n:], value) exch.rawbuf[off+n] = '\r' diff --git a/http/httpraw/header.go b/http/httpraw/header.go index 1e09760..b172480 100644 --- a/http/httpraw/header.go +++ b/http/httpraw/header.go @@ -605,7 +605,7 @@ func CopyDecodedPercentURL(dst, value []byte, plusAsSpace bool) (n int, err erro func copyPlusDecoded(dst, src []byte, plusAsSpace bool) int { n := copy(dst, src) if plusAsSpace { - for i := 0; i < n; i++ { + for i := range n { if dst[i] == '+' { dst[i] = ' ' }