wwbmmm commented on code in PR #1958:
URL: https://github.com/apache/incubator-brpc/pull/1958#discussion_r1000095385


##########
src/brpc/stream_impl.h:
##########
@@ -114,6 +114,7 @@ friend class MessageBatcher;
     bthread_mutex_t _congestion_control_mutex;
     size_t _produced;
     size_t _remote_consumed;
+    size_t _cur_max_buf_size;

Review Comment:
   有了min_buf_size和max_buf_size,这个叫_cur_buf_size是不是更合理。



##########
src/brpc/stream.cpp:
##########
@@ -284,21 +291,43 @@ int Stream::AppendIfNotFull(const butil::IOBuf &data) {
         _produced -= data.length();
         return -1;
     }
+    if (FLAGS_socket_max_streams_unconsumed_bytes > 0) {
+        _host_socket->_total_streams_unconsumed_size += data.length();
+    }
     return 0;
 }
 
 void Stream::SetRemoteConsumed(size_t new_remote_consumed) {
-    CHECK(_options.max_buf_size > 0);
+    CHECK(_cur_max_buf_size > 0);
     bthread_id_list_t tmplist;
     bthread_id_list_init(&tmplist, 0, 0);
     bthread_mutex_lock(&_congestion_control_mutex);
     if (_remote_consumed >= new_remote_consumed) {
         bthread_mutex_unlock(&_congestion_control_mutex);
         return;
     }
-    const bool was_full = _produced >= _remote_consumed + 
(size_t)_options.max_buf_size;
+    const bool was_full = _produced >= _remote_consumed + 
(size_t)_cur_max_buf_size;
+
+    if (FLAGS_socket_max_streams_unconsumed_bytes > 0) {
+        _host_socket->_total_streams_unconsumed_size -= new_remote_consumed - 
_remote_consumed;
+        if (_host_socket->_total_streams_unconsumed_size <= 
FLAGS_socket_max_streams_unconsumed_bytes) {

Review Comment:
   条件是不是写反了,这里应该是 > ?



##########
src/brpc/stream.cpp:
##########
@@ -72,6 +74,11 @@ int Stream::Create(const StreamOptions &options,
     s->_connected = false;
     s->_options = options;
     s->_closed = false;
+    s->_cur_max_buf_size = options.max_buf_size;
+    if (FLAGS_socket_max_streams_unconsumed_bytes > 0 && options.min_buf_size 
> 0) {

Review Comment:
   需要判断 min_buf_size < max_buf_size吧,否则是无效配置
   



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