Copilot commented on code in PR #3712:
URL: https://github.com/apache/brpc/pull/3712#discussion_r4692583464
##########
src/brpc/urma/mock_urma.cpp:
##########
@@ -697,13 +702,13 @@ urma_status_t urma_rearm_jfc(urma_jfc_t*, bool) {
int urma_wait_jfc(urma_jfce_t* jfce, uint32_t jfc_cnt, int,
urma_jfc_t* jfcs[]) {
- if (!jfce || !jfcs || jfc_cnt == 0) {
+ std::shared_lock<std::shared_mutex> lock(g_rw_mutex);
+ if (!jfce || !jfcs || jfc_cnt == 0 || jfce_map.count(jfce) == 0) {
errno = EINVAL;
return -1;
}
Review Comment:
This global `g_rw_mutex` is held across `read(jfce->fd, ...)` immediately
below. A JFCE descriptor is an I/O wait point and the provider API does not
establish that it is always nonblocking; if the read waits (or a readiness
event is consumed by another thread first), teardown and every other mock URMA
operation are blocked because they need the writer lock. Keep the lock only
while validating/copying the handle, perform the read without the global lock,
and reacquire it before walking the JFC maps (or otherwise make the wait
explicitly nonblocking).
--
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]