Repository navigation
fix(xhttp): rewrite libx bench servers on current API + h2 on_data arg fix - #88
Merged
Merged
Conversation
The four C++ bench servers in libx/bench/http used the pre-resolver server API (xHttpServerCreate(), xHttpServerRoute(), xHttpResponseWriter/xHttpResponseSend) which no longer exists — they did not compile when X_BUILD_BENCHMARKS=ON. Rewrite them on the current API (xHttpMux resolver + xHttpCtx handlers) and fix two bugs found while doing so: - proto_h2.c: the h2 on_data callback passed route_info->arg instead of stream->user, so per-request state (xHttpCtxSetUser) was invisible and POST body handlers dereferenced NULL. Align with h1. - bench POST /echo per-request state is now freed on both on_done and on_close (abort-path leak guard); xHttpRouteConf gained on_close, forwarded by xHttpMuxHandle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
libx/bench/http/的 4 个 C++ bench server(http/https/ws/wss)仍使用 pre-resolver旧 server API(
xHttpServerCreate()、xHttpServerRoute()、xHttpResponseWriter/xHttpResponseSend),在新 API 下无法编译(X_BUILD_BENCHMARKS=ON即挂)。CI 默认不开 bench 所以一直没暴露;本次压测工作开启 bench 后才发现。
改动
xHttpMuxresolver +xHttpRouteInfo回调 +
xHttpCtxhandler;POST /echo 用xHttpCtxSetUser存 per-request 状态。on_dataarg bug(proto_h2.c):h2 直接传route_info->arg,h1 用
stream->user ?: route_info->arg——per-request 状态在 h2 下不可见,POST body 处理解引用 NULL 崩溃。对齐 h1。
EchoBody在on_done(正常)和on_close(abort/断开兜底)双路径释放;xHttpRouteConf补on_close字段并在xHttpMuxHandle转发。验证
curl -sk POST(默认协商 h2)正常 echo详见
issues/http-h2-ondata-user-arg.md。