Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f318a68
Unify transport handshakes on current upstream master
Spicy-cream Oct 9, 2026
d9fc07d
Merge current upstream master and preserve IPC V2 handshake compatibi…
Spicy-cream Oct 16, 2026
2e51361
Fix certificate name extraction with const OpenSSL accessors
Spicy-cream Oct 16, 2026
7ebd2f2
Merge pull request #75 from Spicy-cream/review/pr3535-sync-master-oct15
zchuango Oct 16, 2026
3da2dde
Merge current master and retain shared memory name validation
Spicy-cream Oct 19, 2026
d819d93
Merge pull request #79 from Spicy-cream/review/pr3535-shm-conflict-oct18
zchuango Oct 19, 2026
ebcb46d
Merge modular CMake master and preserve handshake proto generation
Spicy-cream Oct 20, 2026
29f3185
Merge pull request #82 from Spicy-cream/review/pr3535-cmake-conflict-…
zchuango Oct 20, 2026
bacfda1
Merge Apache master and preserve handshake source discovery
Spicy-cream Oct 23, 2026
96babbd
Retrigger community CI
Spicy-cream Oct 23, 2026
9ae366f
Rename the common transport handshake protocol
Spicy-cream Oct 23, 2026
0b9a6fd
Apply handshake review style and test cleanup
Spicy-cream Oct 23, 2026
822d5de
Fix transport handshake cleanup and dispatch
Spicy-cream Oct 26, 2026
cebd46c
Handle handshake startup errors and preserve failure causes
Spicy-cream Oct 26, 2026
9ab0f4d
Retrigger transport handshake CI
Spicy-cream Oct 26, 2026
c0ef0ea
Synchronize handshake read cancellation test and clarify protocol naming
Spicy-cream Oct 26, 2026
82cfd76
Condense the common handshake design document
Spicy-cream Oct 26, 2026
f3012a3
Forward application connection stop notifications through the adapter
Spicy-cream Oct 26, 2026
baf2aca
Stop handshake reads before consuming data from failed sockets
Spicy-cream Oct 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ filegroup(
srcs = glob([
"src/brpc/*.proto",
"src/brpc/policy/*.proto",
"src/brpc/rdma/*.proto",
"src/brpc/urma/*.proto",
]),
visibility = ["//visibility:public"],
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ JSON2PB_DIRS = src/json2pb
JSON2PB_SOURCES = $(foreach d,$(JSON2PB_DIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
JSON2PB_OBJS = $(addsuffix .o, $(basename $(JSON2PB_SOURCES)))

BRPC_DIRS = src/brpc src/brpc/details src/brpc/builtin src/brpc/policy src/brpc/policy/mysql src/brpc/rdma
BRPC_DIRS = src/brpc src/brpc/details src/brpc/builtin src/brpc/handshake src/brpc/policy src/brpc/policy/mysql src/brpc/rdma
ifeq ($(WITH_FLATBUFFERS),1)
BRPC_DIRS += src/brpc/flatbuffers
endif
Expand Down
42 changes: 42 additions & 0 deletions docs/cn/handshake_common_design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# RDMA 与 UBSHM 公共握手

RDMA 和 UBSHM 共用握手流程,以 TCP 交换控制帧。升级成功后使用高速
数据面,协商不可用时继续使用 TCP。

## 分工

| 组件 | 职责 |
| --- | --- |
| `AdapterTransport` | 持有 TCP 与高速 Transport,启动握手、分发输入并选择数据面 |
| `HandshakeSession` | 编排客户端和服务端流程,管理帧收发、增量解析和终态发布 |
| `HandshakeProtocol` | 编解码 hello、ACK 和扩展帧,校验协议版本及字段 |
| `HandshakeTransport` | 准备和协商资源,处理升级、回退及失败清理 |
| `RdmaEndpoint` / `UBShmEndpoint` | 管理传输资源和数据面 |

客户端在 TCP 连接建立后启动握手 bthread;服务端通过 `InputMessenger`
增量解析控制帧。在 `EXTENSION_WAIT` 和 `ACK_WAIT`,服务端保留解析上下文,
按已选协议版本继续处理后续帧。

## 状态与回退

- `ESTABLISHED`:业务数据走 RDMA/UBSHM,TCP 保留为控制连接。服务端
完成最终 ACK 解析并退出 TCP 解析循环后启动高速接收;额外 TCP 数据触发连接错误。
- `FALLBACK_TCP`:释放升级资源后以 release 顺序发布终态,事件线程以
acquire 顺序读取并继续处理已缓存及后续的 TCP 业务数据。
- `FAILED`:握手 I/O 错误或畸形帧导致失败,清理资源并关闭连接。

完整帧按边界消费;分片输入返回 `NOT_ENOUGH_DATA` 等待补齐,
与握手 magic 不匹配的前缀返回 `TRY_OTHERS`。

## 协议兼容

- RDMA 保持 v2/v3 wire format 和协议数值 ID `1`。公共握手使用枚举
`PROTOCOL_TRANSPORT_HANDSHAKE`,注册名称为 `transport_handshake`。
- UBSHM 使用 64 字节 v3 hello、4 字节网络序格式扩展和 4 字节 ACK。
IPC 后端选择 `IPC_V2`,UBS 后端选择 `LEGACY_64`;格式相同则升级,否则
回退 TCP。资源映射使用对端共享内存长度,数据面激活前发布协商格式。

## 测试

覆盖分片与粘连输入、magic 分流、版本与格式校验、TCP 回退、资源释放、
终态发布、最终 ACK 与首包并发,以及 RDMA 和 UBSHM 回归测试。
2 changes: 1 addition & 1 deletion src/brpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ set(PROTO_FILES brpc/builtin_service.proto
brpc/policy/public_pbrpc_meta.proto
brpc/policy/sofa_pbrpc_meta.proto
brpc/proto_base.proto
brpc/rdma/rdma_handshake.proto
brpc/rdma_handshake.proto
brpc/rpc_dump.proto
brpc/rtmp.proto
brpc/span.proto
Expand Down
Loading
Loading