fix possible memory lost
This commit is contained in:
parent
fa463c6530
commit
98286acce4
|
@ -59,7 +59,7 @@ int32_t dnodeInitMClient() {
|
||||||
dError("failed to init dnode timer");
|
dError("failed to init dnode timer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dnodeReadMnodeIpList()) {
|
if (!dnodeReadMnodeIpList()) {
|
||||||
memset(&tsMnodeIpList, 0, sizeof(SRpcIpSet));
|
memset(&tsMnodeIpList, 0, sizeof(SRpcIpSet));
|
||||||
memset(&tsMnodeInfos, 0, sizeof(SDMNodeInfos));
|
memset(&tsMnodeInfos, 0, sizeof(SDMNodeInfos));
|
||||||
|
|
|
@ -177,7 +177,6 @@ static int32_t dnodeInitSystem() {
|
||||||
|
|
||||||
static void dnodeCleanUpSystem() {
|
static void dnodeCleanUpSystem() {
|
||||||
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_STOPPED) {
|
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_STOPPED) {
|
||||||
tclearModuleStatus(TSDB_MOD_MGMT);
|
|
||||||
dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_STOPPED);
|
dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_STOPPED);
|
||||||
dnodeCleanupShell();
|
dnodeCleanupShell();
|
||||||
dnodeCleanupMnode();
|
dnodeCleanupMnode();
|
||||||
|
|
|
@ -504,6 +504,7 @@ void *sdbFetchRow(void *handle, void *pNode, void **ppRow) {
|
||||||
|
|
||||||
void *sdbOpenTable(SSdbTableDesc *pDesc) {
|
void *sdbOpenTable(SSdbTableDesc *pDesc) {
|
||||||
SSdbTable *pTable = (SSdbTable *)calloc(1, sizeof(SSdbTable));
|
SSdbTable *pTable = (SSdbTable *)calloc(1, sizeof(SSdbTable));
|
||||||
|
|
||||||
if (pTable == NULL) return NULL;
|
if (pTable == NULL) return NULL;
|
||||||
|
|
||||||
strcpy(pTable->tableName, pDesc->tableName);
|
strcpy(pTable->tableName, pDesc->tableName);
|
||||||
|
@ -557,7 +558,7 @@ void sdbCloseTable(void *handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_destroy(&pTable->mutex);
|
pthread_mutex_destroy(&pTable->mutex);
|
||||||
|
|
||||||
sdbTrace("table:%s, is closed, numOfTables:%d", pTable->tableName, tsSdbNumOfTables);
|
sdbTrace("table:%s, is closed, numOfTables:%d", pTable->tableName, tsSdbNumOfTables);
|
||||||
free(pTable);
|
free(pTable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,7 +270,7 @@ void httpCleanUpConnect(HttpServer *pServer) {
|
||||||
|
|
||||||
for (i = 0; i < pServer->numOfThreads; ++i) {
|
for (i = 0; i < pServer->numOfThreads; ++i) {
|
||||||
pThread = pServer->pThreads + i;
|
pThread = pServer->pThreads + i;
|
||||||
taosCloseSocket(pThread->pollFd);
|
//taosCloseSocket(pThread->pollFd);
|
||||||
|
|
||||||
while (pThread->pHead) {
|
while (pThread->pHead) {
|
||||||
httpCleanUpContext(pThread->pHead, 0);
|
httpCleanUpContext(pThread->pHead, 0);
|
||||||
|
@ -591,7 +591,6 @@ void httpAcceptHttpConnection(void *arg) {
|
||||||
|
|
||||||
bool httpInitConnect(HttpServer *pServer) {
|
bool httpInitConnect(HttpServer *pServer) {
|
||||||
int i;
|
int i;
|
||||||
pthread_attr_t thattr;
|
|
||||||
HttpThread * pThread;
|
HttpThread * pThread;
|
||||||
|
|
||||||
pServer->pThreads = (HttpThread *)malloc(sizeof(HttpThread) * (size_t)pServer->numOfThreads);
|
pServer->pThreads = (HttpThread *)malloc(sizeof(HttpThread) * (size_t)pServer->numOfThreads);
|
||||||
|
@ -601,8 +600,6 @@ bool httpInitConnect(HttpServer *pServer) {
|
||||||
}
|
}
|
||||||
memset(pServer->pThreads, 0, sizeof(HttpThread) * (size_t)pServer->numOfThreads);
|
memset(pServer->pThreads, 0, sizeof(HttpThread) * (size_t)pServer->numOfThreads);
|
||||||
|
|
||||||
pthread_attr_init(&thattr);
|
|
||||||
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
|
|
||||||
pThread = pServer->pThreads;
|
pThread = pServer->pThreads;
|
||||||
for (i = 0; i < pServer->numOfThreads; ++i) {
|
for (i = 0; i < pServer->numOfThreads; ++i) {
|
||||||
sprintf(pThread->label, "%s%d", pServer->label, i);
|
sprintf(pThread->label, "%s%d", pServer->label, i);
|
||||||
|
@ -626,21 +623,27 @@ bool httpInitConnect(HttpServer *pServer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_attr_t thattr;
|
||||||
|
pthread_attr_init(&thattr);
|
||||||
|
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
|
||||||
if (pthread_create(&(pThread->thread), &thattr, (void *)httpProcessHttpData, (void *)(pThread)) != 0) {
|
if (pthread_create(&(pThread->thread), &thattr, (void *)httpProcessHttpData, (void *)(pThread)) != 0) {
|
||||||
httpError("http thread:%s, failed to create HTTP process data thread, reason:%s",
|
httpError("http thread:%s, failed to create HTTP process data thread, reason:%s",
|
||||||
pThread->label, strerror(errno));
|
pThread->label, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
pthread_attr_destroy(&thattr);
|
||||||
|
|
||||||
httpTrace("http thread:%p:%s, initialized", pThread, pThread->label);
|
httpTrace("http thread:%p:%s, initialized", pThread, pThread->label);
|
||||||
pThread++;
|
pThread++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_attr_t thattr;
|
||||||
|
pthread_attr_init(&thattr);
|
||||||
|
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
|
||||||
if (pthread_create(&(pServer->thread), &thattr, (void *)httpAcceptHttpConnection, (void *)(pServer)) != 0) {
|
if (pthread_create(&(pServer->thread), &thattr, (void *)httpAcceptHttpConnection, (void *)(pServer)) != 0) {
|
||||||
httpError("http server:%s, failed to create Http accept thread, reason:%s", pServer->label, strerror(errno));
|
httpError("http server:%s, failed to create Http accept thread, reason:%s", pServer->label, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_attr_destroy(&thattr);
|
pthread_attr_destroy(&thattr);
|
||||||
|
|
||||||
httpTrace("http server:%s, initialized, ip:%s:%u, numOfThreads:%d", pServer->label, pServer->serverIp,
|
httpTrace("http server:%s, initialized, ip:%s:%u, numOfThreads:%d", pServer->label, pServer->serverIp,
|
||||||
|
|
|
@ -54,7 +54,7 @@ static HttpServer *httpServer = NULL;
|
||||||
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
|
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
|
||||||
|
|
||||||
int httpInitSystem() {
|
int httpInitSystem() {
|
||||||
taos_init();
|
// taos_init();
|
||||||
|
|
||||||
httpServer = (HttpServer *)malloc(sizeof(HttpServer));
|
httpServer = (HttpServer *)malloc(sizeof(HttpServer));
|
||||||
memset(httpServer, 0, sizeof(HttpServer));
|
memset(httpServer, 0, sizeof(HttpServer));
|
||||||
|
@ -129,7 +129,7 @@ void httpCleanUpSystem() {
|
||||||
httpPrint("http service cleanup");
|
httpPrint("http service cleanup");
|
||||||
httpStopSystem();
|
httpStopSystem();
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
if (httpServer == NULL) {
|
if (httpServer == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue