From c755056d75a69c48a3148260b99cf468570500e6 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Thu, 6 Aug 2020 10:58:01 +0800 Subject: [PATCH] [TD-1076] --- src/kit/taosnetwork/client.c | 29 ++++++++++++++++++++++++++--- src/kit/taosnetwork/server.c | 4 ++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/kit/taosnetwork/client.c b/src/kit/taosnetwork/client.c index a4fc26f22f..26e292a1be 100644 --- a/src/kit/taosnetwork/client.c +++ b/src/kit/taosnetwork/client.c @@ -28,7 +28,7 @@ #include #include -#define MAX_PKG_LEN (16*1000) +#define MAX_PKG_LEN (64*1000) #define BUFFER_SIZE (MAX_PKG_LEN + 1024) typedef struct { @@ -107,9 +107,32 @@ int checkTcpPort(info_s *info) { send(clientSocket, sendbuf, info->pktLen, 0); - iDataNum = recv(clientSocket, recvbuf, BUFFER_SIZE, 0); + memset(recvbuf, 0, BUFFER_SIZE); + int nleft, nread; + char *ptr = recvbuf; + nleft = info->pktLen; + while (nleft > 0) { + nread = recv(clientSocket, ptr, BUFFER_SIZE, 0);; + + if (nread == 0) { + break; + } else if (nread < 0) { + if (errno == EINTR) { + continue; + } else { + printf("recv ack pkg from TCP port: %d fail:%s.\n", port, strerror(errno)); + close(clientSocket); + return -1; + } + } else { + nleft -= nread; + ptr += nread; + iDataNum += nread; + } + } + if (iDataNum < info->pktLen) { - printf("Read ack pkg len: %d, less than req pkg len: %d from tcp port: %d\n", iDataNum, info->pktLen, port); + printf("recv ack pkg len: %d, less than req pkg len: %d from tcp port: %d\n", iDataNum, info->pktLen, port); return -1; } //printf("Read ack pkg len:%d from tcp port: %d, buffer: %s %s\n", info->pktLen, port, recvbuf, recvbuf+iDataNum-8); diff --git a/src/kit/taosnetwork/server.c b/src/kit/taosnetwork/server.c index 18565edb3f..b18fbde46e 100644 --- a/src/kit/taosnetwork/server.c +++ b/src/kit/taosnetwork/server.c @@ -29,7 +29,7 @@ #include #include -#define MAX_PKG_LEN (16*1000) +#define MAX_PKG_LEN (64*1000) #define BUFFER_SIZE (MAX_PKG_LEN + 1024) typedef struct { @@ -119,7 +119,7 @@ static void *bindTcpPort(void *sarg) { char *ptr = buffer; nleft = pinfo->pktLen; while (nleft > 0) { - nread = recv(client, buffer, BUFFER_SIZE, 0); + nread = recv(client, ptr, BUFFER_SIZE, 0); if (nread == 0) { break; -- GitLab