|
From: | WQY |
Subject: | [certi-dev] A crash in CERTI when used in multithread application |
Date: | Wed, 15 Aug 2012 22:29:56 +0800 |
Hi, I am using CERTI to develop GUI applications. In the common situation, I used two threads: the main thread used for UI, the other called RTIambassador::tick() repeatedly to process FederateAmbassador callbacks. My question is when I use RTIambassador to send interactions, (of course this happens in UI main thread), my application crashed sometimes. I found the problem is this: RTIambPrivateRefs.cc, in function executeService(): req->send(socketUn,msgBufSend); … rep->receive(socketUn,msgBufReceive); … if (rep->getMessageType() != req->getMessageType()) throw RTI::RTIinternalError("RTIambPrivateRefs::executeService: rep->type != req->type"); So, this requires that: req and rep must have the save type, or an exception will be arised. However, in RTIambassador.cc, function __tick_kernel: vers_RTI.send(privateRefs->socketUn,privateRefs->msgBufSend); … while (1) { vers_Fed.reset(M_Factory::receive(privateRefs->socketUn)); … if (vers_Fed->getMessageType() == Message::TICK_REQUEST) … return RTI::Boolean(static_cast<M_Tick_Request*>(vers_Fed.get())->getMultiple()); … // Otherwise, the RTI calls a FederateAmbassador service. privateRefs->callFederateAmbassador(vers_Fed.get()); … } So, here is the question: the tick() thread receives other message, and cause the main thread’s req and rep have different type, and the crash happens. Did I use CERTI in a wrong way, or I make some mistake? Please help! Thanks! James |
[Prev in Thread] | Current Thread | [Next in Thread] |