From a9ec661f0f26e77e64785652eb7939b9b73c1339 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Fri, 12 Jun 2020 07:12:18 +0000 Subject: [PATCH] return -1 if connection is already closed --- src/inc/trpc.h | 2 +- src/rpc/src/rpcMain.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/inc/trpc.h b/src/inc/trpc.h index 3be304e29b..748fad0e62 100644 --- a/src/inc/trpc.h +++ b/src/inc/trpc.h @@ -83,7 +83,7 @@ void rpcSendResponse(const SRpcMsg *pMsg); void rpcSendRedirectRsp(void *pConn, const SRpcIpSet *pIpSet); int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo); void rpcSendRecv(void *shandle, SRpcIpSet *pIpSet, const SRpcMsg *pReq, SRpcMsg *pRsp); -void rpcReportProgress(void *pConn, char *pCont, int contLen); +int rpcReportProgress(void *pConn, char *pCont, int contLen); #ifdef __cplusplus } diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 7627a06c99..cf15cc690a 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -486,12 +486,19 @@ void rpcSendRecv(void *shandle, SRpcIpSet *pIpSet, const SRpcMsg *pMsg, SRpcMsg } // this API is used by server app to keep an APP context in case connection is broken -void rpcReportProgress(void *handle, char *pCont, int contLen) { +int rpcReportProgress(void *handle, char *pCont, int contLen) { SRpcConn *pConn = (SRpcConn *)handle; - // pReqMsg and reqMsgLen is re-used to store the context from app server - pConn->pReqMsg = pCont; - pConn->reqMsgLen = contLen; + if (pConn->user[0]) { + // pReqMsg and reqMsgLen is re-used to store the context from app server + pConn->pReqMsg = pCont; + pConn->reqMsgLen = contLen; + return 0; + } + + tTrace("%s, rpc connection is already released", pConn->info); + rpcFreeCont(pCont); + return -1; } static void rpcFreeMsg(void *msg) { -- GitLab