rm idle conn
This commit is contained in:
parent
607c042a2f
commit
87a15d4523
|
@ -187,7 +187,7 @@ static void cliReleaseUnfinishedMsg(SCliConn* conn) {
|
||||||
pThrd = (SCliThrd*)(exh)->pThrd; \
|
pThrd = (SCliThrd*)(exh)->pThrd; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define CONN_PERSIST_TIME(para) (para * 20)
|
#define CONN_PERSIST_TIME(para) ((para) == 0 ? 3 * 1000 : 10 * (para))
|
||||||
#define CONN_GET_HOST_THREAD(conn) (conn ? ((SCliConn*)conn)->hostThrd : NULL)
|
#define CONN_GET_HOST_THREAD(conn) (conn ? ((SCliConn*)conn)->hostThrd : NULL)
|
||||||
#define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrd*)(conn)->hostThrd)->pTransInst))->label)
|
#define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrd*)(conn)->hostThrd)->pTransInst))->label)
|
||||||
#define CONN_SHOULD_RELEASE(conn, head) \
|
#define CONN_SHOULD_RELEASE(conn, head) \
|
||||||
|
@ -1078,7 +1078,8 @@ static void doCloseIdleConn(void* param) {
|
||||||
STaskArg* arg = param;
|
STaskArg* arg = param;
|
||||||
SCliConn* conn = arg->param1;
|
SCliConn* conn = arg->param1;
|
||||||
SCliThrd* pThrd = arg->param2;
|
SCliThrd* pThrd = arg->param2;
|
||||||
|
tTrace("%s conn %p idle, close it", CONN_GET_INST_LABEL(conn), conn);
|
||||||
|
conn->task = NULL;
|
||||||
cliDestroyConn(conn, true);
|
cliDestroyConn(conn, true);
|
||||||
taosMemoryFree(arg);
|
taosMemoryFree(arg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,31 +149,34 @@ static void* transAcceptThread(void* arg);
|
||||||
static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName);
|
static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName);
|
||||||
static bool addHandleToAcceptloop(void* arg);
|
static bool addHandleToAcceptloop(void* arg);
|
||||||
|
|
||||||
#define CONN_SHOULD_RELEASE(conn, head) \
|
#define CONN_SHOULD_RELEASE(conn, head) \
|
||||||
do { \
|
do { \
|
||||||
if ((head)->release == 1 && (head->msgLen) == sizeof(*head)) { \
|
if ((head)->release == 1 && (head->msgLen) == sizeof(*head)) { \
|
||||||
conn->status = ConnRelease; \
|
reallocConnRef(conn); \
|
||||||
transClearBuffer(&conn->readBuf); \
|
tTrace("conn %p received release request", conn); \
|
||||||
transFreeMsg(transContFromHead((char*)head)); \
|
\
|
||||||
tTrace("conn %p received release request", conn); \
|
STraceId traceId = head->traceId; \
|
||||||
STransMsg tmsg = {.code = 0, .info.handle = (void*)conn, .info.traceId = head->traceId, .info.ahandle = NULL}; \
|
conn->status = ConnRelease; \
|
||||||
SSvrMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSvrMsg)); \
|
transClearBuffer(&conn->readBuf); \
|
||||||
srvMsg->msg = tmsg; \
|
transFreeMsg(transContFromHead((char*)head)); \
|
||||||
srvMsg->type = Release; \
|
\
|
||||||
srvMsg->pConn = conn; \
|
STransMsg tmsg = {.code = 0, .info.handle = (void*)conn, .info.traceId = traceId, .info.ahandle = NULL}; \
|
||||||
reallocConnRef(conn); \
|
SSvrMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSvrMsg)); \
|
||||||
if (!transQueuePush(&conn->srvMsgs, srvMsg)) { \
|
srvMsg->msg = tmsg; \
|
||||||
return; \
|
srvMsg->type = Release; \
|
||||||
} \
|
srvMsg->pConn = conn; \
|
||||||
if (conn->regArg.init) { \
|
if (!transQueuePush(&conn->srvMsgs, srvMsg)) { \
|
||||||
tTrace("conn %p release, notify server app", conn); \
|
return; \
|
||||||
STrans* pTransInst = conn->pTransInst; \
|
} \
|
||||||
(*pTransInst->cfp)(pTransInst->parent, &(conn->regArg.msg), NULL); \
|
if (conn->regArg.init) { \
|
||||||
memset(&conn->regArg, 0, sizeof(conn->regArg)); \
|
tTrace("conn %p release, notify server app", conn); \
|
||||||
} \
|
STrans* pTransInst = conn->pTransInst; \
|
||||||
uvStartSendRespInternal(srvMsg); \
|
(*pTransInst->cfp)(pTransInst->parent, &(conn->regArg.msg), NULL); \
|
||||||
return; \
|
memset(&conn->regArg, 0, sizeof(conn->regArg)); \
|
||||||
} \
|
} \
|
||||||
|
uvStartSendRespInternal(srvMsg); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SRV_RELEASE_UV(loop) \
|
#define SRV_RELEASE_UV(loop) \
|
||||||
|
|
Loading…
Reference in New Issue