void x_ipc_dataMsgDisplayStats(FILE *stream) { LOCK_M_MUTEX; fprintf(stream,"Data Msg Buffer Stats:\n"); fprintf(stream," Total Alloc : %d\n", GET_M_GLOBAL(DMTotal)); fprintf(stream," Total Freed : %d\n", GET_M_GLOBAL(DMFree)); fprintf(stream," Min Request : %d\n", GET_M_GLOBAL(DMmin)); fprintf(stream," Max Request : %d\n", GET_M_GLOBAL(DMmax)); #if 0 fprintf(stream,"Buf List Size: %d\n", x_ipc_listLength(GET_M_GLOBAL(dataMsgBufferList))); GET_M_GLOBAL(numAllocatedDM) = GET_M_GLOBAL(sizeDM) = 0; x_ipc_listIterateFromFirst((LIST_ITER_FN)countDataMessages, (char *)TRUE, (GET_M_GLOBAL(dataMsgBufferList))); fprintf(stream," %d allocated, with %d total bytes\n", GET_M_GLOBAL(numAllocatedDM), GET_M_GLOBAL(sizeDM)); GET_M_GLOBAL(numAllocatedDM) = GET_M_GLOBAL(sizeDM) = 0; x_ipc_listIterateFromFirst((LIST_ITER_FN)countDataMessages, FALSE, (GET_M_GLOBAL(dataMsgBufferList))); fprintf(stream," %d deallocated, with %d total bytes\n", GET_M_GLOBAL(numAllocatedDM), GET_M_GLOBAL(sizeDM)); #endif UNLOCK_M_MUTEX; FLUSH_IF_NEEDED(stream); }
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); } }
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); } }
static DISPATCH_HND_PTR chooseMsgHandler(MSG_PTR msg) { int32 size; LIST_PTR hndList; DISPATCH_HND_PTR hnd, nextHnd, retHnd; hndList = msg->hndList; size = x_ipc_listLength(hndList); hnd = (DISPATCH_HND_PTR)x_ipc_listFirst(hndList); if (!size) { size = 1; hnd = NEW(DISPATCH_HND_TYPE); hnd->sd = 0; hnd->localId =0; hnd->msg = NULL; hnd->hndProc = NULL; hnd->hndOrg = GET_S_GLOBAL(x_ipcServerModGlobal); hnd->hndData = NULL; hnd->msgList = NULL; hnd->resource = resourceCreate(0, 0, msg->msgData->name, 1); hnd->resource->capacity = 0; hnd->hndLanguage = C_LANGUAGE; #ifdef NMP_IPC hnd->clientData = NO_CLIENT_DATA; #endif x_ipc_listInsertItem((char *)hnd, msg->hndList); } if (size > 1) { retHnd = hnd; nextHnd = (DISPATCH_HND_PTR)x_ipc_listNext(hndList); while (nextHnd && nextHnd->hndData && STREQ(hnd->hndData->hndName, nextHnd->hndData->hndName)) { if (resourceAvailableRes(nextHnd->resource)) retHnd = nextHnd; nextHnd = (DISPATCH_HND_PTR)x_ipc_listNext(hndList); } hnd = !nextHnd ? retHnd : NULL; } return hnd; }
X_IPC_REF_PTR x_ipcRefCreate(MSG_PTR msg, const char *name, int32 refId) { X_IPC_REF_PTR x_ipcRef; int32 length; LOCK_CM_MUTEX; if (!x_ipc_listLength(GET_C_GLOBAL(x_ipcRefFreeList))) x_ipcRef = NEW(X_IPC_REF_TYPE); else x_ipcRef = (X_IPC_REF_PTR)x_ipc_listPopItem(GET_C_GLOBAL(x_ipcRefFreeList)); UNLOCK_CM_MUTEX; x_ipcRef->refId = refId; x_ipcRef->msg = msg; if (!name) { x_ipcRef->name = NULL; } else { char *namePtr; length = strlen(name); namePtr = (char *)x_ipcMalloc((unsigned)(length+1)); BCOPY(name, namePtr, length); namePtr[length] = '\0'; x_ipcRef->name = namePtr; } x_ipcRef->responseSd = NO_FD; #ifdef NMP_IPC x_ipcRef->responded = FALSE; x_ipcRef->dataLength = 0; #endif x_ipcRef->encoding.byteOrder = GET_M_GLOBAL(byteOrder); x_ipcRef->encoding.alignment = GET_M_GLOBAL(alignment); return x_ipcRef; }