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


##########
tools/rpc_replay/rpc_replay.cpp:
##########
@@ -181,11 +181,23 @@ static void* replay_thread(void* arg) {
                 memcpy(&nshead_req.head, sample->meta.nshead().c_str(), 
sample->meta.nshead().length());
                 nshead_req.body = sample->request;
                 req_ptr = &nshead_req;
-            } else if (sample->meta.attachment_size() > 0) {
-                sample->request.cutn(
-                    &req.serialized_data(),
-                    sample->request.size() - sample->meta.attachment_size());
-                cntl->request_attachment() = sample->request.movable();
+            } else {
+                // Get attachment size with backward compatibility
+                int64_t attachment_size = 0;
+                if (sample->meta.has_attachment_size_long()) {
+                    attachment_size = sample->meta.attachment_size_long();
+                } else if (sample->meta.has_attachment_size()) {
+                    attachment_size = 
static_cast<int64_t>(sample->meta.attachment_size());
+                }
+                if (attachment_size > 0 && 
+                    static_cast<size_t>(attachment_size) < 
sample->request.size()) {
+                    sample->request.cutn(
+                        &req.serialized_data(),
+                        sample->request.size() - 
static_cast<size_t>(attachment_size));
+                    cntl->request_attachment() = sample->request.movable();
+                } else {
+                    req.serialized_data() = sample->request.movable();
+                }
             } else {

Review Comment:
   This else is never reached



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