caddyhttp: Removing redundant middleware next copy#7217
caddyhttp: Removing redundant middleware next copy#7217mholt merged 2 commits intocaddyserver:masterfrom
Conversation
|
Oh, interesting! That's a tricky one cause the loop is at the caller. I hope you're right, this is a pretty risky bit. I suppose it'll shave a few nanoseconds per request 😅 |
|
Ha, I knew EXACTLY what this was about from the title even before I opened the PR or the diff. (We do something similar with We need to be really careful with this. How have you verified that this is correct? (I had a hard time writing tests for this back in the day.) |
|
I'm going to spend some time in the coming days to verify this works as intended. I'll post an update as soon as possible! |
|
Hey just circling back on this. Did some testing / debugging on my branch and on a branch with versions of Go <1.22 and I'm not seeing the reference issue that you are referring to. Each I would be curious to see how you are able to detect this duplication issue! Let me know if there is a specific way to test this that you had in mind. Maybe I'm missing something here. |
|
In the case of capturing a copy before mutation, I think this portion of |
mholt
left a comment
There was a problem hiding this comment.
@maxcelant Thanks for checking. If I recall, when I was initially designing/writing Caddy 2, this bug was very apparent (and initially confusing!!) when it manifested. So if you haven't seen it reoccur, that's probably a good sign.
fixes #7216
No AI was used.