Copilot commented on code in PR #3471:
URL: https://github.com/apache/brpc/pull/3471#discussion_r3835084359
##########
src/brpc/ubshm/ub_endpoint.cpp:
##########
@@ -840,40 +839,39 @@ int UBShmEndpoint::PollingModeInitialize(bthread_tag_t
tag,
std::unique_ptr<FnArgs> args(static_cast<FnArgs*>(p));
auto poller = args->poller;
auto running = args->running;
- std::unordered_set<CqSidOp, CqSidOpHash, CqSidOpEqual> cq_sids;
- CqSidOp op;
+ std::unordered_set<PollerSidOp, PollerSidOpHash, PollerSidOpEqual>
poller_sids;
+ PollerSidOp op;
if (poller->init_fn) {
poller->init_fn();
}
while (running->load(std::memory_order_relaxed)) {
while (poller->op_queue.Dequeue(op)) {
- if (op.type == CqSidOp::ADD) {
- cq_sids.emplace(op);
- } else if (op.type == CqSidOp::REMOVE) {
- cq_sids.erase(op);
-
- } else if (op.type == CqSidOp::MOD) {
- cq_sids.erase(op);
- cq_sids.emplace(op);
+ if (op.type == PollerSidOp::ADD) {
+ poller_sids.emplace(op);
+ } else if (op.type == PollerSidOp::REMOVE) {
Review Comment:
`poller_sids` is an `unordered_set<PollerSidOp>` where hash/equality only
consider `sid` (see `PollerSidOpEqual`). As a result, `poller_sids.emplace(op)`
is a no-op when the same `sid` is already present, so an `ADD` op cannot update
the stored `events` mask (e.g., adding `EPOLLOUT` after an initial `EPOLLIN`
registration). This can prevent `PollOut` from being called and cause waits for
writability to time out unnecessarily.
##########
src/brpc/ubshm/ub_ring.cpp:
##########
@@ -127,9 +130,10 @@ RETURN_CODE UBRing::UbrAddCloseTimer() {
return UBRING_ERR;
}
- uint32_t event_q_timer_interval = FLAGS_ub_event_queue_timer_interval *
TIME_COVERSION;
+ const uint32_t event_q_timer_interval_ns =
+ FLAGS_ub_event_queue_timer_interval_us * USEC_TO_NSEC;
itimerspec time_spec = {
- .it_interval = {.tv_sec = 0, .tv_nsec = event_q_timer_interval},
+ .it_interval = {.tv_sec = 0, .tv_nsec = event_q_timer_interval_ns},
.it_value = {.tv_sec = 0, .tv_nsec = 1}
Review Comment:
`it_interval.tv_nsec` is set to `FLAGS_ub_event_queue_timer_interval_us *
USEC_TO_NSEC` without normalizing into seconds/nanoseconds. If the flag is >=
1,000,000 (>=1s), `tv_nsec` will be >= 1e9 and `timerfd_settime()` will fail
with `EINVAL`, breaking the close-check timer for valid configurations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]