brpc icon indicating copy to clipboard operation
brpc copied to clipboard

Support progressive read timeout bthread handler

Open zchuango opened this issue 1 month ago • 2 comments

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:

zchuango avatar Nov 25 '25 02:11 zchuango

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?

wwbmmm avatar Nov 25 '25 08:11 wwbmmm

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

zchuango avatar Nov 28 '25 11:11 zchuango