wwbmmm commented on code in PR #3163:
URL: https://github.com/apache/brpc/pull/3163#discussion_r2584451583
##########
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);
Review Comment:
maybe you can save some status to the member of ProgressiveTimeoutReader,
reset the bthread_timer and return here.
--
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]