Example #1
0
void releaseDispatch(DISPATCH_PTR dispatch)
{
  if (dispatch) {
    
    if (dispatch->refCount == 0) {
      LOG2("\nWARNING: Releasing an unreserved dispatch %s (%d)\n",
	  dispatch->msg->msgData->name, dispatch->locId);
    } else {
      dispatch->refCount--;
    }
    
    if (dispatch->refCount <= 0) {
#ifndef NMP_IPC
      HandleKillAfterAttendingNodes(dispatch);
      if ((dispatch->status == HandledDispatch) && !dispatch->treeNode) {
	dispatchFree(dispatch);
#else
      if (dispatch->status == HandledDispatch) {
	dispatchFree(dispatch);
#endif
      }
    }
  }
}

/******************************************************************************
 *
 * FUNCTION: void dispatchStats
 *
 * DESCRIPTION: Print stats about the utilization of dispatches in central
 *
 * INPUTS: 
 *
 * OUTPUTS: 
 *
 *****************************************************************************/

#if 0
/* No longer used */
void dispatchStats ()
{
  int32 i, num=0;
  DISPATCH_PTR dispatch;
  
  for (i=0; i<GET_S_GLOBAL(dispatchTable)->currentSize; i++) {
    dispatch = (DISPATCH_PTR)idTableItem(i, GET_S_GLOBAL(dispatchTable));
    if (dispatch->status != UnallocatedDispatch) {
      printf("%d. %s\n", ++num, dispatch->msg->msgData->name);
    }
  }
}
Example #2
0
static void recvMultiQueryMessage (DISPATCH_PTR dispatch)
{
  tapWhenSent(dispatch);
  /* 
   * Need to "park" the class data somewhere, so that it will not be freed
   * when a reply comes in.  Instead of adding another slot to "dispatch",
   * just reuse the "blockCom" slot
   */
  dispatch->blockCom = (BLOCK_COM_PTR)dispatch->classData;
  dispatch->classData = NULL;
  
  MULTI_QUERY_NUM(dispatch) = x_ipc_listLength(dispatch->msg->hndList);
  if (MULTI_QUERY_MAX(dispatch) > MULTI_QUERY_NUM(dispatch)) {
    MULTI_QUERY_MAX(dispatch) = MULTI_QUERY_NUM(dispatch);
  }
  
  if (MULTI_QUERY_MAX(dispatch) == 0) {
    sendMultiQueryTermination(dispatch);
    /* Free the class data, saved in "blockCom" slot */
    x_ipcFree((char *)dispatch->blockCom);
    dispatchFree(dispatch);
  } else {
    (void)x_ipc_listIterateFromLast((LIST_ITER_FN)processBroadcast, 
			      (char *)dispatch, 
			      dispatch->msg->hndList);
  }
}
Example #3
0
static void recvBroadcastMessage (DISPATCH_PTR dispatch)
{
  tapWhenSent(dispatch);
  if (x_ipc_listLength(dispatch->msg->hndList) == 0) {
    dispatchFree(dispatch);
  } else {
    (void)x_ipc_listIterateFromLast((LIST_ITER_FN)processBroadcast, 
			      (char *)dispatch, 
			      dispatch->msg->hndList);
  }
}
Example #4
0
void processResAttendDeliver(DISPATCH_PTR dispatch)
{
  resourceAttending(dispatch);
#ifndef NMP_IPC
  AttendingConstraints(dispatch);
#endif
  deliverDispatch(dispatch);
  tapWhileHandling(dispatch);
  /* 02-Jul-91: Reid: 
   * Just handled a central query or inform: 
   * It's OK to free the dispatch here 
   */
  if (dispatch->msg_class == ReplyClass ||
      (dispatch->msg_class == InformClass && 
       dispatch->des == GET_S_GLOBAL(x_ipcServerModGlobal)))
    dispatchFree(dispatch);
}
Example #5
0
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);
}
Example #6
0
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 */
}