From 35fc91f9824a30655a6cf42ad7d462993034a16a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 1 Jun 2019 16:18:56 +0800 Subject: [PATCH] add ext_len --- cpp/protoutils.cc | 9 +++------ cpp/protoutils.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cpp/protoutils.cc b/cpp/protoutils.cc index 90b0cea..eb7a224 100644 --- a/cpp/protoutils.cc +++ b/cpp/protoutils.cc @@ -81,7 +81,6 @@ namespace f8 ::google::protobuf::Message& msg) { int packlen = msg.ByteSize(); - assert(packlen < 1024 * 60); char* buff = (char*)malloc(sizeof(PackHead) + packlen); PackHead* head = (PackHead*)buff; @@ -89,7 +88,7 @@ namespace f8 head->msgid = msgid; head->seqid = seqid; head->magic_code = MAGIC_CODE; - head->rpc_error_code = 0; + head->ext_len = packlen >> 16; msg.SerializeToArray(buff + sizeof(PackHead), packlen); tcp_client->SendBuff(buff, sizeof(PackHead) + packlen); free(buff); @@ -119,7 +118,6 @@ namespace f8 unsigned short msgid, ::google::protobuf::Message& msg) { int packlen = msg.ByteSize(); - assert(packlen < 1024 * 60); char* buff = (char*)malloc(sizeof(PackHead) + packlen); PackHead* head = (PackHead*)buff; @@ -127,7 +125,7 @@ namespace f8 head->msgid = msgid; head->seqid = seqid; head->magic_code = MAGIC_CODE; - head->rpc_error_code = 0; + head->rpc_ext_len = packlen >> 16; msg.SerializeToArray(buff + sizeof(PackHead), packlen); tcp_listener->SendClientMsg(socket_handle, buff, sizeof(PackHead) + packlen); free(buff); @@ -157,7 +155,6 @@ namespace f8 unsigned short msgid, ::google::protobuf::Message& msg) { int packlen = msg.ByteSize(); - assert(packlen < 1024 * 60); char* buff = (char*)malloc(sizeof(PackHead) + packlen); PackHead* head = (PackHead*)buff; @@ -165,7 +162,7 @@ namespace f8 head->msgid = msgid; head->seqid = seqid; head->magic_code = MAGIC_CODE; - head->rpc_error_code = 0; + head->ext_len = packlen >> 16; msg.SerializeToArray(buff + sizeof(PackHead), packlen); tcp_listener->BroadcastMsg(buff, sizeof(PackHead) + packlen); free(buff); diff --git a/cpp/protoutils.h b/cpp/protoutils.h index 6795432..2264d6c 100644 --- a/cpp/protoutils.h +++ b/cpp/protoutils.h @@ -24,7 +24,7 @@ namespace f8 unsigned short msgid; unsigned int seqid; unsigned short magic_code; - unsigned short rpc_error_code; + unsigned short ext_len; }; //大包消息头部