add lock in all timer processing

This commit is contained in:
Jeff Tao 2020-06-16 12:36:58 +00:00
parent 58922d8600
commit 387f162ddf
1 changed files with 8 additions and 1 deletions

View File

@ -490,6 +490,7 @@ void rpcSendRecv(void *shandle, SRpcIpSet *pIpSet, const SRpcMsg *pMsg, SRpcMsg
int rpcReportProgress(void *handle, char *pCont, int contLen) { int rpcReportProgress(void *handle, char *pCont, int contLen) {
SRpcConn *pConn = (SRpcConn *)handle; SRpcConn *pConn = (SRpcConn *)handle;
rpcLockConn(pConn);
if (pConn->user[0]) { if (pConn->user[0]) {
// pReqMsg and reqMsgLen is re-used to store the context from app server // pReqMsg and reqMsgLen is re-used to store the context from app server
pConn->pReqMsg = pCont; pConn->pReqMsg = pCont;
@ -499,6 +500,8 @@ int rpcReportProgress(void *handle, char *pCont, int contLen) {
tTrace("%s, rpc connection is already released", pConn->info); tTrace("%s, rpc connection is already released", pConn->info);
rpcFreeCont(pCont); rpcFreeCont(pCont);
rpcUnlockConn(pConn);
return -1; return -1;
} }
@ -1254,13 +1257,17 @@ static void rpcProcessRetryTimer(void *param, void *tmrId) {
static void rpcProcessIdleTimer(void *param, void *tmrId) { static void rpcProcessIdleTimer(void *param, void *tmrId) {
SRpcConn *pConn = (SRpcConn *)param; SRpcConn *pConn = (SRpcConn *)param;
rpcLockConn(pConn);
if (pConn->user[0]) { if (pConn->user[0]) {
tTrace("%s, close the connection since no activity", pConn->info); tTrace("%s, close the connection since no activity", pConn->info);
if (pConn->inType) rpcReportBrokenLinkToServer(pConn); if (pConn->inType) rpcReportBrokenLinkToServer(pConn);
rpcCloseConn(pConn); rpcReleaseConn(pConn);
} else { } else {
tTrace("%s, idle timer:%p not processed", pConn->info, tmrId); tTrace("%s, idle timer:%p not processed", pConn->info, tmrId);
} }
rpcUnlockConn(pConn);
} }
static void rpcProcessProgressTimer(void *param, void *tmrId) { static void rpcProcessProgressTimer(void *param, void *tmrId) {