From 6e46c77f6c09787bb9a47c17ac73e937ed6ba4f0 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 14 Sep 2020 11:36:17 +0000 Subject: [PATCH 1/4] TD-1326 --- src/plugins/http/inc/httpInt.h | 2 +- src/plugins/http/inc/httpSql.h | 6 +++--- src/plugins/http/src/httpGcHandle.c | 2 +- src/plugins/http/src/httpGcJson.c | 26 +++++++++++++------------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/plugins/http/inc/httpInt.h b/src/plugins/http/inc/httpInt.h index 4fae4e74c9..36a022159f 100644 --- a/src/plugins/http/inc/httpInt.h +++ b/src/plugins/http/inc/httpInt.h @@ -36,7 +36,7 @@ #define HTTP_BUFFER_SIZE 8388608 #define HTTP_STEP_SIZE 4096 //http message get process step by step #define HTTP_METHOD_SCANNER_SIZE 7 //http method fp size -#define TSDB_CODE_HTTP_GC_TARGET_SIZE 512 +#define HTTP_GC_TARGET_SIZE 512 #define HTTP_WRITE_RETRY_TIMES 500 #define HTTP_WRITE_WAIT_TIME_MS 5 #define HTTP_SESSION_ID_LEN (TSDB_USER_LEN + TSDB_PASSWORD_LEN) diff --git a/src/plugins/http/inc/httpSql.h b/src/plugins/http/inc/httpSql.h index 660a65e44d..db3e3a3b16 100644 --- a/src/plugins/http/inc/httpSql.h +++ b/src/plugins/http/inc/httpSql.h @@ -29,10 +29,10 @@ void httpFreeMultiCmds(HttpContext *pContext); HttpSqlCmd *httpNewSqlCmd(HttpContext *pContext); HttpSqlCmd *httpCurrSqlCmd(HttpContext *pContext); -int32_t httpCurSqlCmdPos(HttpContext *pContext); +int32_t httpCurSqlCmdPos(HttpContext *pContext); -void httpTrimTableName(char *name); +void httpTrimTableName(char *name); int32_t httpShrinkTableName(HttpContext *pContext, int32_t pos, char *name); -char *httpGetCmdsString(HttpContext *pContext, int32_t pos); +char * httpGetCmdsString(HttpContext *pContext, int32_t pos); #endif diff --git a/src/plugins/http/src/httpGcHandle.c b/src/plugins/http/src/httpGcHandle.c index 01be301637..5d4cb0c680 100644 --- a/src/plugins/http/src/httpGcHandle.c +++ b/src/plugins/http/src/httpGcHandle.c @@ -228,7 +228,7 @@ bool gcProcessQueryRequest(HttpContext* pContext) { cmd->values = refIdBuffer; cmd->table = aliasBuffer; cmd->numOfRows = 0; // hack way as target flags - cmd->timestamp = httpAddToSqlCmdBufferWithSize(pContext, TSDB_CODE_HTTP_GC_TARGET_SIZE + 1); // hack way + cmd->timestamp = httpAddToSqlCmdBufferWithSize(pContext, HTTP_GC_TARGET_SIZE + 1); // hack way if (cmd->timestamp == -1) { httpWarn("context:%p, fd:%d, user:%s, cant't malloc target size, sql buffer is full", pContext, pContext->fd, diff --git a/src/plugins/http/src/httpGcJson.c b/src/plugins/http/src/httpGcJson.c index e864d54ac0..a291641dc3 100644 --- a/src/plugins/http/src/httpGcJson.c +++ b/src/plugins/http/src/httpGcJson.c @@ -129,48 +129,48 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, // for group by if (groupFields != -1) { - char target[TSDB_CODE_HTTP_GC_TARGET_SIZE] = {0}; + char target[HTTP_GC_TARGET_SIZE] = {0}; int32_t len; - len = snprintf(target,TSDB_CODE_HTTP_GC_TARGET_SIZE,"%s{",aliasBuffer); + len = snprintf(target,HTTP_GC_TARGET_SIZE,"%s{",aliasBuffer); for (int32_t i = dataFields + 1; i Date: Mon, 14 Sep 2020 22:23:50 +0800 Subject: [PATCH 2/4] TD-1291 --- src/plugins/http/src/httpServer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c index 0dfdee32da..2d95a0ac72 100644 --- a/src/plugins/http/src/httpServer.c +++ b/src/plugins/http/src/httpServer.c @@ -308,7 +308,11 @@ static bool httpReadData(HttpContext *pContext) { httpInitParser(pParser); } - ASSERT(!pParser->parsed); + if (pParser->parsed) { + httpDebug("context:%p, fd:%d, not in ready state, parsed:%d", pContext, pContext->fd, pParser->parsed); + return false; + } + pContext->accessTimes++; pContext->lastAccessTime = taosGetTimestampSec(); From 95457415469356deb3c7bad6bb9d4ab9032e46b8 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 14 Sep 2020 23:38:00 +0800 Subject: [PATCH 3/4] TD-1291 --- tests/test/c/CMakeLists.txt | 14 ++++++++++++-- tests/test/c/httpTest.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 tests/test/c/httpTest.c diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index e1fedaee3c..5339203ec2 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -5,6 +5,12 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/mnode/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/tsdb/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/plugins/http/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) +INCLUDE_DIRECTORIES(${TD_ENTERPRISE_DIR}/src/inc) IF (TD_LINUX) #add_executable(insertPerTable insertPerTable.c) @@ -28,6 +34,10 @@ IF (TD_LINUX) #add_executable(createNormalTable createNormalTable.c) #target_link_libraries(createNormalTable taos_static tutil common pthread) - add_executable(queryPerformance queryPerformance.c) - target_link_libraries(queryPerformance taos_static tutil common pthread) + #add_executable(queryPerformance queryPerformance.c) + #target_link_libraries(queryPerformance taos_static tutil common pthread) + + add_executable(httpTest httpTest.c) + target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) ENDIF() + diff --git a/tests/test/c/httpTest.c b/tests/test/c/httpTest.c new file mode 100644 index 0000000000..dd6d9e4cf8 --- /dev/null +++ b/tests/test/c/httpTest.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "os.h" +#include "os.h" +#include "tglobal.h" +#include "taoserror.h" +#include "httpSystem.h" + +int main(int argc, char *argv[]) { + // Initialize the system + if (httpInitSystem() < 0) { + exit(EXIT_FAILURE); + } + + if (httpStartSystem() < 0) { + exit(EXIT_FAILURE); + } + + while (1) { + sleep(1000); + } +} From c8cf0720826ec08293c0f2162ddcccbe03bee314 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 14 Sep 2020 23:52:02 +0800 Subject: [PATCH 4/4] minor changes --- tests/test/c/httpTest.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test/c/httpTest.c b/tests/test/c/httpTest.c index dd6d9e4cf8..261546770e 100644 --- a/tests/test/c/httpTest.c +++ b/tests/test/c/httpTest.c @@ -19,7 +19,20 @@ #include "taoserror.h" #include "httpSystem.h" +void signal_handler(int signum) { + httpStopSystem(); + httpCleanUpSystem(); + exit(EXIT_SUCCESS); +} + int main(int argc, char *argv[]) { + struct sigaction act; + act.sa_handler = signal_handler; + sigaction(SIGTERM, &act, NULL); + sigaction(SIGHUP, &act, NULL); + sigaction(SIGINT, &act, NULL); + sigaction(SIGABRT, &act, NULL); + // Initialize the system if (httpInitSystem() < 0) { exit(EXIT_FAILURE);