Aaaaaaron commented on code in PR #1947:
URL: https://github.com/apache/incubator-brpc/pull/1947#discussion_r993247562


##########
src/brpc/stream.cpp:
##########
@@ -140,20 +141,30 @@ ssize_t Stream::CutMessageIntoFileDescriptor(int /*fd*/,
         errno = EBADF;
         return -1;
     }
-    butil::IOBuf out;
     ssize_t len = 0;
     for (size_t i = 0; i < size; ++i) {
+      butil::IOBuf *data = data_list[i];
+      size_t length = data->length();
+      uint64_t trans_unit = FLAGS_max_trans_unit_size;
+      int packet_num = ceil((double)length / (double)trans_unit);
+
+      butil::IOBuf split_data;
+      for (int j = 0; j < packet_num; j++) {
+        butil::IOBuf out;
+        data->cutn(&split_data, trans_unit);
+        bool has_continuation = (j != packet_num - 1);
         StreamFrameMeta fm;
         fm.set_stream_id(_remote_settings.stream_id());
         fm.set_source_stream_id(id());
         fm.set_frame_type(FRAME_TYPE_DATA);
-        // TODO: split large data
-        fm.set_has_continuation(false);
-        policy::PackStreamMessage(&out, fm, data_list[i]);
-        len += data_list[i]->length();
-        data_list[i]->clear();
+        fm.set_has_continuation(has_continuation);
+        policy::PackStreamMessage(&out, fm, &split_data);
+        WriteToHostSocket(&out);

Review Comment:
   这里是指如果消息没有达到 max_stream_data_frame_size, 就还是和之前一样放到最后统一 write 吗



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