Skip to content

Commit

Permalink
RoutingTableRecorder: bugfix: recording was destroyed during cleanup
Browse files Browse the repository at this point in the history
The routingLogFile closed by finish(). The cleanup phase reopen and truncate the routingLogFile,
because signal arrived to recordInterfaceChange() in cleanup phase.
  • Loading branch information
ZoltanBojthe committed Apr 28, 2022
1 parent d476e52 commit c72183b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/inet/networklayer/ipv4/RoutingTableRecorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ RoutingTableRecorder::RoutingTableRecorder()

RoutingTableRecorder::~RoutingTableRecorder()
{
if (routingLogFile != nullptr) {
fclose(routingLogFile);
routingLogFile = nullptr;
}
}

void RoutingTableRecorder::initialize(int stage)
Expand All @@ -59,10 +63,6 @@ void RoutingTableRecorder::handleMessage(cMessage *)

void RoutingTableRecorder::finish()
{
if (routingLogFile != nullptr) {
fclose(routingLogFile);
routingLogFile = nullptr;
}
}

void RoutingTableRecorder::hookListeners()
Expand Down Expand Up @@ -107,6 +107,9 @@ void RoutingTableRecorder::receiveChangeNotification(cComponent *nsource, simsig

void RoutingTableRecorder::recordInterfaceChange(cModule *host, const NetworkInterface *ie, simsignal_t signalID)
{
if (getSimulation()->getSimulationStage() == CTX_CLEANUP)
return; // ignore notifications during cleanup

// Note: ie->getInterfaceTable() may be nullptr (entry already removed from its table)

const char *tag;
Expand Down

0 comments on commit c72183b

Please sign in to comment.