Skip to content

Commit

Permalink
return -1 if connection is already closed
Browse files Browse the repository at this point in the history
  • Loading branch information
jtao1735 committed Jun 12, 2020
1 parent 7b48f58 commit a9ec661
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/inc/trpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
15 changes: 11 additions & 4 deletions src/rpc/src/rpcMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a9ec661

Please sign in to comment.