未验证 提交 7a465a3a 编写于 作者: M Minglei Jin 提交者: GitHub

Merge pull request #10011 from taosdata/fix/TS-487-2.4

[TS-487]<fix>: fixed udp partial message chaos
...@@ -186,9 +186,11 @@ static void *taosRecvUdpData(void *param) { ...@@ -186,9 +186,11 @@ static void *taosRecvUdpData(void *param) {
SUdpConn *pConn = param; SUdpConn *pConn = param;
struct sockaddr_in sourceAdd; struct sockaddr_in sourceAdd;
ssize_t dataLen; ssize_t dataLen;
int32_t msgLen;
unsigned int addLen; unsigned int addLen;
uint16_t port; uint16_t port;
SRecvInfo recvInfo; SRecvInfo recvInfo;
SRpcHead *pHead;
memset(&sourceAdd, 0, sizeof(sourceAdd)); memset(&sourceAdd, 0, sizeof(sourceAdd));
addLen = sizeof(sourceAdd); addLen = sizeof(sourceAdd);
...@@ -218,6 +220,13 @@ static void *taosRecvUdpData(void *param) { ...@@ -218,6 +220,13 @@ static void *taosRecvUdpData(void *param) {
continue; continue;
} }
pHead = (SRpcHead *)msg;
msgLen = (int32_t)htonl((uint32_t)pHead->msgLen);
if (dataLen < msgLen) {
tError("%s recvfrom failed(%s): dataLen: %ld, msgLen: %d", pConn->label, strerror(errno), (long)dataLen, msgLen);
continue;
}
int32_t size = dataLen + tsRpcOverhead; int32_t size = dataLen + tsRpcOverhead;
char *tmsg = malloc(size); char *tmsg = malloc(size);
if (NULL == tmsg) { if (NULL == tmsg) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册