From 7af5d3b84aeaa84a2979c24db9db5ed5a43cea2d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 29 May 2019 14:24:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=97=E8=8A=82=E5=AF=B9?= =?UTF-8?q?=E9=BD=90=E5=AF=BC=E8=87=B4=E5=86=85=E5=AD=98=E6=9C=AA=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cpp/protoutils.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cpp/protoutils.cc b/cpp/protoutils.cc index 59d8a9e..90b0cea 100644 --- a/cpp/protoutils.cc +++ b/cpp/protoutils.cc @@ -197,18 +197,19 @@ namespace f8 int packlen = msg.ByteSize(); assert(packlen < 1024 * 60); - char* buff = (char*)malloc(sizeof(WSProxyPackHead_S) + packlen); + char* buff = (char*)malloc(sizeof(WSProxyPackHead_C) + packlen); + memset(buff, 0, sizeof(WSProxyPackHead_C)); WSProxyPackHead_C* head = (WSProxyPackHead_C*)buff; head->packlen = packlen; head->msgid = msgid; head->seqid = 0; head->magic_code = MAGIC_CODE; - #if 0 - head->rpc_error_code = 0; - #endif + head->ip_saddr = 0; head->socket_handle = socket_handle; - msg.SerializeToArray(buff + sizeof(WSProxyPackHead_C), packlen); + if (packlen > 0) { + msg.SerializeToArray(buff + sizeof(WSProxyPackHead_C), packlen); + } tcp_client->SendBuff(buff, sizeof(WSProxyPackHead_C) + packlen); free(buff); return sizeof(WSProxyPackHead_C) + packlen;