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


##########
src/brpc/policy/baidu_rpc_protocol.cpp:
##########
@@ -62,36 +65,101 @@ DEFINE_bool(baidu_std_protocol_deliver_timeout_ms, false,
 DECLARE_bool(pb_enum_as_number);
 
 // Notes:
-// 1. 12-byte header [PRPC][body_size][meta_size]
+// 1. Header format:
+//    - Normal format (12 bytes): [PRPC][body_size(32bit)][meta_size(32bit)]
+//    - Extended format (20 bytes): 
[PRPC][UINT32_MAX][meta_size(32bit)][body_size(64bit)]
+//      Extended format is used when body_size > UINT32_MAX
 // 2. body_size and meta_size are in network byte order
 // 3. Use service->full_name() + method_name to specify the method to call
 // 4. `attachment_size' is set iff request/response has attachment
 // 5. Not supported: chunk_info
 
+// Helper function to get attachment size from RpcMeta, with backward 
compatibility
+static int64_t GetAttachmentSize(const RpcMeta& meta) {
+    if (meta.has_attachment_size_long()) {
+        return meta.attachment_size_long();
+    }
+    if (meta.has_attachment_size()) {
+        return static_cast<int64_t>(meta.attachment_size());
+    }
+    return 0;
+}
+
+// Helper function to set attachment size in RpcMeta, with backward 
compatibility
+static void SetAttachmentSize(RpcMeta* meta, size_t size) {
+    const size_t INT32_MAX_VALUE = static_cast<size_t>(INT32_MAX);
+    if (size > INT32_MAX_VALUE) {
+        meta->set_attachment_size_long(static_cast<int64_t>(size));
+    } else {
+        meta->set_attachment_size(static_cast<int32_t>(size));
+    }
+}
+
+// Helper function to get attachment size from RpcDumpMeta, with backward 
compatibility
+// Marked unused to avoid -Werror-unused-function when not referenced.
+static __attribute__((unused)) int64_t GetAttachmentSizeFromDump(const 
RpcDumpMeta& meta) {

Review Comment:
   Please use ALLOW_UNUSED instead of __attribute__((unused)).



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