3712 Commits

Author SHA1 Message Date
Chuang Zhang f90ab52b64 docs: add Bazel build guide and bzlmod example (#3468)
* docs: add Bazel build guide for bRPC (#13)

* docs: fix build_with_bazel_module echo example

* docs: explain why the bzlmod example repeats the root overrides (#24)

---------

Co-authored-by: Winchell <cw20050111@gmail.com>
2026-08-24 18:14:07 +08:00
UB e7f0867068 Reject out-of-range port in SplitHostAndPort (#3434)
* reject out-of-range port in SplitHostAndPort

Signed-off-by: ubeddulla khan <ubed@bugqore.com>

* parse port forward and clamp to avoid accumulator wrap

---------

Signed-off-by: ubeddulla khan <ubed@bugqore.com>
2026-08-24 16:06:57 +08:00
UB 1665ebedfd Skip header fields containing CR/LF in http serialization (#3387)
* skip header fields containing CR/LF in http serialization

* Gate CR/LF header check behind a flag; log at WARNING with sanitized name

Signed-off-by: ubeddulla khan <ubed@bugqore.com>

* Log the skipped header value alongside its name

Signed-off-by: ubeddulla khan <ubed@bugqore.com>

* Use separate IOBufs for request and response in the CR/LF header test

Signed-off-by: ubeddulla khan <ubed@bugqore.com>

---------

Signed-off-by: ubeddulla khan <ubed@bugqore.com>
2026-08-24 15:58:48 +08:00
Chuang Zhang 16e3c31158 Clean up UBRing code and make configuration names (#3471) 2026-08-24 15:54:34 +08:00
Xiaofeng Wang 9e9c626abf Fix streaming RPC frame validation (#3481) 2026-08-24 15:53:18 +08:00
ShawYann e2babdf1e6 Docs: add StarRocks use case to community/cases.md (#3478)
Added section on brpc usage in StarRocks, detailing version, usage, and provider.
2026-08-23 14:31:22 +08:00
Bright Chen 71871ee9fb Fix potential bvar deadlock by running describe()/dump() outside the global VarMap lock (#3470) 2026-08-22 23:55:40 +08:00
Chuang Zhang 64663837f6 Support progressive HTTP read timeout (#3469)
* Add timeout support for progressive HTTP reads (#15)

Co-authored-by: zchuango <zchuang185@gmail.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: BGQ99 <1132767344@qq.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-08-22 23:39:01 +08:00
Weibing Wang fb2f6efa56 Fix unstable hpack UT (#3473) 2026-08-22 14:25:25 +08:00
UB a5c3365af1 size hpack dynamic table for the 33-byte minimum entry (#3462)
* size hpack dynamic table for the 33-byte minimum entry

* keep at least one dynamic-table slot when max_size < 33
2026-08-22 12:09:36 +08:00
Bright Chen e24461e353 Refactor NULL with nullptr in docs (#3467) 2026-08-19 23:11:50 +08:00
Bright Chen 271b98fef7 Refactor NULL with nullptr in example (#3466) 2026-08-19 23:06:40 +08:00
Bright Chen 93f6692ebb Refactor NULL with nullptr in tools (#3465) 2026-08-19 23:03:24 +08:00
Bright Chen c9778ca1a3 Refactor NULL with nullptr in test (#3464) 2026-08-19 13:26:18 +08:00
Bright Chen afef47a83e Refactor NULL with nullptr in brpc (#3461) 2026-08-19 13:21:38 +08:00
Bright Chen 688d5f49d6 Refactor NULL with nullptr in bthread (#3454) 2026-08-19 13:18:34 +08:00
Bright Chen 3366074fa5 Refactor NULL with nullptr in brpc/policy (#3458)
* Refactor NULL with nullptr in brpc/policy

* Fix NULL in mysql comments
2026-08-18 22:20:53 +08:00
Bright Chen 11f8192bdf Refactor NULL with nullptr in brpc/rdma (#3459) 2026-08-18 13:55:37 +08:00
Bright Chen 64120a3727 Refactor NULL with nullptr in brpc/ubshm (#3460) 2026-08-18 13:53:58 +08:00
Bright Chen 3188cb587c Refactor NULL with nullptr in brpc/builtin (#3456) 2026-08-18 13:51:47 +08:00
Bright Chen f0f72fdaa5 Refactor NULL with nullptr in json2pb (#3455) 2026-08-18 13:50:38 +08:00
Bright Chen 7f8120a583 Refactor NULL with nullptr in brpc/details (#3457) 2026-08-18 13:47:41 +08:00
Weibing Wang 96ce9f11ee Fix bug when parsing zero-length string field in mcpack2pb (#3450)
* Fix bug when parsing zero-length string field in mcpack2pb

UnparsedValue::as_string() resizes the output string to
without checking , where  is the value_size of a string
field read from the input. When value_size is 0,  underflows
to SIZE_MAX and resize() throws std::length_error, which is not caught
on the request path and therefore crashes the server. Reject such
malformed fields by marking the stream bad so the caller can fail the
request gracefully instead.

* Clear output string when size error
2026-08-16 18:01:01 +08:00
nas 7f64663135 Fix WeightedRandomizedLoadBalancer skipping the last server (#3426)
* fix WeightedRandomizedLoadBalancer skipping the last server

SelectServer() draws random_weight from fast_rand_less_than(weight_sum),
i.e. from [0, weight_sum - 1], and then lower_bound()s it against
Server::current_weight_sum, which Add() fills with an inclusive prefix
sum. lower_bound() returns the first server whose prefix sum is >=
random_weight, but a server owns the half-open range
[prefix(i-1), prefix(i)), so the predicate has to be > random_weight.

Because of that the first server in the list also serves
random_weight == prefix(0) and the last server never serves anything at
all, since random_weight can never reach weight_sum. With four servers of
equal weight the measured distribution is 49.8/25.1/25.1/0.0 percent
instead of 25 percent each.

Search for random_weight + 1 so that lower_bound() lands on the first
prefix sum strictly greater than random_weight.

The existing weighted_randomized test does not catch this: its servers
have weights 3/2/5/10 and it only asserts that each rate is within
0.5x~2x of the expected one. The weight-10 server measures 0.448 before
this change and 0.494 after it, both inside that band. Add
weighted_randomized_equal_weight, which uses equal weights so that a
single misplaced slot is visible, and check the rates within 0.9x~1.1x.

Signed-off-by: Anas <156536069+Nas01010101@users.noreply.github.com>

* use upper_bound for the weighted prefix-sum search

upper_bound(random_weight) states the intent directly: the first server whose
inclusive prefix sum is strictly greater than random_weight. It is the same
search as lower_bound(random_weight + 1) without the increment.

Also correct the tolerance comment in the unit test: with run_times=40000 and
p=0.25 the count has sigma ~= 86.6, so the 0.9x~1.1x band is about 11 sigma,
not more than 20.

---------

Signed-off-by: Anas <156536069+Nas01010101@users.noreply.github.com>
2026-08-16 17:39:37 +08:00
Weibing Wang 137c1ca304 Revert "Progressive timeout dev (#3409)" (#3453)
This reverts commit e0abb1001e.
2026-08-16 17:31:23 +08:00
Xiaofeng Wang 9aa41f79f2 Support flow-controlled gRPC client requests (#3430)
* Support flow-controlled gRPC client requests

- Split client request DATA frames according to the peer's connection and
  stream flow-control windows.
- Buffer unsent DATA and resume transmission when WINDOW_UPDATE restores
  capacity.
- Track pending request bytes per H2 connection and apply
  socket_max_unwritten_bytes as an upper bound.
- Reject or reroute new requests once the pending DATA limit is reached.
- Release buffered DATA when an RPC fails, times out, or its stream is
  removed.
- Add tests for fragmented transmission, deferred DATA flushing,
  pending-byte accounting, and buffer cleanup.

* Fix pending HTTP/2 data limit race

- Check pending DATA capacity atomically with client stream insertion.
- Leave stream and window state unchanged when the limit is exceeded.
- Use an ephemeral port in the gRPC flow-control test.
- Avoid accessing an empty payload buffer in H2 frame tests.
2026-08-16 15:22:43 +08:00
Bright Chen 48db968fa0 Refactor NULL with nullptr in butil (#3444) 2026-08-16 10:29:58 +08:00
Weibing Wang 552bfd6e25 Fix SOFA PBRPC parser not limiting metadata size (#3449)
ParseSofaMessage only checked body_size against max_body_size, while
meta_size and the total frame size were left unbounded. A frame with a
large meta_size and zero body_size passed the body_size check and made
the connection keep buffering far beyond the configured limit before the
invalid metadata was rejected. Bound meta_size by max_body_size as well,
consistent with other protocols such as baidu_std and hulu_pbrpc.

Add unit tests covering oversized body and oversized metadata.
2026-08-16 01:08:59 +08:00
Weibing Wang ca370c28a9 Fix RTMP abort message deleting the chunk stream being parsed (#3452)
* Fix RTMP abort message deleting the chunk stream being parsed

* Address review comments on RTMP abort regression test
2026-08-16 01:08:30 +08:00
Weibing Wang 437a7b705c Limit mcpack2pb array item count to the actual payload size (#3451)
* Limit mcpack2pb array item count to the actual payload size

The item count in an mcpack array header is read directly from the
request and was used as-is by the generated parsing code to Reserve()
memory for repeated protobuf fields. A malformed request could claim an
item count up to INT32_MAX and force the server to preallocate ~16GB of
virtual memory, which may abort the process on memory-constrained hosts.

Cap the item count by the remaining bytes of the array (each item
occupies at least one byte) so that the preallocation is bounded by the
request size.

* Fix underflow in mcpack2pb array item count clamping
2026-08-16 01:06:46 +08:00
Chuang Zhang e0abb1001e Progressive timeout dev (#3409)
* add the progressive timeout reader

* optimize the code format

* WIP: progressive read timeout review

* test: strengthen progressive read timeout coverage
2026-08-15 16:56:56 +08:00
UB 24146ca556 cap simple string length in RedisReply::ConsumePartialIOBuf (#3404)
* cap simple string length in RedisReply::ConsumePartialIOBuf

Signed-off-by: ubeddulla khan <ubed@bugqore.com>

* reject negative redis_max_allocation_size in simple string branch

Signed-off-by: ubeddulla khan <ubed@bugqore.com>

* enforce redis simple string cap while waiting for CRLF

Signed-off-by: ubeddulla khan <ubed@bugqore.com>

---------

Signed-off-by: ubeddulla khan <ubed@bugqore.com>
2026-08-15 14:12:00 +08:00
Bright Chen 3124cf035d Replace NULL with nullptr in butil/containers (#3437) 2026-08-15 13:57:09 +08:00
Bright Chen a2a43d951a Refactor NULL with nullptr in butil/threading (#3443) 2026-08-15 13:56:50 +08:00
Bright Chen 9f9b62f683 Refactor NULL with nullptr in butil/strings (#3442) 2026-08-15 13:56:33 +08:00
Bright Chen a22d3052c8 Refactor NULL with nullptr in butil/memory (#3441) 2026-08-15 13:56:15 +08:00
Bright Chen 950cf26f9b Refactor NULL with nullptr in butil/files (#3440) 2026-08-15 13:55:57 +08:00
Bright Chen bd6fa80ba6 Replace NULL with nullptr in butil/details, butil/mac, butil/synchronization and butil/time (#3439) 2026-08-15 13:55:40 +08:00
Bright Chen 5a80007eb1 Replace NULL with nullptr in butil/debug (#3438) 2026-08-15 13:55:23 +08:00
Chuang Zhang 04d0bf0f80 fix(test): avoid overriding the configured C++ standard (#3446) 2026-08-15 11:08:02 +08:00
Regal 58ad9048b9 build: complete UBRING Bazel and CI support (#3445)
Add the missing BRPC_WITH_UBRING Bazel configuration, wire it through
the library and example targets, and document the supported build
commands.

Enable RDMA and UBRING in CI jobs whose all-options configurations did
not exercise those features. Run both feature suites in the existing
Bazel unit-test jobs and enable RDMA in the Make unit-test job.

Use unsigned literals for UBRING atomic counter operations to match the
counter type and avoid template deduction failures on stricter
compilers.

Signed-off-by: Zhengwei Zhu <141622927+ZhengweiZhu@users.noreply.github.com>
2026-08-15 09:54:19 +08:00
Regal 117531111d test: wait for submitted spans to be collected (#3448)
Wait for the asynchronous span collector to release root client spans
after Controller reset or submission. This prevents LeakSanitizer from
reporting pending test spans when the short-lived test binary exits
before the collector’s first polling interval.

Signed-off-by: Zhengwei Zhu <141622927+ZhengweiZhu@users.noreply.github.com>
2026-08-15 09:42:04 +08:00
Bright Chen febb014aaa Signal workers for priority tasks (#3423) 2026-08-10 10:20:11 +08:00
Xiaofeng Wang ce0eaec391 Merge pull request #3429 from wasphin/feature/protobuf-35
Support Protobuf v35
2026-08-09 19:42:20 +08:00
lh2debug-2 cb84e83c59 fix rpcz root client span lifetime (#3420) (#3421)
Keep the current RPC span alive from Controller until the RPC finishes,
SubmitSpan runs, or the Controller is reset. This lets root client spans
without a local parent be submitted to rpcz instead of being destroyed
after the caller-side temporary shared_ptr goes out of scope.

Child client spans remain linked to their parent through weak local-parent
references and parent-owned client lists, so they are still serialized
under their parent without introducing shared_ptr cycles.

Co-authored-by: lh2debug <lh2debug@163.com>
2026-08-09 15:03:54 +08:00
Bright Chen 7a3e034e20 Fix brpc_proto_library failure when brpc is used as an external Bazel dependency (#3427) 2026-08-09 14:47:53 +08:00
Bright Chen 0ec3a9ddaa Refactor streaming rpc (#3422) 2026-08-09 14:35:44 +08:00
Bright Chen 0c8aede171 Fix rdma handshake failing the socket instead of falling back to TCP (#3424) 2026-08-07 17:38:10 +08:00
Bright Chen 159c85505c Fix RDMA PollCq missing recv CQEs after re-arming the CQs (#3425)
PollCq only re-polled send_cq after arming both CQs, so a recv CQE
arriving in the one-shot notification race window of recv_cq was left
in the CQ and the RPC timed out. Restart the re-poll from recv_cq so
that both CQs are covered.
2026-08-07 17:38:00 +08:00
darion-yaphet 0313102276 build(cxx): align all builds on a C++14 baseline (#3419)
* build(cxx): align all builds on a C++14 baseline

CMake, Make, tests, tools, and examples now require C++14 so every supported build path shares the same minimum language level. The compiler checks and user-facing documentation reflect that baseline.

* fix(test): keep cores scoped to the failing test

Clear prior cores before each test binary. A passing death test can leave a core that would otherwise be used to diagnose an unrelated later failure.

* revert src/butil/type_traits.h
2026-08-06 17:34:49 +08:00