Skip to content

Commit

Permalink
Fixed one warning message at shutdown after checkpoint load and kept …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
hchen99 authored Sep 26, 2024
1 parent eed8707 commit 077064f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
7 changes: 0 additions & 7 deletions include/trick/ExternalApplication.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,21 @@ 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() {
return 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ int Trick::VariableServerListenThread::restart() {
message_publish(MSG_INFO, "restart variable server message port = %d\n", _listener->getPort());
}

initializeMulticast();
// Don't initialize the multicast group if it's already initialized
if (!_multicast->isInitialized()) {
initializeMulticast();
}

return 0 ;
}
Expand Down

0 comments on commit 077064f

Please sign in to comment.