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


##########
src/brpc/controller.cpp:
##########
@@ -1542,6 +1660,9 @@ void 
Controller::ReadProgressiveAttachmentBy(ProgressiveReader* r) {
                          __FUNCTION__));
     }
     add_flag(FLAGS_PROGRESSIVE_READER);
+    if (progressive_read_timeout_ms() > 0) {
+        return  _rpa->ReadProgressiveAttachmentBy(new 
ProgressiveTimeoutRead(this, r));

Review Comment:
   I think a more elegant way is to add a virtual GetSocket() function to 
ReadableProgressiveAttachment:
   
   ```cpp
   class ReadableProgressiveAttachment : public SharedObject {
   public:
       virtual Socket* GetSocket() = 0;
   };
   ```
   and then return the socket in HttpContext :
   
   ```
   class HttpContext : public ReadableProgressiveAttachment
                     , public InputMessageBase
                     , public HttpMessage {
   public:
       Socket* GetSocket() { return _socket.get(); }
   };
   ```
   
   then we can just pass the socket and `_progressive_read_timeout_ms` to the 
new `ProgressiveTimeoutRead` here:
   ```
       if (progressive_read_timeout_ms() > 0) {
           return  _rpa->ReadProgressiveAttachmentBy(new 
ProgressiveTimeoutRead(_rpa->GetSocket(), _progressive_read_timeout_ms, r));
       }
   ```
   
   Then we don't need to hold the controller in the `ProgressiveTimeoutRead`, 
and don't need the `_checking_progressive_read_fds` and 
`_progressive_read_lock` any more.



##########
src/brpc/controller.cpp:
##########
@@ -174,6 +175,61 @@ class IgnoreAllRead : public ProgressiveReader {
     void OnEndOfMessage(const butil::Status&) {}
 };
 
+class ProgressiveTimeoutRead : public ProgressiveReader {

Review Comment:
   ProgressiveTimeoutRead -> ProgressiveTimeoutReader



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