chenBright commented on code in PR #3163:
URL: https://github.com/apache/brpc/pull/3163#discussion_r2596130044
##########
src/brpc/controller.cpp:
##########
@@ -1028,6 +1118,44 @@ void Controller::SubmitSpan() {
_span = NULL;
}
+void Controller::HandleIdleProgressiveReader(void* arg) {
+ if(arg == nullptr){
+ LOG(ERROR) << "Controller::HandleIdleProgressiveReader arg is null.";
+ return;
+ }
+ ProgressiveTimeoutReader* reader =
static_cast<ProgressiveTimeoutReader*>(arg);
+ SocketUniquePtr s;
+ if (Socket::Address(reader->GetSocketId(), &s) != 0) {
+ LOG(ERROR) << "not found the socket id : " << reader->GetSocketId();
+ return;
+ }
+ auto log_idle = FLAGS_log_idle_progressive_read_close;
+ int64_t progressive_read_timeout_us = reader->read_timeout_ms() * 1000;
+ 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 progressive 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;
+ }
+ reader->set_read_timeout();
Review Comment:
This issue deserves attention.
--
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]