📄 rpccore.c
字号:
return (rpcCoreClntCall (WDB_EVALUATE_GOPHER, xdr_WDB_STRING_T, (char *) pWdbString, xdr_WDB_MEM_XFER, (char *) pWdbMemXfer)); }/********************************************************************************* rpcCoreCacheTextUpdate - update instruction cache** This function update the target instruction cache associated with the* target memory region described by the MEM_REGION structure pointed to* by * <pWdbMemRegion>. ** RETURNS: OK, or ERROR.*/LOCAL UINT32 rpcCoreCacheTextUpdate ( WDB_MEM_REGION * pWdbMemRegion /* cache region to update */ ) { /* check the easy case: null size region */ if (pWdbMemRegion->numBytes == 0) return (OK); /* * call the WDB_CACHE_TEXT_UPDATE service via the backend client in order * to fill the memory region pointed to by pWdbMemRegion. */ return (rpcCoreClntCall (WDB_MEM_CACHE_TEXT_UPDATE, xdr_WDB_MEM_REGION, (char *) pWdbMemRegion, xdr_void, NULL)); }/********************************************************************************* rpcCoreEvtPending - check if an event is pending ** This function is called by the target server in order to know if a event is* pending. It returns the state of the evtPending flag. This flag is set by* rpcCoreClntCall () when the MSB of the first field of the receive structue* is set.** RETURNS: TRUE if a target event is pending, otherwise FALSE.**/LOCAL BOOL rpcCoreEvtPending (void) { return (evtPending); }/********************************************************************************* rpcCoreEvtPendingClear - clear the event pending flag** This function is now a no-op. It will be removed in future versions of the* protocol.** RETURNS: N/A */LOCAL void rpcCoreEvtPendingClear (void) { return; }/********************************************************************************* rpcCoreClntCall - call a WDB service via the backend client** This function call a WDB service via the backend client created at the* initialization. The input arguments are the procedure (service) number to * connect, a pointer to the XDR function that will be used to encode the* input structure, a pointer to the input structure used by the service,* a pointer to the XDR function that will be used to decode the structure* and a pointer to the structure to used to save the data returned by the* service.* * The UDP transport protocol used between the backend and the WDB target agent* is unreliable. To remove this problem the request is re-sent if the timeout* falls before the answer arrived. The maximun number of time a same request* is re-send is handled by the maxNumResend variable. If the maximum number of* re-send is reached and the timeout is detected one more time then the* function is exited with a timeout error. ** The client call error 'RPC_PROCUNAVAIL' is used to detected that a WDB service* is not available. In this case, if the local variable dsaEnabled is set * (with bkendDsaEnable()) then the service is loaded via the routine given to* bkendDsaEnable(). ** The other RPC error 'RPC_SYSTEMERROR' is used to detected that the target* has rebooted. In this case the global variable restartTargetServer is set* allowing to keep the synchronization between the target server and the * WDB target agent.** If the MSB of the first field of the receive structure is set then a target* event was detected. In this case the evtPending flag is set. This flag is* tested by the rpcCoreEvtPending () function in order to know if an event* is pending or not.** RETURNS: Always a WDB error code.*/LOCAL UINT32 rpcCoreClntCall ( u_long procNum, /* procedure number to perform */ xdrproc_t inProc, /* xdr function to code input args */ char * in, /* input argument pointer */ xdrproc_t outProc, /* xdr function to decode output args */ char * out /* ouput arguments pointer */ ) { enum clnt_stat clntStatus; /* client call status */ struct timeval timeout; /* client call timeout */ u_int resendCnt; /* request resend counter */ STATUS status; /* status of tsWdbKnownSvcAdd() */ WDB_PARAM_WRAPPER wdbParamWrapper; /* input parameter wrapper */ WDB_REPLY_WRAPPER wdbReplyWrapper; /* output parameter wrapper */ /* * save the xdr function used to decode the output arguments. This * the xdr function is used by rpcCoreFreeResultArgs() to free the * memory used by the output arguments. */ lastOutProc = outProc; lastOutStruct = out; /* * set the timeout duration to the value hamdled by the defaultTimeout * variable. The variable was set at the initialization either to the * default value or the value set by the user. */ timeout.tv_sec = defaultTimeout; timeout.tv_usec = 0; resendCnt = 0; /* clear the request sent number */ /* increment the sequence number */ seqNumber++ ; /* * Log the WDB request. If no log are asked by the user bkendLog () * exits immediatly. */ bkendLog (procNum, TRUE, in, 0, (int ) seqNumber, 0); /* fill the WDB_PARAM_WRAPPER structure */ wdbParamWrapper.xdr = inProc; /* xdr function */ wdbParamWrapper.pParams = in; /* input structure */ wdbParamWrapper.seqNum = processId | seqNumber; /* seq nb */ /* fill the WDB_REPLY_WRAPPER structure */ wdbReplyWrapper.xdr = outProc; /* output xdr function */ wdbReplyWrapper.pReply = out; /* output struture area */ wdbReplyWrapper.errCode = OK; /* just to clear this field */ do { /* * call the service . If the answer is not arrived before the * timeout fails and the maximun number of time that a same request * can be re-sent is not reached then the request is re-sent. Otherwise * the do_while loop is exited. */ clntStatus = clnt_call (pWdbClnt, procNum, xdr_WDB_PARAM_WRAPPER, (char *)&wdbParamWrapper, xdr_WDB_REPLY_WRAPPER, (char *)&wdbReplyWrapper, timeout); } while (((clntStatus == RPC_TIMEDOUT) || (clntStatus == RPC_CANTDECODERES) || (clntStatus == RPC_CANTDECODEARGS)) && (++resendCnt < maxNumResend)); /* * log the structure returned by the target agent. If no log is requested * by the user the bkendLog() exit immediatly. * Note that we call bkendLog() with clntStatus when an RPC error * occured in order to log the RPC error code. */ if (clntStatus == OK) bkendLog (procNum, FALSE, out, resendCnt, 0, (wdbReplyWrapper.errCode & ~WDB_EVENT_NOTIFY)); else bkendLog (procNum, FALSE, out, resendCnt, 0, clntStatus); /* * If the target has rebooted we will receive RPC_SYSTEMERROR from * the agent. We need to tell the Target Server to restart itself * via restartTargetServer. */ if (clntStatus == RPC_SYSTEMERROR) tgtRestart (); /* * If agent service is not available and the dynamicaly scalable * agent option is available and the service is not already added, * attempt to add the service to the agent. */ if ((clntStatus == RPC_PROCUNAVAIL) && dsaEnabled && !rpcCoreSvcAdded) { status = (*pTsWdbKnownSvcAdd) (procNum); /* clear out since it has been clobbered by pTsWdbKnownSvcAdd */ /* * XXX P_M this is needed but we need to find a way to determine * the memory size to clear. */ /* memset (out, 0 , sizeof (tgtOutArgs)); */ if (status == OK) { /* set the rpcCoreSvcAdded flag to stop the recur loop */ rpcCoreSvcAdded = TRUE ; /* The service has been successfully added, now retry the call */ return (rpcCoreClntCall (procNum, inProc, in, outProc, out)); } } /* * check the client call status: If an error is detected then an error * message is logged. This message handles the RPC error detected. */ if (clntStatus == RPC_PROGUNAVAIL) { wpwrLogRaw ("\n"); wpwrLogErr ("target connected to another Target Server\n"); wdbReplyWrapper.errCode = WDB_ERR_CONNECTION_BUSY; } else if (clntStatus != RPC_SUCCESS) { wpwrLogRaw ("\n"); wpwrLogErr ("rpccore backend client %s\n", clnt_sperrno (clntStatus)); if (clntStatus == RPC_PROCUNAVAIL) wdbReplyWrapper.errCode = WDB_ERR_NO_AGENT_PROC; else wdbReplyWrapper.errCode = WDB_ERR_COMMUNICATION; } /* * check if the WDB target agent has detected an event not already * gotten by the target serveur. The MSB of the first field of the returned * structure is set. In this case the evtPending flag is set. When the * pcBckendEvtPending () function will be called, this function will * return TRUE and the target server will call rpcBckendEvtGet() to * get the event pending. */ if (wdbReplyWrapper.errCode & WDB_EVENT_NOTIFY) { /* * An event is pending: set the evtPending flag and reset the * WDB_EVENT_NOTIFY bit the receive structure. */ evtPending = TRUE; wdbReplyWrapper.errCode &= ~WDB_EVENT_NOTIFY; } else { /* No event is pending: clear the evtPending flag */ evtPending = FALSE; } /* clear the rpcCoreSvcAdded flag to allow service adding the next time */ rpcCoreSvcAdded = FALSE; /* return the client call status */ return (wdbReplyWrapper.errCode); }/********************************************************************************* rpcCoreFreeResultArgs - free the memory used by the returned structure** This function frees the memory used to save the structure returned by the* last service called. This function must be called after each call* to rpcCoreClntCall () when the output structure are no longer needed.** The lastOutProc variable points to the last XDR function used to decode* the structure returned by the WDB target agent. This variable is set* by the rpcCoreClntCall () function. If this variable is equal to the NULL* pointer no memory are freed.** RETURNS: TRUE if the memory is freed, otherwise FALSE.*/LOCAL BOOL rpcCoreFreeResultArgs (void) { bool_t freeResultStatus = TRUE; /* memory free result status */ if (lastOutProc != NULL) { /* * free the memory used by the returned structure of * the last clnt_call() */ freeResultStatus = clnt_freeres (pWdbClnt, lastOutProc, lastOutStruct); /* clear the last procedure used pointer */ lastOutProc = NULL; } return ((BOOL) freeResultStatus); }/********************************************************************************* rpcCoreTgtDisconnect - disconnect the target agent.** This function disconnects the target agent by killing the backend client.* It also call the WDB_TARGET_DISCONNECT service to allow the target to* perform whatever cleanup is necessary on its side.** RETURNS: Always Ok*/LOCAL UINT32 rpcCoreTgtDisconnect (void) { STATUS status = OK; /* function status */ /* * Tell the target to cleanup whatever is related to this connection * with the Target Server. * XXX p_m: ignore the status for now */ rpcCoreClntCall (WDB_TARGET_DISCONNECT, xdr_void, NULL, xdr_void, NULL); /* kill the backend client */ clnt_destroy (pWdbClnt); return (status); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -