[TD-6416]<fix>: fixed memory leak and crash bug
This commit is contained in:
parent
e9e5dc22f7
commit
52e92cd3ed
|
@ -60,17 +60,25 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* para
|
||||||
tscDebugL("0x%"PRIx64" SQL: %s", pSql->self, pSql->sqlstr);
|
tscDebugL("0x%"PRIx64" SQL: %s", pSql->self, pSql->sqlstr);
|
||||||
pCmd->resColumnId = TSDB_RES_COL_ID;
|
pCmd->resColumnId = TSDB_RES_COL_ID;
|
||||||
|
|
||||||
|
taosAcquireRef(tscObjRef, pSql->self);
|
||||||
|
|
||||||
int32_t code = tsParseSql(pSql, true);
|
int32_t code = tsParseSql(pSql, true);
|
||||||
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) return;
|
|
||||||
|
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
|
||||||
|
taosReleaseRef(tscObjRef, pSql->self);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pSql->res.code = code;
|
pSql->res.code = code;
|
||||||
tscAsyncResultOnError(pSql);
|
tscAsyncResultOnError(pSql);
|
||||||
|
taosReleaseRef(tscObjRef, pSql->self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd);
|
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd);
|
||||||
executeQuery(pSql, pQueryInfo);
|
executeQuery(pSql, pQueryInfo);
|
||||||
|
taosReleaseRef(tscObjRef, pSql->self);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO return the correct error code to client in tscQueueAsyncError
|
// TODO return the correct error code to client in tscQueueAsyncError
|
||||||
|
|
|
@ -35,6 +35,7 @@ bool httpProcessData(HttpContext* pContext) {
|
||||||
if (!httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_HANDLING)) {
|
if (!httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_HANDLING)) {
|
||||||
httpTrace("context:%p, fd:%d, state:%s not in ready state, stop process request", pContext, pContext->fd,
|
httpTrace("context:%p, fd:%d, state:%s not in ready state, stop process request", pContext, pContext->fd,
|
||||||
httpContextStateStr(pContext->state));
|
httpContextStateStr(pContext->state));
|
||||||
|
pContext->error = true;
|
||||||
httpCloseContextByApp(pContext);
|
httpCloseContextByApp(pContext);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1157,10 +1157,6 @@ static int32_t httpParseChar(HttpParser *parser, const char c, int32_t *again) {
|
||||||
httpOnError(parser, HTTP_CODE_INTERNAL_SERVER_ERROR, TSDB_CODE_HTTP_PARSE_ERROR_STATE);
|
httpOnError(parser, HTTP_CODE_INTERNAL_SERVER_ERROR, TSDB_CODE_HTTP_PARSE_ERROR_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok != 0) {
|
|
||||||
pContext->error = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,8 @@ void httpSendErrorResp(HttpContext *pContext, int32_t errNo) {
|
||||||
httpCode = pContext->parser->httpCode;
|
httpCode = pContext->parser->httpCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pContext->error = true;
|
||||||
|
|
||||||
char *httpCodeStr = httpGetStatusDesc(httpCode);
|
char *httpCodeStr = httpGetStatusDesc(httpCode);
|
||||||
httpSendErrorRespImp(pContext, httpCode, httpCodeStr, errNo & 0XFFFF, tstrerror(errNo));
|
httpSendErrorRespImp(pContext, httpCode, httpCodeStr, errNo & 0XFFFF, tstrerror(errNo));
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,8 +191,6 @@ static void httpProcessHttpData(void *param) {
|
||||||
if (httpReadData(pContext)) {
|
if (httpReadData(pContext)) {
|
||||||
(*(pThread->processData))(pContext);
|
(*(pThread->processData))(pContext);
|
||||||
atomic_fetch_add_32(&pServer->requestNum, 1);
|
atomic_fetch_add_32(&pServer->requestNum, 1);
|
||||||
} else {
|
|
||||||
httpReleaseContext(pContext/*, false*/);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,13 +400,17 @@ static bool httpReadData(HttpContext *pContext) {
|
||||||
} else if (nread < 0) {
|
} else if (nread < 0) {
|
||||||
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
|
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
httpDebug("context:%p, fd:%d, read from socket error:%d, wait another event", pContext, pContext->fd, errno);
|
httpDebug("context:%p, fd:%d, read from socket error:%d, wait another event", pContext, pContext->fd, errno);
|
||||||
return false; // later again
|
continue; // later again
|
||||||
} else {
|
} else {
|
||||||
httpError("context:%p, fd:%d, read from socket error:%d, close connect", pContext, pContext->fd, errno);
|
httpError("context:%p, fd:%d, read from socket error:%d, close connect", pContext, pContext->fd, errno);
|
||||||
|
taosCloseSocket(pContext->fd);
|
||||||
|
httpReleaseContext(pContext/*, false */);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
httpError("context:%p, fd:%d, nread:%d, wait another event", pContext, pContext->fd, nread);
|
httpError("context:%p, fd:%d, nread:%d, wait another event", pContext, pContext->fd, nread);
|
||||||
|
taosCloseSocket(pContext->fd);
|
||||||
|
httpReleaseContext(pContext/*, false */);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,7 +405,6 @@ void httpProcessRequestCb(void *param, TAOS_RES *result, int32_t code) {
|
||||||
|
|
||||||
if (pContext->session == NULL) {
|
if (pContext->session == NULL) {
|
||||||
httpSendErrorResp(pContext, TSDB_CODE_HTTP_SESSION_FULL);
|
httpSendErrorResp(pContext, TSDB_CODE_HTTP_SESSION_FULL);
|
||||||
httpCloseContextByApp(pContext);
|
|
||||||
} else {
|
} else {
|
||||||
httpExecCmd(pContext);
|
httpExecCmd(pContext);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue