commit
71a467f838
|
@ -957,17 +957,6 @@ static void doInitGlobalConfig(void) {
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
taosInitConfigOption(cfg);
|
taosInitConfigOption(cfg);
|
||||||
|
|
||||||
// http configs
|
|
||||||
cfg.option = "httpCacheSessions";
|
|
||||||
cfg.ptr = &tsHttpCacheSessions;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
|
|
||||||
cfg.minValue = 1;
|
|
||||||
cfg.maxValue = 100000;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosInitConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "httpEnableRecordSql";
|
cfg.option = "httpEnableRecordSql";
|
||||||
cfg.ptr = &tsHttpEnableRecordSql;
|
cfg.ptr = &tsHttpEnableRecordSql;
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
||||||
|
|
|
@ -131,8 +131,6 @@ HttpContext *httpCreateContext(int32_t fd) {
|
||||||
HttpContext *httpGetContext(void *ptr) {
|
HttpContext *httpGetContext(void *ptr) {
|
||||||
uint64_t handleVal = (uint64_t)ptr;
|
uint64_t handleVal = (uint64_t)ptr;
|
||||||
HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &handleVal, sizeof(HttpContext *));
|
HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &handleVal, sizeof(HttpContext *));
|
||||||
ASSERT(ppContext);
|
|
||||||
ASSERT(*ppContext);
|
|
||||||
|
|
||||||
if (ppContext) {
|
if (ppContext) {
|
||||||
HttpContext *pContext = *ppContext;
|
HttpContext *pContext = *ppContext;
|
||||||
|
|
|
@ -87,15 +87,12 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
|
||||||
JsonBuf *jsonBuf = httpMallocJsonBuf(pContext);
|
JsonBuf *jsonBuf = httpMallocJsonBuf(pContext);
|
||||||
if (jsonBuf == NULL) return false;
|
if (jsonBuf == NULL) return false;
|
||||||
|
|
||||||
cmd->numOfRows += numOfRows;
|
|
||||||
|
|
||||||
int32_t num_fields = taos_num_fields(result);
|
int32_t num_fields = taos_num_fields(result);
|
||||||
TAOS_FIELD *fields = taos_fetch_fields(result);
|
TAOS_FIELD *fields = taos_fetch_fields(result);
|
||||||
|
|
||||||
for (int32_t k = 0; k < numOfRows; ++k) {
|
for (int32_t k = 0; k < numOfRows; ++k) {
|
||||||
TAOS_ROW row = taos_fetch_row(result);
|
TAOS_ROW row = taos_fetch_row(result);
|
||||||
if (row == NULL) {
|
if (row == NULL) {
|
||||||
cmd->numOfRows--;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int32_t* length = taos_fetch_lengths(result);
|
int32_t* length = taos_fetch_lengths(result);
|
||||||
|
@ -152,23 +149,22 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
|
||||||
|
|
||||||
// data row array end
|
// data row array end
|
||||||
httpJsonToken(jsonBuf, JsonArrEnd);
|
httpJsonToken(jsonBuf, JsonArrEnd);
|
||||||
}
|
cmd->numOfRows ++;
|
||||||
|
|
||||||
if (cmd->numOfRows >= tsRestRowLimit) {
|
|
||||||
httpDebug("context:%p, fd:%d, user:%s, retrieve rows:%d larger than limit:%d, abort retrieve", pContext,
|
|
||||||
pContext->fd, pContext->user, cmd->numOfRows, tsRestRowLimit);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (pContext->fd <= 0) {
|
if (pContext->fd <= 0) {
|
||||||
httpError("context:%p, fd:%d, user:%s, connection is closed, abort retrieve", pContext, pContext->fd,
|
httpError("context:%p, fd:%d, user:%s, conn closed, abort retrieve", pContext, pContext->fd, pContext->user);
|
||||||
pContext->user);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd->numOfRows >= tsRestRowLimit) {
|
||||||
|
httpDebug("context:%p, fd:%d, user:%s, retrieve rows:%d larger than limit:%d, abort retrieve", pContext,
|
||||||
|
pContext->fd, pContext->user, cmd->numOfRows, tsRestRowLimit);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
httpDebug("context:%p, fd:%d, user:%s, total rows:%d retrieved", pContext, pContext->fd, pContext->user,
|
|
||||||
cmd->numOfRows);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
httpDebug("context:%p, fd:%d, user:%s, retrieved row:%d", pContext, pContext->fd, pContext->user, cmd->numOfRows);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool restBuildSqlTimestampJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, int32_t numOfRows) {
|
bool restBuildSqlTimestampJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, int32_t numOfRows) {
|
||||||
|
|
|
@ -315,45 +315,48 @@ static bool httpReadData(HttpContext *pContext) {
|
||||||
|
|
||||||
pContext->accessTimes++;
|
pContext->accessTimes++;
|
||||||
pContext->lastAccessTime = taosGetTimestampSec();
|
pContext->lastAccessTime = taosGetTimestampSec();
|
||||||
|
char buf[HTTP_STEP_SIZE + 1] = {0};
|
||||||
|
|
||||||
char buf[HTTP_STEP_SIZE + 1] = {0};
|
while (1) {
|
||||||
int32_t nread = (int32_t)taosReadSocket(pContext->fd, buf, HTTP_STEP_SIZE);
|
int32_t nread = (int32_t)taosReadSocket(pContext->fd, buf, HTTP_STEP_SIZE);
|
||||||
if (nread > 0) {
|
if (nread > 0) {
|
||||||
buf[nread] = '\0';
|
buf[nread] = '\0';
|
||||||
httpTraceL("context:%p, fd:%d, nread:%d content:%s", pContext, pContext->fd, nread, buf);
|
httpTraceL("context:%p, fd:%d, nread:%d content:%s", pContext, pContext->fd, nread, buf);
|
||||||
int32_t ok = httpParseBuf(pParser, buf, nread);
|
int32_t ok = httpParseBuf(pParser, buf, nread);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
httpError("context:%p, fd:%d, parse failed, ret:%d code:%d close connect", pContext, pContext->fd, ok, pParser->parseCode);
|
httpError("context:%p, fd:%d, parse failed, ret:%d code:%d close connect", pContext, pContext->fd, ok,
|
||||||
httpSendErrorResp(pContext, pParser->parseCode);
|
pParser->parseCode);
|
||||||
httpNotifyContextClose(pContext);
|
httpSendErrorResp(pContext, pParser->parseCode);
|
||||||
return false;
|
httpNotifyContextClose(pContext);
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (pParser->parseCode) {
|
if (pParser->parseCode) {
|
||||||
httpError("context:%p, fd:%d, parse failed, code:%d close connect", pContext, pContext->fd, pParser->parseCode);
|
httpError("context:%p, fd:%d, parse failed, code:%d close connect", pContext, pContext->fd, pParser->parseCode);
|
||||||
httpSendErrorResp(pContext, pParser->parseCode);
|
httpSendErrorResp(pContext, pParser->parseCode);
|
||||||
httpNotifyContextClose(pContext);
|
httpNotifyContextClose(pContext);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pParser->parsed) {
|
if (!pParser->parsed) {
|
||||||
httpTrace("context:%p, fd:%d, read not over yet, len:%d", pContext, pContext->fd, pParser->body.pos);
|
httpTrace("context:%p, fd:%d, read not finished", pContext, pContext->fd);
|
||||||
return false;
|
continue;
|
||||||
|
} else {
|
||||||
|
httpDebug("context:%p, fd:%d, bodyLen:%d", pContext, pContext->fd, pParser->body.pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (nread < 0) {
|
||||||
|
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
|
httpDebug("context:%p, fd:%d, read from socket error:%d, wait another event", pContext, pContext->fd, errno);
|
||||||
|
return false; // later again
|
||||||
|
} else {
|
||||||
|
httpError("context:%p, fd:%d, read from socket error:%d, close connect", pContext, pContext->fd, errno);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
httpDebug("context:%p, fd:%d, totalLen:%d", pContext, pContext->fd, pParser->body.pos);
|
httpError("context:%p, fd:%d, nread:%d, wait another event", pContext, pContext->fd, nread);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (nread < 0) {
|
|
||||||
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
|
|
||||||
httpDebug("context:%p, fd:%d, read from socket error:%d, wait another event", pContext, pContext->fd, errno);
|
|
||||||
return false; // later again
|
|
||||||
} else {
|
|
||||||
httpError("context:%p, fd:%d, read from socket error:%d, close connect", pContext, pContext->fd, errno);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
httpError("context:%p, fd:%d, nread:%d, wait another event", pContext, pContext->fd, nread);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,7 +433,7 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
|
||||||
|
|
||||||
va_list argpointer;
|
va_list argpointer;
|
||||||
char buffer[MAX_LOGLINE_DUMP_BUFFER_SIZE];
|
char buffer[MAX_LOGLINE_DUMP_BUFFER_SIZE];
|
||||||
int32_t len;
|
int32_t len;
|
||||||
struct tm Tm, *ptm;
|
struct tm Tm, *ptm;
|
||||||
struct timeval timeSecs;
|
struct timeval timeSecs;
|
||||||
time_t curTime;
|
time_t curTime;
|
||||||
|
|
Loading…
Reference in New Issue