void deliverDispatch(DISPATCH_PTR dispatch) { char *data; DATA_MSG_PTR newDataMsg; X_IPC_MSG_CLASS_TYPE msg_class; CLASS_FORM_PTR classForm; data = NULL; dispatchUpdateAndDisplay(AttendingDispatch, dispatch); if (dispatch->des == GET_S_GLOBAL(x_ipcServerModGlobal)) { if (monitorClass(dispatch->msg->msgData->msg_class)) { data = dispatch->classData; } else { data = (char *)x_ipc_dataMsgDecodeMsg(dispatch->msg->msgData->msgFormat, DISPATCH_MSG_DATA(dispatch),TRUE); } (*dispatch->hnd->hndProc)(dispatch, data); if (dispatch->msg_class == InformClass) { dispatchUpdateAndDisplay(HandledDispatch, dispatch); } } else { if (dispatch->hnd->msg != dispatch->msg) { /* handler to recieve new message */ msg_class = ExecHndClass; classForm = GET_CLASS_FORMAT(&msg_class); if (!classForm) X_IPC_ERROR("ERROR: deliverDispatch: missing ExecHndClass class format."); newDataMsg = x_ipc_dataMsgReplaceClassData(classForm->format, (char*)&dispatch->msg->msgData->name, dispatch->msgData, dispatch->msg->msgData->msgFormat ); /* 31-Oct-90: fedor: the x_ipc_dataMsgReplaceClassData routine calls x_ipc_dataMsgFree - this avoids calling it twice and gets the refs correct. blah! */ dispatch->msgData = NULL; dispatchSetMsgData(newDataMsg, dispatch); } else { /* The datamags may already have old class data. Since class data follows message data, this will prevent old class data from being sent. */ dispatch->msgData->classTotal = 0; } dispatch->msgData->intent = dispatch->hnd->hndData->refId; dispatch->msgData->msgRef = dispatch->locId; (void)x_ipc_dataMsgSend(dispatch->desId, dispatch->msgData); } }
static void processResourceAndDeliver(DISPATCH_PTR dispatch) { #ifndef NMP_IPC if (!dispatch->treeNode) { tapBeforeHandling(dispatch); } #endif if (resourceAvailable(dispatch)) processResAttendDeliver(dispatch); else { resourcePending(dispatch); #ifndef NMP_IPC PendingConstraints(dispatch); #endif dispatchUpdateAndDisplay(PendingDispatch, dispatch); } }
static void recvReplyMessage (DISPATCH_PTR dispatch) { dispatchUpdateAndDisplay(HandledDispatch, dispatch); resourceRemoveAttending(dispatch); /* Added for safety, the dispatch message could have been * freed if there was an error. */ if ((dispatch->msg == NULL) || (dispatch->msg->msgData == NULL)) return; if (dispatch->msg->msgData->msg_class != MultiQueryClass || MULTI_QUERY_MAX(dispatch) > 0) { deliverResponse(dispatch); tapAfterReplied(dispatch); tapAfterHandled(dispatch); } #ifndef NMP_IPC if (dispatch->msg->msgData->msg_class == MultiQueryClass) { multiQueryUpdate(dispatch, TRUE); } #endif /* 31-Oct-90: fedor: problem with replies that are not simply replies to standard query messages ...etc. sooo we need to keep the dispatch around but perhaps not the datamsg. This just postpones the eventual memory lossage */ x_ipc_dataMsgFree(dispatch->msgData); x_ipc_dataMsgFree(dispatch->resData); dispatch->msgData = NULL; dispatch->resData = NULL; /* 31-Oct-90: fedor: also need to do free before processing further otherwise we may loop and never free anything */ resourceProcessPending(dispatch); /* 02-Jul-91: reid: Centrally handled dispatch queries are * freed in "processResAttendDeliver" */ if (dispatch->des != GET_S_GLOBAL(x_ipcServerModGlobal)) dispatchFree(dispatch); }
/* 22-May-91:fedor: another level of flow and control for exception handling */ void processInactiveTests(DISPATCH_PTR dispatch) { if (NeedToKillMessage(dispatch)) { dispatch->status = InactiveDispatch; dispatch->treeNode->status = ((dispatch->refCount <= 0) ? KilledNode : ToBeKilledNode); /* RGS: 12/1/93: If this is a blocking command, need to issue a reply * in order to prevent deadlock */ if (dispatch->blockCom && dispatch->blockCom->waitFlag && dispatch->msg && dispatch->msg->msgData->msg_class == CommandClass) { blockingCommandReply(dispatch, FailureDispatch); } } else if (ATTENDABLE(dispatch->treeNode)) processActiveMessage(dispatch); else { InactiveConstraints(dispatch); dispatchUpdateAndDisplay(InactiveDispatch, dispatch); } }
void processHandledMessage(DISPATCH_PTR dispatch) { dispatchUpdateAndDisplay(HandledDispatch, dispatch); resourceRemoveAttending(dispatch); tapAfterHandled(dispatch); if (dispatch->msg && !ONE_WAY_MSG(dispatch->msg)) { switch (dispatch->msg_class) { case SuccessClass: #ifndef NMP_IPC tapWhenSuccess(dispatch); tapAfterSuccess(dispatch); #endif break; #ifndef NMP_IPC case FailureClass: tapWhenFailure(dispatch); tapAfterFailure(dispatch); break; #endif default: /* X_IPC_MOD_ERROR("Unhandled default"); */ X_IPC_MOD_WARNING1("unhandled default in processHandledMessage %d\n", dispatch->msg_class); break; } } resourceProcessPending(dispatch); #ifndef NMP_IPC CompletionConstraints(dispatch); HandleKillAfterAttendingNodes(dispatch); #endif if (!dispatch->msg || ONE_WAY_MSG(dispatch->msg)) dispatchFree(dispatch); /* 14-May-91: fedor: exception class messages that are byPassed or retry should not be dispatch freed arbitrarly - may need to declare the first message handled and then resend the same dispatch through recvMessage */ }