refact(tools): add nettest codes
This commit is contained in:
parent
337a065e3a
commit
780561bc9b
|
@ -71,7 +71,7 @@ static void shellWorkAsClient() {
|
||||||
printf("response is received, size:%d\n", rpcMsg.contLen);
|
printf("response is received, size:%d\n", rpcMsg.contLen);
|
||||||
if (rpcRsp.code == 0) totalSucc++;
|
if (rpcRsp.code == 0) totalSucc++;
|
||||||
} else {
|
} else {
|
||||||
printf("response not received since %s\n", terrstr());
|
printf("response not received since %s\n", tstrerror(rpcRsp.code));
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcFreeCont(rpcRsp.pCont);
|
rpcFreeCont(rpcRsp.pCont);
|
||||||
|
@ -96,7 +96,7 @@ _OVER:
|
||||||
static void shellProcessMsg(void *p, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
static void shellProcessMsg(void *p, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
printf("request is received, size:%d\n", pRpc->contLen);
|
printf("request is received, size:%d\n", pRpc->contLen);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = 0};
|
SRpcMsg rsp = {.handle = pRpc->handle, .refId = pRpc->refId, .ahandle = pRpc->ahandle, .code = 0};
|
||||||
rsp.pCont = rpcMallocCont(shell.args.pktLen);
|
rsp.pCont = rpcMallocCont(shell.args.pktLen);
|
||||||
rsp.contLen = shell.args.pktLen;
|
rsp.contLen = shell.args.pktLen;
|
||||||
rpcSendResponse(&rsp);
|
rpcSendResponse(&rsp);
|
||||||
|
@ -107,6 +107,10 @@ void shellNettestHandler(int32_t signum, void *sigInfo, void *context) { shellEx
|
||||||
static void shellWorkAsServer() {
|
static void shellWorkAsServer() {
|
||||||
SShellArgs *pArgs = &shell.args;
|
SShellArgs *pArgs = &shell.args;
|
||||||
|
|
||||||
|
if (pArgs->port == 0) {
|
||||||
|
pArgs->port = tsServerPort;
|
||||||
|
}
|
||||||
|
|
||||||
SRpcInit rpcInit = {0};
|
SRpcInit rpcInit = {0};
|
||||||
rpcInit.localPort = pArgs->port;
|
rpcInit.localPort = pArgs->port;
|
||||||
rpcInit.label = "CHK";
|
rpcInit.label = "CHK";
|
||||||
|
@ -119,16 +123,11 @@ static void shellWorkAsServer() {
|
||||||
void *serverRpc = rpcOpen(&rpcInit);
|
void *serverRpc = rpcOpen(&rpcInit);
|
||||||
if (serverRpc == NULL) {
|
if (serverRpc == NULL) {
|
||||||
printf("failed to init net test server since %s", terrstr());
|
printf("failed to init net test server since %s", terrstr());
|
||||||
|
} else {
|
||||||
|
printf("network test server is initialized, port:%u\n", pArgs->port);
|
||||||
|
taosSetSignal(SIGTERM, shellNettestHandler);
|
||||||
|
while (1) taosMsleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pArgs->port == 0) {
|
|
||||||
pArgs->port = tsServerPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("network test server is initialized, port:%u\n", pArgs->port);
|
|
||||||
|
|
||||||
taosSetSignal(SIGTERM, shellNettestHandler);
|
|
||||||
while (1) taosMsleep(10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void shellTestNetWork() {
|
void shellTestNetWork() {
|
||||||
|
|
Loading…
Reference in New Issue