Skip to content

Conversation

@zchuango
Copy link

@zchuango zchuango commented Nov 25, 2025

What problem does this PR solve?

Issue Number: resolve #3133

Problem Summary: when Controller response_will_be_read_progressively() it needs background bthread monitor handler to solve progressive reader idle timeout,when hit the progressive reader idle timeout duration should close current client socket connection.

What is changed and the side effects?

Changed:

  1. add HandleIdleProgressiveReader method will run in and when controller call response_will_be_read_progressively method will trigger HandleIdleProgressiveReader monitor idle progressive reader on bthread_timer.
  2. add progressive idle case on http_c++ example http_server with enable_progressive_timeout arg to trigger ProgressiveAttachment write timeout and http_client with progressive and progressive_read_timeout_ms args test the progressive reader idle timeout case.

Side effects:

Performance effects: NO

Breaking backward compatibility: NO


Check List:

@wwbmmm
Copy link
Contributor

wwbmmm commented Nov 25, 2025

Hi @zchuang185 Thank you for you contribution! I have left some comments, but I think the biggest problem is that this solution is too heavy and too intrusive to Controller. Is there any other solution? For example, after rpc success, set a bthread_timer with progressive_read_timeout_ms and check the Socket when timeout?

@zchuango
Copy link
Author

@wwbmmm I've added ProgressiveTimeoutRead which is a ProgressiveReader wrapper class, when OnReadPart is invoked, it sets up a bthread_timer to monitor the idle timeout for the progressive socket reader. ProgressiveTimeoutRead is only activated when progressive_read_timeout_ms has been explicitly configured.

<< " pre_idle_duration_us : " << pre_idle_duration_us;
return;
}
reader->set_read_timeout();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a thread safety issue here. The process will crash if the reader has already been destructed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue deserves attention.

* change the timeout checker bthread to timer bthread

* refine ProgressiveReadTimeoutReader class hold SocketId and read_timeout_ms fields

* refine socektId access method, change HandleIdleProgressiveReader belong and logic
}
add_flag(FLAGS_PROGRESSIVE_READER);
if (progressive_read_timeout_ms() > 0) {
auto reader = new ProgressiveTimeoutReader(_rpa->GetSocketId(), _progressive_read_timeout_ms, r);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that _current_call.peer_id can be used instead of GetSocketId.

* change the timeout checker bthread to timer bthread

* refine ProgressiveReadTimeoutReader class hold SocketId and read_timeout_ms fields

* refine socektId access method, change HandleIdleProgressiveReader belong and logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

brpc持续下载,设置每一段超时

3 participants