Copilot commented on code in PR #3480:
URL: https://github.com/apache/brpc/pull/3480#discussion_r3844392057


##########
src/brpc/input_messenger.cpp:
##########
@@ -369,7 +369,14 @@ void InputMessenger::OnNewMessages(Socket* m) {
         if (messenger->ProcessNewMessage(m, nr, read_eof, received_us,
                                          base_realtime, last_msg) < 0) {
             return;
-        } 
+        }
+        // If the transport switched its edge trigger during parsing (e.g.,
+        // RDMA handshake completed and edge trigger changed to
+        // OnNewDataFromTcp), stop reading to avoid racing with the new
+        // edge trigger handler on _read_buf.
+        if (m->_transport->ShouldStopReading()) {
+            return;
+        }

Review Comment:
   Returning early when ShouldStopReading() is true skips the normal 
EAGAIN/MoreReadEvents path that resets Socket::_nevent back to 0. If _nevent 
remains non-zero, subsequent EPOLLIN events will not schedule another OnEdge 
handler (Socket::OnInputEvent only schedules when fetch_add returns 0), so the 
new edge trigger (e.g. OnNewDataFromTcp) may never run and input events/EOF can 
be missed. Reset _nevent via MoreReadEvents() before returning.



-- 
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]

Reply via email to