fix(rpc): avoid fd leak

This commit is contained in:
yihaoDeng 2022-05-13 13:09:34 +08:00
parent c56b0e0b15
commit fee540c1fa
1 changed files with 20 additions and 19 deletions

View File

@ -167,25 +167,26 @@ static void* transAcceptThread(void* arg);
static bool addHandleToWorkloop(SWorkThrdObj* pThrd, char* pipeName); static bool addHandleToWorkloop(SWorkThrdObj* 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) && conn->status == ConnAcquire) { \ if ((head)->release == 1 && (head->msgLen) == sizeof(*head)) { \
transClearBuffer(&conn->readBuf); \ conn->status = ConnRelease; \
transFreeMsg(transContFromHead((char*)head)); \ transClearBuffer(&conn->readBuf); \
tTrace("server conn %p received release request", conn); \ transFreeMsg(transContFromHead((char*)head)); \
\ tTrace("server conn %p received release request", conn); \
STransMsg tmsg = {.code = 0, .handle = (void*)conn, .ahandle = NULL}; \ \
SSrvMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSrvMsg)); \ STransMsg tmsg = {.code = 0, .handle = (void*)conn, .ahandle = NULL}; \
srvMsg->msg = tmsg; \ SSrvMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSrvMsg)); \
srvMsg->type = Release; \ srvMsg->msg = tmsg; \
srvMsg->pConn = conn; \ srvMsg->type = Release; \
reallocConnRefHandle(conn); \ srvMsg->pConn = conn; \
if (!transQueuePush(&conn->srvMsgs, srvMsg)) { \ reallocConnRefHandle(conn); \
return; \ if (!transQueuePush(&conn->srvMsgs, srvMsg)) { \
} \ return; \
uvStartSendRespInternal(srvMsg); \ } \
return; \ uvStartSendRespInternal(srvMsg); \
} \ return; \
} \
} while (0) } while (0)
#define SRV_RELEASE_UV(loop) \ #define SRV_RELEASE_UV(loop) \