Skip to content

style(ubshm): use BAIDU macros, BAIDU_SCOPED_LOCK and butil::atomic - #57

Merged
zchuango merged 1 commit into
LinQuickDev:ubshm_transport_fix_2from
Sherlock0203:ubshm_transport_fix_2
Sep 24, 2026
Merged

zchuango merged 1 commit into
LinQuickDev:ubshm_transport_fix_2from
Sherlock0203:ubshm_transport_fix_2

Conversation

@Sherlock0203

Copy link
Copy Markdown

No description provided.

Make the whole ubring shared-memory module follow the current brpc
conventions, addressing review feedback:

- Replace the module-local LIKELY/UNLIKELY aliases with BAIDU_LIKELY/
  BAIDU_UNLIKELY and drop the aliases from common.h.
- Use BAIDU_SCOPED_LOCK instead of the local GNU cleanup-attribute
  LOCK_GUARD. The pthread_mutex_t members keep their type, allocation
  and lifetime, so no static-init or placement-new change is needed.
- Use butil::atomic instead of std::atomic. The timer handle slots and
  the trx cleanup slot are now real butil::atomic objects, so plain
  storage is never reinterpreted as an atomic: the timer API takes
  butil::atomic<UbrTimerId>* and UbrTrx/UbrCleanupCtl hold atomic
  handles. UbrTrx slots are value-initialized with placement new so
  those atomics are constructed, replacing the per-acquisition memset.
- Drop the two per-node INFO logs on the shm cleanup retry path in
  UbsShmCallback; DeleteShmToList still records each drained node.

No behavioral change: the removed aliases expanded 1:1, BAIDU_SCOPED_LOCK
locks the same pthread_mutex_t, butil::atomic is layout-identical to
std::atomic, and placement-new value-initialization zeroes exactly what
memset zeroed while also constructing the atomic members.
@zchuango
zchuango merged commit 7e0dd01 into LinQuickDev:ubshm_transport_fix_2 Sep 24, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants