Esempio n. 1
0
/*****************************************************************************************************************************************************
AddToSentBox

Add a legal message going to send to process sendBox. This message is stored in global message Queue.
Add a message to a process via PCB_Table otherwise have to loop seperately in ReadyQueue, TimerQueue and SuspendQueue to find a process
*******************************************************************************************************************************************************/
void	AddToSentBox(ProcessControlBlock *PCB_Table[], INT32 process_id, Message *msg,  INT32 number_of_processes) {

    INT32				index = 0;
    ProcessControlBlock *tmp;
    Message*			add_message;

    while (index <number_of_processes) {
        if ( PCB_Table[index] != NULL)  {
            if (PCB_Table[index]->process_id == process_id ) {
                if (!IsExistsMessageIDQueue(PCB_Table[index]->sentBoxQueue,msg->msg_id) ) {
                    add_message = CreateMessage(msg->msg_id,msg->target_id, msg->source_id, msg->send_length,msg->actual_msg_length,msg->msg_buffer,msg->is_broadcast);
                    AddToMsgQueue(& (PCB_Table[index]->sentBoxQueue),add_message);
                }
            }
        }
        index ++;
    }

}
Esempio n. 2
0
bool CMultiXProcess::Send(int32_t MsgCode, const	CMultiXBufferArray	&Bufs,int Flags, const	TMultiXSessionID	&SessionID,int Priority, uint32_t Timeout, void *Context,TMultiXProcID	RoutedFrom,const	char	*WSURL,const	char	*WSSoapAction,const	char	*WSDllFile,const	char	*WSDllFunction)
{
    if(!SenderEnabled())
        return	false;
    CMultiXAppMsg	*Msg	=	CreateNewAppMsg();
    AddToMsgQueue(m_pOutQueue,Msg);
    Msg->AllocateL7XMsg(MsgCode);
    if(RoutedFrom	==	0)
        RoutedFrom	=	Owner()->ProcessID();
    Msg->AddInfo(Bufs,Flags & (~CMultiXAppMsg::FlagMsgIsResponse),SessionID,Priority,Timeout,Context,MultiXNoError,RoutedFrom,WSURL,WSSoapAction,WSDllFile,WSDllFunction);

    if(Msg->NotifyAny())
        return	Send(*Msg);
    else
    {
        Send(*Msg);
        delete	Msg;
    }
    return	true;
}
Esempio n. 3
0
bool CMultiXProcess::OnAppMsg(CMultiXMsg &Msg)
{
    if(!ReceiverEnabled()	||	!SenderEnabled())
        return	false;
    CMultiXAppMsg	*OrgMsg	=	NULL;
    CMultiXSession	*Session	=	NULL;
    CMultiXAppMsg	*AppMsg	=	CreateNewAppMsg(&Msg);
    //if(m_MsgCount++	==	1)
//		m_LastPrintTime	=	Owner()->GetMilliClock();
    m_LastMsgRecvMilliClock	=	Owner()->GetMilliClock();

    AddToMsgQueue(m_pInQueue,AppMsg);

    if(!AppMsg->ResponseRequired())
    {
        if(AppMsg->NotifyAny())
            AppMsg->Reply(MultiXNoError);
    }

    if(AppMsg->IsResponse())
    {
        OrgMsg	=	AppMsg->ReceiverMsgID().GetObject();
        if(OrgMsg	!=	NULL)
        {
            Session	=	Owner()->FindSession(OrgMsg->SessionID());
            OrgMsg->m_bKeep	=	false;
            OrgMsg->ID().RemoveObject();

            if(AppMsg->AppDataSize()	||	OrgMsg->ResponseRequired())
            {
                if(Session)
                {
                    if(AppMsg->IsCtrlMsgFromTpm())
                        Session->OnDataReplyFromTpmReceived(*AppMsg,*OrgMsg);
                    else
                        Session->OnDataReplyReceivedNV(*AppMsg,*OrgMsg);
                }	else
                {
                    if(AppMsg->IsCtrlMsgFromTpm())
                        OnDataReplyFromTpmReceived(*AppMsg,*OrgMsg);
                    else
                        OnDataReplyReceived(*AppMsg,*OrgMsg);
                }
            }	else if(AppMsg->Error())
            {
                if(OrgMsg->NotifyError())
                {
                    if(Session)
                    {
                        if(AppMsg->IsCtrlMsgFromTpm())
                            Session->OnSendMsgToTpmFailed(*OrgMsg);
                        else
                            Session->OnSendMsgFailedNV(*OrgMsg);
                    }	else
                    {
                        if(AppMsg->IsCtrlMsgFromTpm())
                            OnSendMsgToTpmFailed(*OrgMsg);
                        else
                            OnSendMsgFailed(*OrgMsg);
                    }
                }
            }	else
            {
                if(OrgMsg->NotifySuccess())
                {
                    if(Session)
                    {
                        if(AppMsg->IsCtrlMsgFromTpm())
                            Session->OnSendMsgToTpmCompleted(*OrgMsg);
                        else
                            Session->OnSendMsgCompletedNV(*OrgMsg);
                    }	else
                    {
                        if(AppMsg->IsCtrlMsgFromTpm())
                            OnSendMsgToTpmCompleted(*OrgMsg);
                        else
                            OnSendMsgCompleted(*OrgMsg);
                    }
                }
            }
        }	else	//	it is a response but the original does not exist
        {
            AppMsg->Reply(TpmErrUnableToForwardMsg);
        }
    }	else
    {
        Session	=	Owner()->FindSession(AppMsg->SessionID(),true);
        if(Session)
        {
            if(AppMsg->IsCtrlMsgFromTpm())
                Session->OnNewMsgFromTpm(*AppMsg);
            else
                Session->OnNewMsgNV(*AppMsg);
        }	else
        {
            if(AppMsg->IsCtrlMsgFromTpm())
                OnNewMsgFromTpm(*AppMsg);
            else
                OnNewMsg(*AppMsg);
        }
        if(AppMsg->ResponseRequired()	&&	!(AppMsg->ReplySent()	||	AppMsg->m_bKeep))
            Throw();
    }

    if(!(AppMsg->ReplySent()	||	AppMsg->m_bKeep))
    {
        if(AppMsg->ResponseRequired())
            Throw();
        else if(AppMsg->NotifyAny())
            AppMsg->Reply(MultiXNoError);
    }

    if(OrgMsg	&&	!OrgMsg->m_bKeep)
        delete	OrgMsg;
    if(!AppMsg->m_bKeep)
        delete	AppMsg;
    return	true;
}