Fixed one warning message at shutdown after checkpoint load and kept the current multicast group after checkpoint load. (#1784)

* Added a check before calling MM delete_var in ExternalApplication destructor;
Made sure that the MulticastGroup is not initialized before initializing it in VariableServerListenThread.cpp;

* Updated to call multicast group initialization to be consistent for the unit test.

* Removed unnecessary command c str pointer.

* Removed unnecessary command c str pointer.
This commit is contained in:
Hong Chen 2024-09-26 11:17:57 -05:00 committed by GitHub
parent eed8707638
commit 077064f225
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 21 deletions

View File

@ -295,13 +295,6 @@ namespace Trick {
/** Command to execute when starting this application. */
std::string command;
/** Pointer to alloc'd command c str for use with external application c_intf */
char * command_c_str;
/** alloc'd addresses to be deallocated during app destruction (currently only
used by command_c_str) */
std::vector<char*> allocations;
private:
/** Prevent SWIG from trying to invoke operator= on ostringstream. */

View File

@ -19,25 +19,13 @@ Trick::ExternalApplication::ExternalApplication() :
host_source = port_source = AUTO;
cycle_period_set = minimum_cycle_period_set = disconnect_behavior_set = height_set =
width_set = x_set = y_set = auto_reconnect_set = false;
// c_intf uses char *, we manage the memory here in external application
command_c_str = (char*)trick_MM->declare_var("char", (command.size() + 1) );
strcpy(command_c_str, command.c_str());
allocations.push_back(command_c_str);
}
Trick::ExternalApplication::~ExternalApplication() {
for(std::vector<char*>::iterator it = allocations.begin(); it != allocations.end(); ++it) {
trick_MM->delete_var( (void*)*it );
}
allocations.clear();
}
void Trick::ExternalApplication::set_startup_command(std::string in_command) {
command = in_command;
command_c_str = (char*)trick_MM->declare_var("char", (command.size() + 1) );
strcpy(command_c_str, command.c_str());
allocations.push_back((command_c_str));
}
std::string Trick::ExternalApplication::get_startup_command() {
@ -45,7 +33,7 @@ std::string Trick::ExternalApplication::get_startup_command() {
}
const char * Trick::ExternalApplication::get_startup_command_c_str() {
return command_c_str;
return command.c_str();
}
void Trick::ExternalApplication::add_arguments(std::string args) {

View File

@ -248,7 +248,10 @@ int Trick::VariableServerListenThread::restart() {
message_publish(MSG_INFO, "restart variable server message port = %d\n", _listener->getPort());
}
// Don't initialize the multicast group if it's already initialized
if (!_multicast->isInitialized()) {
initializeMulticast();
}
return 0 ;
}