fix(rpc): avoid fd leak
This commit is contained in:
parent
4f7886d208
commit
ddee7344d5
|
@ -360,14 +360,14 @@ void uvOnSendCb(uv_write_t* req, int status) {
|
||||||
tTrace("server conn %p data already was written on stream", conn);
|
tTrace("server conn %p data already was written on stream", conn);
|
||||||
if (!transQueueEmpty(&conn->srvMsgs)) {
|
if (!transQueueEmpty(&conn->srvMsgs)) {
|
||||||
SSrvMsg* msg = transQueuePop(&conn->srvMsgs);
|
SSrvMsg* msg = transQueuePop(&conn->srvMsgs);
|
||||||
if (msg->type == Release && conn->status != ConnNormal) {
|
// if (msg->type == Release && conn->status != ConnNormal) {
|
||||||
conn->status = ConnNormal;
|
// conn->status = ConnNormal;
|
||||||
transUnrefSrvHandle(conn);
|
// transUnrefSrvHandle(conn);
|
||||||
reallocConnRefHandle(conn);
|
// reallocConnRefHandle(conn);
|
||||||
destroySmsg(msg);
|
// destroySmsg(msg);
|
||||||
transQueueClear(&conn->srvMsgs);
|
// transQueueClear(&conn->srvMsgs);
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
destroySmsg(msg);
|
destroySmsg(msg);
|
||||||
// send second data, just use for push
|
// send second data, just use for push
|
||||||
if (!transQueueEmpty(&conn->srvMsgs)) {
|
if (!transQueueEmpty(&conn->srvMsgs)) {
|
||||||
|
@ -425,8 +425,15 @@ static void uvPrepareSendData(SSrvMsg* smsg, uv_buf_t* wb) {
|
||||||
if (pConn->status == ConnNormal) {
|
if (pConn->status == ConnNormal) {
|
||||||
pHead->msgType = pConn->inType + 1;
|
pHead->msgType = pConn->inType + 1;
|
||||||
} else {
|
} else {
|
||||||
pHead->msgType = smsg->type == Release ? 0 : pMsg->msgType;
|
if (smsg->type == Release) {
|
||||||
|
pHead->msgType = 0;
|
||||||
|
pConn->status = ConnNormal;
|
||||||
|
transUnrefSrvHandle(pConn);
|
||||||
|
} else {
|
||||||
|
pHead->msgType = pMsg->msgType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pHead->release = smsg->type == Release ? 1 : 0;
|
pHead->release = smsg->type == Release ? 1 : 0;
|
||||||
pHead->code = htonl(pMsg->code);
|
pHead->code = htonl(pMsg->code);
|
||||||
|
|
||||||
|
@ -977,8 +984,8 @@ void uvHandleQuit(SSrvMsg* msg, SWorkThrdObj* thrd) {
|
||||||
}
|
}
|
||||||
void uvHandleRelease(SSrvMsg* msg, SWorkThrdObj* thrd) {
|
void uvHandleRelease(SSrvMsg* msg, SWorkThrdObj* thrd) {
|
||||||
SSrvConn* conn = msg->pConn;
|
SSrvConn* conn = msg->pConn;
|
||||||
// reallocConnRefHandle(conn);
|
|
||||||
if (conn->status == ConnAcquire) {
|
if (conn->status == ConnAcquire) {
|
||||||
|
reallocConnRefHandle(conn);
|
||||||
if (!transQueuePush(&conn->srvMsgs, msg)) {
|
if (!transQueuePush(&conn->srvMsgs, msg)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue