mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
Variable Server fails to establish listen port on restart under a specific circumstance.
Added a test in the variable server listen restart job to see if the the name of the machine in the checkpoint file matches the machine that we are running on. We test all of the network names avaiable on the machine. If the name is not found then we assume that the checkpoint was taken on another machine and wipe out the machine name. This will default the machine name back to localhost. Fixes #24.
This commit is contained in:
parent
ea085eb9ee
commit
c5456fab2a
@ -156,11 +156,23 @@ int Trick::JSONVariableServer::restart() {
|
||||
int ret ;
|
||||
|
||||
if ( user_port_requested ) {
|
||||
printf("user_port_requested set %d", port) ;
|
||||
char hname[80];
|
||||
static struct sockaddr_in s_in;
|
||||
gethostname(hname, (size_t) 80);
|
||||
// Test to see if the restart address is on this machine. If it is not, it's not an error, clear source address
|
||||
if ( strcmp( source_address.c_str(), hname )) {
|
||||
if (! inet_pton(AF_INET, source_address.c_str(), (struct in_addr *)&s_in.sin_addr.s_addr) ) {
|
||||
//printf("clearing source_address\n") ;
|
||||
source_address.clear() ;
|
||||
}
|
||||
}
|
||||
|
||||
printf("JSON variable server restart user_port requested set %d\n", port) ;
|
||||
|
||||
tc_disconnect(&listen_dev) ;
|
||||
ret = tc_init_with_connection_info(&listen_dev, AF_INET, SOCK_STREAM, source_address.c_str(), port) ;
|
||||
if (ret != TC_SUCCESS) {
|
||||
message_publish(MSG_ERROR, "ERROR: Could not establish listen port %d for Variable Server. Aborting.\n", port);
|
||||
message_publish(MSG_ERROR, "ERROR: Could not establish listen port %d for JSON Variable Server. Aborting.\n", port);
|
||||
return (-1);
|
||||
}
|
||||
} else {
|
||||
|
@ -184,12 +184,27 @@ void * Trick::VariableServerListenThread::thread_body() {
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
int Trick::VariableServerListenThread::restart() {
|
||||
|
||||
int ret ;
|
||||
|
||||
if ( user_port_requested ) {
|
||||
printf("user_port_requested set %d", port) ;
|
||||
|
||||
char hname[80];
|
||||
static struct sockaddr_in s_in;
|
||||
gethostname(hname, (size_t) 80);
|
||||
// Test to see if the restart address is on this machine. If it is not, it's not an error, clear source address
|
||||
if ( strcmp( source_address.c_str(), hname )) {
|
||||
if (! inet_pton(AF_INET, source_address.c_str(), (struct in_addr *)&s_in.sin_addr.s_addr) ) {
|
||||
//printf("clearing source_address\n") ;
|
||||
source_address.clear() ;
|
||||
}
|
||||
}
|
||||
|
||||
printf("variable server restart user_port requested set %d\n", port) ;
|
||||
|
||||
tc_disconnect(&listen_dev) ;
|
||||
ret = tc_init_with_connection_info(&listen_dev, AF_INET, SOCK_STREAM, source_address.c_str(), port) ;
|
||||
if (ret != TC_SUCCESS) {
|
||||
|
Loading…
Reference in New Issue
Block a user