chenBright commented on code in PR #3163:
URL: https://github.com/apache/brpc/pull/3163#discussion_r2573055777


##########
src/brpc/controller.cpp:
##########
@@ -1027,6 +1092,54 @@ void Controller::SubmitSpan() {
     _span = NULL;
 }
 
+void Controller::HandleIdleProgressiveReader(void* arg) {
+    if(arg == nullptr){
+        LOG(ERROR) << "Controller::HandleIdleProgressiveReader arg is null.";
+        return;
+    }
+    auto* cntl = static_cast<Controller*>(arg);
+    auto log_idle = FLAGS_log_idle_progressive_read_close;
+    int64_t progressive_read_timeout_us = cntl->_progressive_read_timeout_ms * 
1000;
+    std::vector<SocketId> remove_socket_ids;
+    butil::AutoLock guard(cntl->_progressive_read_lock);
+    auto socketIds = cntl->_checking_progressive_read_fds;
+    for (auto socket_id :  socketIds){
+        SocketUniquePtr s;
+        if (Socket::Address(socket_id, &s) == 0) {
+            int64_t pre_idle_duration_us = 0;
+            int64_t idle_duration_us = butil::cpuwide_time_us() - 
s->last_active_time_us();
+            while (progressive_read_timeout_us > idle_duration_us && 
idle_duration_us > pre_idle_duration_us) {
+                auto sleep_ms = (progressive_read_timeout_us - 
idle_duration_us) / 1000;
+                bthread_usleep(sleep_ms > 0 ? sleep_ms : 1);
+                pre_idle_duration_us = idle_duration_us;
+                idle_duration_us = butil::cpuwide_time_us() - 
s->last_active_time_us();
+            }
+            if (idle_duration_us <= pre_idle_duration_us) {
+                LOG_IF(INFO, log_idle) << "stop pgressive read timeout 
checking process!"
+                << " progressive_read_timeout_us : " << 
progressive_read_timeout_us
+                << " idle_duration_us : " << idle_duration_us
+                << " pre_idle_duration_us : " << pre_idle_duration_us;
+                return;
+            }
+            LOG_IF(INFO, log_idle) << "progressive read timeout socket id : " 
<< socket_id
+            << " progressive read timeout us : " << progressive_read_timeout_us
+            << " progressive read idle duration : " << idle_duration_us;
+            if (s->parsing_context() != NULL) {
+                s->parsing_context()->Destroy();
+            }
+            s->ReleaseReferenceIfIdle(0);

Review Comment:
   Does the user get a timeout error in OnEndOfMessage?



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