@@ -1334,28 +1334,49 @@ static void cliBatchSendCb(uv_write_t* req, int status) {
13341334 }
13351335}
13361336bool cliConnMayAddUserInfo (SCliConn * pConn , STransMsgHead * * ppHead , int32_t * msgLen ) {
1337+ int32_t code = 0 ;
13371338 SCliThrd * pThrd = pConn -> hostThrd ;
13381339 STrans * pInst = pThrd -> pInst ;
13391340 if (pConn -> userInited == 1 ) {
13401341 return false;
13411342 }
13421343 STransMsgHead * pHead = * ppHead ;
1343- STransMsgHead * tHead = taosMemoryCalloc (1 , * msgLen + sizeof (pInst -> user ));
1344+ int32_t len = * msgLen ;
1345+ char * oriMsg = NULL ;
1346+ int32_t oriLen = 0 ;
1347+
1348+ if (pHead -> comp == 1 ) {
1349+ int32_t msgLen = htonl (pHead -> msgLen );
1350+ code = transDecompressMsgExt ((char * )(pHead ), msgLen , & oriMsg , & oriLen );
1351+ if (code < 0 ) {
1352+ tError ("failed to decompress since %s" , tstrerror (code ));
1353+ return false;
1354+ } else {
1355+ tDebug ("decompress msg and resent, compress size %d, raw size %d" , msgLen , oriLen );
1356+ }
1357+
1358+ pHead = (STransMsgHead * )oriMsg ;
1359+ len = oriLen ;
1360+ }
1361+ STransMsgHead * tHead = taosMemoryCalloc (1 , len + sizeof (pInst -> user ));
13441362 if (tHead == NULL ) {
13451363 return false;
13461364 }
13471365 memcpy ((char * )tHead , (char * )pHead , TRANS_MSG_OVERHEAD );
13481366 memcpy ((char * )tHead + TRANS_MSG_OVERHEAD , pInst -> user , sizeof (pInst -> user ));
13491367
13501368 memcpy ((char * )tHead + TRANS_MSG_OVERHEAD + sizeof (pInst -> user ), (char * )pHead + TRANS_MSG_OVERHEAD ,
1351- * msgLen - TRANS_MSG_OVERHEAD );
1369+ len - TRANS_MSG_OVERHEAD );
13521370
13531371 tHead -> withUserInfo = 1 ;
13541372 * ppHead = tHead ;
1355- * msgLen += sizeof (pInst -> user );
1373+ * msgLen = len + sizeof (pInst -> user );
13561374
13571375 pConn -> pInitUserReq = tHead ;
13581376 pConn -> userInited = 1 ;
1377+ if (oriMsg != NULL ) {
1378+ taosMemoryFree (oriMsg );
1379+ }
13591380 return true;
13601381}
13611382int32_t cliBatchSend (SCliConn * pConn , int8_t direct ) {
@@ -1421,9 +1442,8 @@ int32_t cliBatchSend(SCliConn* pConn, int8_t direct) {
14211442 pReq -> contLen = 0 ;
14221443 }
14231444
1424- int32_t msgLen = transMsgLenFromCont (pReq -> contLen );
1425-
14261445 STransMsgHead * pHead = transHeadFromCont (pReq -> pCont );
1446+ int32_t msgLen = transMsgLenFromCont (pReq -> contLen );
14271447
14281448 char * content = pReq -> pCont ;
14291449 int32_t contLen = pReq -> contLen ;
0 commit comments