未验证 提交 33fd458d 编写于 作者: M Minglei Jin 提交者: GitHub

Merge pull request #9995 from taosdata/fix/TS-487

[TS-487]<fix>(rpc): fix 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);
...@@ -216,6 +218,13 @@ static void *taosRecvUdpData(void *param) { ...@@ -216,6 +218,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) {
......
...@@ -51,7 +51,7 @@ sleep 1000 ...@@ -51,7 +51,7 @@ sleep 1000
sql connect sql connect
sleep 1000 sleep 1000
sql create dnode $hostname2 sql create dnode $hostname2
sleep 1000 sleep 2000
print ============== step2: create database with replica 2, and create table, insert data print ============== step2: create database with replica 2, and create table, insert data
$totalTableNum = 10 $totalTableNum = 10
...@@ -268,4 +268,4 @@ system sh/exec.sh -n dnode4 -s stop -x SIGINT ...@@ -268,4 +268,4 @@ system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT system sh/exec.sh -n dnode5 -s stop -x SIGINT
system sh/exec.sh -n dnode6 -s stop -x SIGINT system sh/exec.sh -n dnode6 -s stop -x SIGINT
system sh/exec.sh -n dnode7 -s stop -x SIGINT system sh/exec.sh -n dnode7 -s stop -x SIGINT
system sh/exec.sh -n dnode8 -s stop -x SIGINT system sh/exec.sh -n dnode8 -s stop -x SIGINT
\ No newline at end of file
...@@ -51,7 +51,7 @@ sleep 1000 ...@@ -51,7 +51,7 @@ sleep 1000
sql connect sql connect
sleep 1000 sleep 1000
sql create dnode $hostname2 sql create dnode $hostname2
sleep 1000 sleep 2000
print ============== step2: create database with replica 2, and create table, insert data print ============== step2: create database with replica 2, and create table, insert data
$totalTableNum = 10 $totalTableNum = 10
...@@ -266,4 +266,4 @@ system sh/exec.sh -n dnode4 -s stop -x SIGINT ...@@ -266,4 +266,4 @@ system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT system sh/exec.sh -n dnode5 -s stop -x SIGINT
system sh/exec.sh -n dnode6 -s stop -x SIGINT system sh/exec.sh -n dnode6 -s stop -x SIGINT
system sh/exec.sh -n dnode7 -s stop -x SIGINT system sh/exec.sh -n dnode7 -s stop -x SIGINT
system sh/exec.sh -n dnode8 -s stop -x SIGINT system sh/exec.sh -n dnode8 -s stop -x SIGINT
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册