static void ipcDeleteTimer (TIMER_PTR timer) { LOCK_M_MUTEX; x_ipc_listDeleteItem((const void *)timer, GET_M_GLOBAL(timerList)); UNLOCK_M_MUTEX; x_ipcFree((char *)timer); }
/****************************************************************************** * * FUNCTION: int32 x_ipc_deregisterHnd(sd, hndData) * * DESCRIPTION: Deregister the given handler for the given message, for * the given module (as indicated by the socket descriptor sd). * * INPUTS: int32 sd; Socket descriptor of the module that registere the handler * HND_DATA_PTR hndData; Name of message and handler pair. * * OUTPUTS: int32: returns FALSE if the handler is not currently registered. * * NOTES: Just remove the handler from the message's hndList. Do not actually * delete it, since other things depend on having the handler around. * *****************************************************************************/ int32 x_ipc_deregisterHnd(int sd, HND_DATA_PTR hndData) { HND_PTR hnd; MSG_PTR msg; HND_KEY_TYPE hndKey; msg = x_ipc_findOrRegisterMessage(hndData->msgName); hndKey.num = sd; hndKey.str = hndData->hndName; LOCK_CM_MUTEX; hnd = (HND_PTR)x_ipc_hashTableFind((char *)&hndKey, GET_C_GLOBAL(handlerTable)); UNLOCK_CM_MUTEX; if (hnd) { x_ipc_removeHndFromMsg(hnd, msg); x_ipc_listDeleteItem((char *)msg, hnd->msgList); hnd->isRegistered = FALSE; } return (hnd != NULL); }
static int32 x_ipc_removeHndFromMsg(HND_PTR hnd, MSG_PTR msg) { x_ipc_listDeleteItem((char *)hnd, msg->hndList); return TRUE; }
IPC_RETURN_TYPE _IPC_queryResponse (const char *msgName, unsigned int length, BYTE_ARRAY content, BYTE_ARRAY *replyHandle, FORMATTER_PTR *replyFormatterPtr, const char **responseMsgNamePtr, unsigned int timeoutMsecs) { unsigned long quitTime = WAITFOREVER, now; QUERY_REPLY_TYPE queryReplyData; QUERY_NOTIFICATION_PTR queryNotif; IPC_RETURN_TYPE retVal = IPC_OK; queryReplyData.handled = FALSE; queryReplyData.data = NULL; queryReplyData.formatter = (FORMATTER_PTR)NULL; queryReplyData.msgName = NULL; if (timeoutMsecs != IPC_WAIT_FOREVER) { /* When to timeout */ now = x_ipc_timeInMsecs(); quitTime = timeoutMsecs + now; } /* Send the query, and set up a handler to catch the result and squirrel away the response data in "queryReplyData" */ if (IPC_queryNotify(msgName, length, content, queryReplyHandler, &queryReplyData) == IPC_Error) { PASS_ON_ERROR(); } else { /* Check if completed, because in threaded IPC, another thread could have handled the notification already */ if (!queryReplyData.handled) { while ((retVal = IPC_listen(timeoutMsecs)) == IPC_OK && !queryReplyData.handled) { /* Handled a message, but not the one we are waiting for. If still have time, reset the timeout and try again */ if (timeoutMsecs != IPC_WAIT_FOREVER) { now = x_ipc_timeInMsecs(); if (quitTime < now) { retVal = IPC_Timeout; break; } else { timeoutMsecs = quitTime - now; } } } } if (retVal != IPC_OK) { /* Clean up */ LOCK_CM_MUTEX; queryNotif = ((QUERY_NOTIFICATION_PTR) x_ipc_listMemReturnItem((LIST_ITER_FN)testQueryReplyData, (char *)&queryReplyData, GET_C_GLOBAL(queryNotificationList))); x_ipc_listDeleteItem((void *)queryNotif, GET_C_GLOBAL(queryNotificationList)); UNLOCK_CM_MUTEX; x_ipcRefFree(queryNotif->ref); x_ipcFree((void *)queryNotif); } *replyHandle = queryReplyData.data; if (replyFormatterPtr) *replyFormatterPtr = queryReplyData.formatter; if (responseMsgNamePtr) *responseMsgNamePtr = queryReplyData.msgName; return retVal; } }