add http test

This commit is contained in:
yihaoDeng 2023-11-23 13:59:42 +08:00
parent 321ef1c758
commit 50922427ff
1 changed files with 8 additions and 7 deletions

View File

@ -198,7 +198,7 @@ static void httpAsyncCb(uv_async_t* handle) {
queue wq; queue wq;
QUEUE_INIT(&wq); QUEUE_INIT(&wq);
static int32_t BACTHSIZE = 20; static int32_t BACTHSIZE = 5;
int32_t count = 0; int32_t count = 0;
taosThreadMutexLock(&item->mtx); taosThreadMutexLock(&item->mtx);
@ -372,13 +372,14 @@ static bool httpFailFastShoudIgnoreMsg(SHashObj* pTable, char* server, int16_t p
char buf[256] = {0}; char buf[256] = {0};
sprintf(buf, "%s:%d", server, port); sprintf(buf, "%s:%d", server, port);
int64_t* failedTime = (int64_t*)taosHashGet(pTable, buf, strlen(buf)); int32_t* failedTime = (int32_t*)taosHashGet(pTable, buf, strlen(buf));
if (failedTime == NULL) { if (failedTime == NULL) {
return false; return false;
} }
int32_t now = taosGetTimestampSec();
int64_t now = taosGetTimestampSec(); tError("failed timestamp %d, curr timestamp:%d", *failedTime, now);
if (now - *failedTime < 60) { if (*failedTime > now - 60) {
tError("http-report succ to ignore msg,reason:connection timed out, dst:%s", buf); tError("http-report succ to ignore msg,reason:connection timed out, dst:%s", buf);
return true; return true;
} else { } else {
@ -392,7 +393,7 @@ static void httpFailFastMayUpdate(SHashObj* pTable, char* server, int16_t port,
if (succ) { if (succ) {
taosHashRemove(pTable, buf, strlen(buf)); taosHashRemove(pTable, buf, strlen(buf));
} else { } else {
int64_t st = taosGetTimestampSec(); int32_t st = taosGetTimestampSec();
taosHashPut(pTable, buf, strlen(buf), &st, sizeof(st)); taosHashPut(pTable, buf, strlen(buf), &st, sizeof(st));
} }
return; return;
@ -452,11 +453,11 @@ static void httpHandleReq(SHttpMsg* msg) {
uv_tcp_init(http->loop, &cli->tcp); uv_tcp_init(http->loop, &cli->tcp);
// set up timeout to avoid stuck; // set up timeout to avoid stuck;
int32_t fd = taosCreateSocketWithTimeout(5); int32_t fd = taosCreateSocketWithTimeout(3000);
if (fd < 0) { if (fd < 0) {
tError("http-report failed to open socket, dst:%s:%d", cli->addr, cli->port); tError("http-report failed to open socket, dst:%s:%d", cli->addr, cli->port);
taosReleaseRef(httpRefMgt, httpRef);
destroyHttpClient(cli); destroyHttpClient(cli);
taosReleaseRef(httpRefMgt, httpRef);
return; return;
} }
int ret = uv_tcp_open((uv_tcp_t*)&cli->tcp, fd); int ret = uv_tcp_open((uv_tcp_t*)&cli->tcp, fd);