提交 d47b358b 编写于 作者: M Minglei Jin

[TD-3909]<fix>: [http/race] fix singleCmd race issue

上级 ec79d6a7
...@@ -25,7 +25,7 @@ const char *httpContextStateStr(HttpContextState state); ...@@ -25,7 +25,7 @@ const char *httpContextStateStr(HttpContextState state);
HttpContext *httpCreateContext(SOCKET fd); HttpContext *httpCreateContext(SOCKET fd);
bool httpInitContext(HttpContext *pContext); bool httpInitContext(HttpContext *pContext);
HttpContext *httpGetContext(void * pContext); HttpContext *httpGetContext(void * pContext);
void httpReleaseContext(HttpContext *pContext, bool clearRes); void httpReleaseContext(HttpContext *pContext/*, bool clearRes*/);
void httpCloseContextByServer(HttpContext *pContext); void httpCloseContextByServer(HttpContext *pContext);
void httpCloseContextByApp(HttpContext *pContext); void httpCloseContextByApp(HttpContext *pContext);
void httpNotifyContextClose(HttpContext *pContext); void httpNotifyContextClose(HttpContext *pContext);
......
...@@ -146,20 +146,20 @@ HttpContext *httpGetContext(void *ptr) { ...@@ -146,20 +146,20 @@ HttpContext *httpGetContext(void *ptr) {
return NULL; return NULL;
} }
void httpReleaseContext(HttpContext *pContext, bool clearRes) { void httpReleaseContext(HttpContext *pContext/*, bool clearRes*/) {
int32_t refCount = atomic_sub_fetch_32(&pContext->refCount, 1); int32_t refCount = atomic_sub_fetch_32(&pContext->refCount, 1);
if (refCount < 0) { if (refCount < 0) {
httpError("context:%p, is already released, refCount:%d", pContext, refCount); httpError("context:%p, is already released, refCount:%d", pContext, refCount);
return; return;
} }
/*
if (clearRes) { if (clearRes) {
if (pContext->parser) { if (pContext->parser) {
httpClearParser(pContext->parser); httpClearParser(pContext->parser);
} }
memset(&pContext->singleCmd, 0, sizeof(HttpSqlCmd)); memset(&pContext->singleCmd, 0, sizeof(HttpSqlCmd));
} }
*/
HttpContext **ppContext = pContext->ppContext; HttpContext **ppContext = pContext->ppContext;
httpTrace("context:%p, is released, data:%p refCount:%d", pContext, ppContext, refCount); httpTrace("context:%p, is released, data:%p refCount:%d", pContext, ppContext, refCount);
...@@ -217,7 +217,7 @@ void httpCloseContextByApp(HttpContext *pContext) { ...@@ -217,7 +217,7 @@ void httpCloseContextByApp(HttpContext *pContext) {
httpContextStateStr(pContext->state), pContext->state); httpContextStateStr(pContext->state), pContext->state);
} }
httpReleaseContext(pContext, true); httpReleaseContext(pContext/*, true*/);
} }
void httpCloseContextByServer(HttpContext *pContext) { void httpCloseContextByServer(HttpContext *pContext) {
...@@ -235,5 +235,5 @@ void httpCloseContextByServer(HttpContext *pContext) { ...@@ -235,5 +235,5 @@ void httpCloseContextByServer(HttpContext *pContext) {
pContext->parsed = false; pContext->parsed = false;
httpRemoveContextFromEpoll(pContext); httpRemoveContextFromEpoll(pContext);
httpReleaseContext(pContext, true); httpReleaseContext(pContext/*, true*/);
} }
...@@ -177,7 +177,7 @@ static void httpProcessHttpData(void *param) { ...@@ -177,7 +177,7 @@ static void httpProcessHttpData(void *param) {
if (!httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_READY)) { if (!httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_READY)) {
httpDebug("context:%p, fd:%d, state:%s, not in ready state, ignore read events", pContext, pContext->fd, httpDebug("context:%p, fd:%d, state:%s, not in ready state, ignore read events", pContext, pContext->fd,
httpContextStateStr(pContext->state)); httpContextStateStr(pContext->state));
httpReleaseContext(pContext, true); httpReleaseContext(pContext/*, true*/);
continue; continue;
} }
...@@ -191,7 +191,7 @@ static void httpProcessHttpData(void *param) { ...@@ -191,7 +191,7 @@ static void httpProcessHttpData(void *param) {
(*(pThread->processData))(pContext); (*(pThread->processData))(pContext);
atomic_fetch_add_32(&pServer->requestNum, 1); atomic_fetch_add_32(&pServer->requestNum, 1);
} else { } else {
httpReleaseContext(pContext, false); httpReleaseContext(pContext/*, false*/);
} }
} }
} }
...@@ -275,7 +275,7 @@ static void *httpAcceptHttpConnection(void *arg) { ...@@ -275,7 +275,7 @@ static void *httpAcceptHttpConnection(void *arg) {
httpError("context:%p, fd:%d, ip:%s, thread:%s, failed to add http fd for epoll, error:%s", pContext, connFd, httpError("context:%p, fd:%d, ip:%s, thread:%s, failed to add http fd for epoll, error:%s", pContext, connFd,
pContext->ipstr, pThread->label, strerror(errno)); pContext->ipstr, pThread->label, strerror(errno));
taosCloseSocket(pContext->fd); taosCloseSocket(pContext->fd);
httpReleaseContext(pContext, true); httpReleaseContext(pContext/*, true*/);
continue; continue;
} }
......
...@@ -376,6 +376,8 @@ void httpExecCmd(HttpContext *pContext) { ...@@ -376,6 +376,8 @@ void httpExecCmd(HttpContext *pContext) {
httpCloseContextByApp(pContext); httpCloseContextByApp(pContext);
break; break;
} }
memset(&pContext->singleCmd, 0, sizeof(HttpSqlCmd));
} }
void httpProcessRequestCb(void *param, TAOS_RES *result, int32_t code) { void httpProcessRequestCb(void *param, TAOS_RES *result, int32_t code) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册