Skip to content

Commit 9500ec8

Browse files
Fixed undefined behavior bug
1 parent 607972b commit 9500ec8

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

IDAWin/SundialsSolverInterface.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ void activateSolver(std::ifstream& inputFileStream, FILE* outputFile, int taskID
7979
}
8080

8181
// cleanup
82-
if (SimulationMessaging::getInstVar() != nullptr) {
83-
SimulationMessaging::getInstVar()->waitUntilFinished();
84-
delete SimulationMessaging::getInstVar();
85-
}
82+
SimulationMessaging::cleanupInstanceVar();
8683

8784
if (!errorMsg.empty()) errExit(returnCode, errorMsg);
8885
}

IDAWin/VCellSolverFactory.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,6 @@ VCellSolverInputBreakdown VCellSolverFactory::parseInputFile(std::ifstream& inpu
109109
else throw VCell::Exception("Unexpected token \"" + nextToken + "\" in the input file!");
110110

111111
}
112-
113-
114-
#ifdef USE_MESSAGING
115-
// Since messaging assumes we have a job requiring messaging, we should initialize a "default" messaging handler
116-
if (NULL == SimulationMessaging::getInstVar()) SimulationMessaging::create();
117-
#endif
118112
return inputBreakdown;
119113
}
120114

@@ -469,8 +463,10 @@ static void loadJMSInfo(std::istream &ifsInput, int taskID) {
469463
}
470464

471465
#ifdef USE_MESSAGING
472-
SimulationMessaging::create(broker.c_str(), smqUserName.c_str(),
473-
password.c_str(), qName.c_str(), topicName.c_str(),
474-
vCellUsername.c_str(), simKey, jobIndex, taskID);
466+
// SimulationMessaging::getInstVar()->initialize_curl_messaging(broker.c_str(), smqUserName.c_str(),
467+
// password.c_str(), qName.c_str(), topicName.c_str(),
468+
// vCellUsername.c_str(), simKey, jobIndex, taskID);
469+
SimulationMessaging::getInstVar()->initialize_curl_messaging(false, broker.c_str(),
470+
vCellUsername.c_str(), simKey, jobIndex, taskID);
475471
#endif
476472
}

IDAWin/VCellSundialsSolver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,9 @@ double VCellSundialsSolver::getNextEventTime() {
615615

616616
void VCellSundialsSolver::checkStopRequested(double time, long numIterations) {
617617
#ifdef USE_MESSAGING
618-
if (SimulationMessaging::getInstVar()->isStopRequested()) { throw StoppedByUserException("stopped by user"); }
618+
auto instVar = SimulationMessaging::getInstVar();
619+
if (nullptr == instVar) return;
620+
if (instVar->isStopRequested()) { throw StoppedByUserException("stopped by user"); }
619621
#endif
620622
}
621623

0 commit comments

Comments
 (0)