mosh-server: Fix bug where spins forever if process dies while disconnected

This commit is contained in:
Keith Winstein
2012-11-26 01:45:07 -05:00
parent 6a16eecce0
commit 486325e76b
3 changed files with 28 additions and 25 deletions
+10 -1
View File
@@ -56,6 +56,7 @@ TransportSender<MyState>::TransportSender( Connection *s_connection, MyState &in
verbose( false ),
shutdown_in_progress( false ),
shutdown_tries( 0 ),
shutdown_start( -1 ),
ack_num( 0 ),
pending_data_ack( false ),
SEND_MINDELAY( 8 ),
@@ -357,7 +358,15 @@ void TransportSender<MyState>::process_acknowledgment_through( uint64_t ack_num
template <class MyState>
bool TransportSender<MyState>::shutdown_ack_timed_out( void ) const
{
return shutdown_tries >= SHUTDOWN_RETRIES;
if ( shutdown_in_progress ) {
if ( shutdown_tries >= SHUTDOWN_RETRIES ) {
return true;
} else if ( timestamp() - shutdown_start >= uint64_t( ACTIVE_RETRY_TIMEOUT ) ) {
return true;
}
}
return false;
}
/* Executed upon entry to new receiver state */
+2 -1
View File
@@ -94,6 +94,7 @@ namespace Network {
bool verbose;
bool shutdown_in_progress;
int shutdown_tries;
uint64_t shutdown_start;
/* information about receiver state */
uint64_t ack_num;
@@ -132,7 +133,7 @@ namespace Network {
void remote_heard( uint64_t ts ) { last_heard = ts; }
/* Starts shutdown sequence */
void start_shutdown( void ) { shutdown_in_progress = true; }
void start_shutdown( void ) { if ( !shutdown_in_progress ) { shutdown_start = timestamp(); shutdown_in_progress = true; } }
/* Misc. getters and setters */
/* Cannot modify current_state while shutdown in progress */