OMNeT++/OMNEST Bug Tracker - OMNeT++
View Issue Details
0000433OMNeT++simulation kernelpublic2011-11-09 18:052011-11-09 18:05
0000433: Delete messages sent while finishing
Modules sometimes send messages while they are shutting down. For example, as part of finish we stop our applications, which shuts down sockets, which send UNBIND messages. These are reported as undisposed messages which is rather annoying.

One fix is to delete any messages that are sent while the sim is finishing as in the patch below.
------------------- vendor/omnetpp/src/sim/ -------------------
index d4193eb..166a5ee 100755
@@ -399,16 +399,24 @@ int cSimpleModule::sendDelayed(cMessage *msg, simtime_t delay, cGate *outgate)
             throw cRuntimeError("send()/sendDelayed(): cannot send message (%s)%s, "
                                 "it is currently contained/owned by (%s)%s",
                                 msg->getClassName(), msg->getName(), msg->getOwner()->getClassName(),
     if (delay < 0)
         throw cRuntimeError("sendDelayed(): negative delay %s", SIMTIME_STR(delay));
+ // Modules sometimes queue messages as part of their cleanup (e.g. a socket might attempt
+ // to send a UNBIND or IGMP leaves when it is closed).
+ if (simulation.getSimulationStage() == CTX_FINISH)
+ {
+ delete msg;
+ return 0;
+ }
     // set message parameters and send it
     simtime_t delayEndTime = simTime()+delay;
     msg->setSentFrom(this, outgate->getId(), delayEndTime);
     if (msg->isPacket())
         ((cPacket *)msg)->setDuration(0);
     bool keepit = outgate->deliver(msg, delayEndTime);
No tags attached.
Issue History
2011-11-09 18:05jesjonesNew Issue

There are no notes attached to this issue.