Ejemplo n.º 1
0
void RPC_HandleEvent(void *eventHandle)
{
	UInt8 clientId = 0;
	ResultDataBuffer_t *dataBuf;
	Result_t res = RESULT_OK;

	PACKET_BufHandle_t bufHandle = (PACKET_BufHandle_t) eventHandle;

	dataBuf = capi2_malloc(sizeof(ResultDataBuffer_t));

	if (dataBuf) {
		dataBuf->refCount = 1;
		res =
		    RPC_DeserializeMsg(RPC_PACKET_GetBufferData(bufHandle),
				       RPC_PACKET_GetBufferLength(bufHandle),
				       dataBuf);

		if (res == RESULT_OK) {
			Boolean isUnsolicited;
			UInt8 clientIndex =
			    GetClientIndex(dataBuf, &isUnsolicited);
			clientId = RPC_SYS_GetClientID(clientIndex);

			RPC_USER_LOCK(gRpcLock);

			RPC_DispatchMsg(dataBuf);

			RPC_USER_UNLOCK(gRpcLock);
		} else {
			capi2_free(dataBuf);
		}
	}

	RPC_PACKET_FreeBufferEx(bufHandle, clientId);
}
Ejemplo n.º 2
0
void RPC_SYSFreeResultDataBuffer(ResultDataBufHandle_t dataBufHandle)
{
	ResultDataBuffer_t* dataBuf = (ResultDataBuffer_t*)dataBufHandle;
	
	_DBG_(RPC_TRACE_INFO("RPC_SYSFreeResultDataBuffer ref=%d", (dataBuf)?dataBuf->refCount:-1));
	if(dataBuf && dataBuf->refCount > 0)
	{
		--(dataBuf->refCount);
		if(dataBuf->refCount == 0)
	    {
		    /* Free up the memory allocated during deserialization of the pointers */
		    dataBuf->xdrs.x_op = XDR_FREE;
		    xdr_RPC_InternalMsg_t( &dataBuf->xdrs, &dataBuf->rsp );
		    xdr_destroy(&dataBuf->xdrs);
            capi2_free(dataBuf);
			// coverity[deref_after_free]: Dereferencing freed pointer "dataBuf"
			_DBG_(RPC_TRACE_INFO("RPC_SYSFreeResultDataBuffer ( FREE ) ref=%d", (dataBuf)?dataBuf->refCount:-1));
		}
	}
}