Hop new ports, but keep the old [for a minute, and up to 10 at a time]
(One is silver and the other gold...)
This commit is contained in:
@@ -534,7 +534,10 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network
|
||||
|
||||
/* poll for events */
|
||||
sel.clear_fds();
|
||||
sel.add_fd( network.fd() );
|
||||
std::vector< int > fd_list( network.fds() );
|
||||
assert( fd_list.size() == 1 ); /* servers don't hop */
|
||||
int network_fd = fd_list.back();
|
||||
sel.add_fd( network_fd );
|
||||
sel.add_fd( host_fd );
|
||||
|
||||
int active_fds = sel.select( timeout );
|
||||
@@ -546,7 +549,7 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network
|
||||
now = Network::timestamp();
|
||||
uint64_t time_since_remote_state = now - network.get_latest_remote_state().timestamp;
|
||||
|
||||
if ( sel.read( network.fd() ) ) {
|
||||
if ( sel.read( network_fd ) ) {
|
||||
/* packet received from the network */
|
||||
network.recv();
|
||||
|
||||
@@ -652,7 +655,7 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network
|
||||
}
|
||||
}
|
||||
|
||||
if ( sel.error( network.fd() ) ) {
|
||||
if ( sel.error( network_fd ) ) {
|
||||
/* network problem */
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -324,7 +324,12 @@ void STMClient::main( void )
|
||||
/* poll for events */
|
||||
/* network->fd() can in theory change over time */
|
||||
sel.clear_fds();
|
||||
sel.add_fd( network->fd() );
|
||||
std::vector< int > fd_list( network->fds() );
|
||||
for ( std::vector< int >::const_iterator it = fd_list.begin();
|
||||
it != fd_list.end();
|
||||
it++ ) {
|
||||
sel.add_fd( *it );
|
||||
}
|
||||
sel.add_fd( STDIN_FILENO );
|
||||
|
||||
int active_fds = sel.select( wait_time );
|
||||
@@ -333,8 +338,24 @@ void STMClient::main( void )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( sel.read( network->fd() ) ) {
|
||||
/* packet received from the network */
|
||||
bool network_ready_to_read = false;
|
||||
|
||||
for ( std::vector< int >::const_iterator it = fd_list.begin();
|
||||
it != fd_list.end();
|
||||
it++ ) {
|
||||
if ( sel.read( *it ) ) {
|
||||
/* packet received from the network */
|
||||
/* we only read one socket each run */
|
||||
network_ready_to_read = true;
|
||||
}
|
||||
|
||||
if ( sel.error( *it ) ) {
|
||||
/* network problem */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( network_ready_to_read ) {
|
||||
if ( !process_network_input() ) { return; }
|
||||
}
|
||||
|
||||
@@ -370,11 +391,6 @@ void STMClient::main( void )
|
||||
}
|
||||
}
|
||||
|
||||
if ( sel.error( network->fd() ) ) {
|
||||
/* network problem */
|
||||
break;
|
||||
}
|
||||
|
||||
if ( sel.error( STDIN_FILENO ) ) {
|
||||
/* user problem */
|
||||
if ( !network->has_remote_addr() ) {
|
||||
|
||||
Reference in New Issue
Block a user