90 Commits

Author SHA1 Message Date
Chuang Zhang 72bf13a395 Interconnecting with the UBShmTransport Based on the LD/ST Shared Memory Semantics. (#3290)
* add ubring transport

* fix the  bug for ub ring transport

* fix the  bug for ub ring transport and other

* add the license for ub transport

* Modifying the variable naming style

* optimize the log message and some field name

* fix some bug for ubring

* add some log ubring endpoint

* add todo

* fix the bug for handshake for ub endpoint

* fix the bug for client ub endpoint

* optimize the iobuf file code

* modify the log level

* fix the declare_shm_ubs define not found bug

* add the timer_mgr support for macos and format code style

* fix the bug for macos epoll

* fix the timespece bug

* adaptor the itimerspec for macos platform

* optimize the cmakelist config

* add the ubring docs for ubring transport

* modify some file name and directory structure

* modify some code style and optimize code logical

* add the cmake ubshm transport ci/testing

* add the dependency header

* bug fix the code

* Fix UB shm allocation cleanup crashes (#11)

Co-authored-by: 郭业昌 <lvpengfei@MacBook-Air.local>

* remove the brpc_ubshm_unittest

* Found and fixed two stability issues (#13)

* 修复ubring server端关闭连接coredump问题

* 修复PollIn/PollOut解引用已释放Socket指针的问题

PollIn/PollOut通过ep->_socket(裸指针)读取data socket,当data socket
被销毁时该指针悬空,导致Socket::Address读到垃圾id触发SIGSEGV。
改为存储_socket_id(SocketId),用Address获取引用计数的Socket,
并在整个回调期间持有该引用,避免解引用悬空指针。

* 修复client非正常退出导致UBRING shm残留的问题

client被强杀(SIGTERM/崩溃/OOM)时teardown没跑完,localShm(_C)的
shm_unlink未执行,导致/dev/shm残留_C文件。server的remoteShm只munmap
不unlink(正确),无法清理client的名字。

在握手ESTABLISHED时(client/server都确认对方已mmap自己的localShm)
立即unlink localShm名字。此时对端已持有mmap引用,unlink只删名字不
影响通信;进程任意时刻退出都不会残留文件名。

* Address chenBright's review: use English comments and BAIDU_CACHELINE_ALIGNMENT

- Convert all Chinese comments in ubshm to English (per chenBright's
  'Please use English' on ub_endpoint.cpp:723, ub_ring.cpp:337,
  shm_ubs.cpp:316, and similar)
- Replace __attribute__((aligned(64))) with BAIDU_CACHELINE_ALIGNMENT
  in ubr_msg.h (per chenBright's comment on ubr_msg.h:41)
- Remove unnecessary TODO comment in ub_ring.cpp:551 (per chenBright's
  'Unnecessary comments, please delete')

* Remove unused lock macros in thread_lock.h

Per chenBright's review, the functions and macros defined in
thread_lock.h are largely unused. Verified usage across ubshm:
- LOCK_GUARD / UnlockMutex: 8 call sites in shm_ubs.cpp and
  ub_ring_manager.cpp, kept.
- SPIN_LOCK_GUARD, R_LOCK_GUARD, W_LOCK_GUARD, SEMAPHORE_WAIT_GUARD,
  SEMAPHORE_WAIT_GUARD_WITH_CLOSE and their helper functions
  (UnlockSpinLock, UnlockRWLock, PostSem, PostSemWithClose): 0 call
  sites, removed.

* Apply chenBright's review on timer_mgr globals

Per chenBright's review on timer_mgr.cpp:32-37:
- Add explicit default values to uninitialized globals
  (g_total_timer_num=0, g_max_system_fd=0, g_epoll_execute_thread=0,
  g_timer_module_initialized=0)
- Rename globals to snake_case (g_epollFd -> g_epoll_fd,
  g_totalTimerNum -> g_total_timer_num, g_timerFdCtxMap ->
  g_timer_fd_ctx_map, maxSystemFd -> g_max_system_fd,
  g_epollExecuteThread -> g_epoll_execute_thread,
  g_timerModuleInitialized -> g_timer_module_initialized)
- maxSystemFd also gains the g_ prefix to match global naming style

Also fix the missing std:: qualifier on atomic_fetch_sub/add/load
(per chenBright's earlier comment on timer_mgr.cpp:80).

* Change CloseTimerFd fd type from uint32_t to int

Per chenBright's review on timer_mgr.cpp:399 (uint32_t -> int).
fd is a system file descriptor; POSIX APIs use int and -1 denotes an
invalid fd, which uint32_t cannot represent. Changed the CloseTimerFd
signature (header + definition) and removed the now-unnecessary
(uint32_t) casts at the two call sites.

* Use BAIDU_LIKELY/BAIDU_UNLIKELY instead of custom __builtin_expect

Per chenBright's review on common.h:27. Rather than redefine the
macros with __builtin_expect directly, forward LIKELY/UNLIKELY to
brpc's standard BAIDU_LIKELY/BAIDU_UNLIKELY (from butil/compiler_specific.h).
The 122 call sites keep using LIKELY()/UNLIKELY() unchanged; only the
macro bodies change, preserving semantics.

* Add unit tests for UBShmEndpoint

Per chenBright's request to add unit tests for UBShmTransport in this
PR (rather than a follow-up).

Adds test/brpc_ubring_unittest.cpp with tests covering the public
interface of UBShmEndpoint under the g_skip_ub_init=true mode (which
skips real shared-memory/poller setup):
- construct_and_destruct: lifecycle safety
- is_writable_false_when_skip_init: skip-mode behavior
- reset_is_idempotent: Reset() is safe to call repeatedly

The file follows the brpc_*_unittest.cpp naming convention so it is
auto-collected by test/CMakeLists.txt's file(GLOB). Verified: compiles,
links, and all 3 tests pass (g++ 15.2, C++17, gtest, BRPC_WITH_UBRING=ON).

* Rewrite UBShmEndpoint unit tests with real coverage

Per chenBright's feedback that the previous tests were too simple and
did not cover the main methods.

Source changes to enable testing:
- Move HelloMessage struct declaration from ub_endpoint.cpp to
  ub_endpoint.h so tests can access it
- Expose private members under #ifdef UNIT_TEST (precedent:
  butil/containers/stack_container.h) so tests can call
  AllocateClientResources without -Dprivate=public (which breaks
  GCC 15 + new libstdc++ <any>/<sstream>)

Tests (9, all passing on Ubuntu 26.04 g++ 15.2 C++17 gtest):
HelloMessageTest (5): serialize/deserialize roundtrip, network byte
order verification, uint64 max boundary, full shm_name, toString
UBShmEndpointTest (4): construct, real IPC shm
AllocateClientResources (g_skip_ub_init=false), reset cleanup, reset
idempotency

* rename the variable to snake_case style

---------

Co-authored-by: YeChang Guo <52730608+YChange01@users.noreply.github.com>
Co-authored-by: 郭业昌 <lvpengfei@MacBook-Air.local>
Co-authored-by: gure <740684863@qq.com>
2026-07-19 13:02:08 +08:00
darion-yaphet be01d1047c docs(readme): update READMEs and add English doc placeholders (#3263)
- Fix outdated Travis CI badge in README_cn.md to GitHub Actions
- Unify all doc links in README.md to point to docs/en/ directory
- Add references for bthread tracer, coroutine, circuit breaker, RDMA, Bazel support
- Create 39 English placeholder docs pointing to Chinese versions
- Create Chinese placeholder for couchbase_example
2026-04-08 20:01:58 +08:00
Bright Chen 31d604e278 Fix bRPC case (#2509) 2024-01-17 10:09:50 +08:00
DevanshKyada27 ad67ffd8cf Fixed the typo error (#2434)
Fixes #2433 

Fixed the typo error in readme file.

Looking forward for merging the PR.
2023-11-10 16:40:55 +08:00
Sean e7d75c60d6 Update logo in readme (#2402) 2023-10-25 14:29:53 +08:00
Bright Chen 629fabb80e Opt README doc for rdma (#2312) 2023-07-13 10:32:29 +08:00
Xiaoyao Zhao 435b5120cb update h2 link in README and README_cn (#2212) 2023-04-18 12:29:20 +08:00
Xiaofeng Wang 0eb6a79f28 update project links (#2200)
- brpc/brpc -> apache/brpc
2023-04-11 09:48:46 +08:00
Mahesh Rijal af4dcf82a7 Update README.md
Add hyperlink to https://brpc.apache.org/
2023-02-11 13:14:26 +05:30
Weibing Wang 6b563554f2 Remove incubator (#2056) 2023-01-10 10:33:14 +08:00
0xflotus fedea96b79 fix: small typo (#2050)
Did you mean `introduction`?
2022-12-21 12:53:03 +08:00
果冻虾仁 9cdced4fb5 Add Action Badge and Remove Travis file (#2023) 2022-11-28 13:17:51 +01:00
Weibing Wang fae30e6a9a Update README.md 2022-11-17 14:39:08 +08:00
Tanzhongyi(Jerry Tan) 6495704589 update readme to add link to coc (#1564)
* update readme to add link to coc

* update gnp edit command options
2022-08-09 11:00:52 +08:00
serverglen 946d29b65c Update README.md 2022-08-08 19:19:34 +08:00
Tanzhongyi(Jerry Tan) 1bafe4b294 Update README.md 2022-08-04 08:19:04 +08:00
jamesge 31eba304a9 change travis-ci.org to travis-ci.com 2020-11-30 12:29:20 +08:00
jamesge 8a68acd3d2 update logo and readme 2020-08-27 11:04:41 +08:00
zhujiashun 7d55c5ef5d update_mail_list 2019-10-25 18:36:40 +08:00
jamesge 8534fe84de remove exec bit from README files 2019-10-07 23:14:15 -07:00
zhujiashun c564742180 fix travis-ci link after transfering to apache 2019-03-05 22:12:03 +08:00
gejun bd502a725a Move contribution related info into contributing.md 2018-10-09 17:49:20 +08:00
Ge Jun 2d496fa5b5 rename grpc to gRPC 2018-09-30 10:00:23 +01:00
Ge Jun dd499b664f fix links to grpc section according to github 2018-09-30 09:50:14 +01:00
Ge Jun 0553fe9aa2 Change the grpc link on README 2018-09-30 09:48:27 +01:00
Ge Jun 23dbd69342 Add h2/grpc docs 2018-09-30 09:46:22 +01:00
Ge Jun b4d54c3ddc translate docs on AutoConcurrencyLimiter in server.md to English 2018-08-21 16:25:17 +08:00
Ge Jun ce16cdf2da add entries of auto_concurrency_limiter.md on README 2018-08-21 00:59:58 -07:00
Ge Jun 60761edd45 point links on streaming services to brpc/media-server 2018-08-20 23:58:16 -07:00
Ge Jun d864ccabd8 config_brpc.sh only uses realpath in macosx 2018-07-03 23:42:47 -07:00
Ge Jun a1692d9aed more docs on naming service 2018-07-04 13:55:14 +08:00
Ge Jun 8b3ee09e05 change the chinese translation of 'naming service' 2018-07-04 11:47:49 +08:00
Ge Jun f184cbc757 Polish thrift related docs 2018-05-24 00:10:35 -07:00
Ge Jun 74c55ed937 Update README.md 2018-05-24 15:08:03 +08:00
Ge Jun 324a0a28f9 Add entries for thrift in Client/Server sections 2018-05-24 15:06:55 +08:00
wangxuefeng 8f8f0bf145 Fix as comments 2018-05-22 07:26:25 +00:00
wangxuefeng 7d128b98ea Fix typo 2018-05-14 07:08:44 +00:00
wangxuefeng 4803a6837c Add thrift documents 2018-05-14 07:01:56 +00:00
Ge Jun 18014aedae Update README.md 2018-05-09 21:24:06 +08:00
old-bear 8de65ffeb7 + Update PPTs 2018-04-24 10:11:25 +08:00
gejun 26a0df8413 Add tutorial_on_building_services.pptx 2018-03-08 13:50:19 +08:00
gejun dfd372e2b8 fix some links in README.md 2018-03-07 11:31:07 +08:00
gejun 560bc30042 rephrase more docs 2018-03-07 11:27:14 +08:00
gejun d461ff7f82 updated README 2018-01-20 15:32:38 +08:00
gejun e16247dc67 minor change to README 2018-01-15 20:15:01 +08:00
gejun c9c974c1b6 change some numbers in docs 2018-01-15 20:07:10 +08:00
gejun 56523eb9a5 highlight some sections in README 2018-01-15 14:37:54 +08:00
Ge Jun 9c3b3fb74e Change rule for contributing code 2018-01-15 14:25:10 +08:00
gejun f2f5114318 fix links to performance in readme 2017-12-06 22:19:37 +08:00
gejun 22dd4b2d4e add requirement for indentation 2017-12-06 22:15:37 +08:00