Allow new states slowly even when queue full (fixes Axel Beckert lockup)

This commit is contained in:
Keith Winstein
2013-01-15 02:03:10 -05:00
parent e9c4184c27
commit 2dcef54e24
2 changed files with 12 additions and 4 deletions
+7
View File
@@ -45,6 +45,7 @@ Transport<MyState, RemoteState>::Transport( MyState &initial_state, RemoteState
: connection( desired_ip, desired_port ),
sender( &connection, initial_state ),
received_states( 1, TimestampedState<RemoteState>( timestamp(), 0, initial_remote ) ),
receiver_quench_timer( 0 ),
last_receiver_state( initial_remote ),
fragments(),
verbose( false )
@@ -58,6 +59,7 @@ Transport<MyState, RemoteState>::Transport( MyState &initial_state, RemoteState
: connection( key_str, ip, port ),
sender( &connection, initial_state ),
received_states( 1, TimestampedState<RemoteState>( timestamp(), 0, initial_remote ) ),
receiver_quench_timer( 0 ),
last_receiver_state( initial_remote ),
fragments(),
verbose( false )
@@ -116,11 +118,16 @@ void Transport<MyState, RemoteState>::recv( void )
process_throwaway_until( inst.throwaway_num() );
if ( received_states.size() > 1024 ) { /* limit on state queue */
uint64_t now = timestamp();
if ( now < receiver_quench_timer ) { /* deny letting state grow further */
if ( verbose ) {
fprintf( stderr, "[%u] Receiver queue full, discarding %d (malicious sender or long-unidirectional connectivity?)\n",
(unsigned int)(timestamp() % 100000), (int)inst.new_num() );
}
return;
} else {
receiver_quench_timer = now + 15000;
}
}
/* apply diff to reference state */
+1
View File
@@ -60,6 +60,7 @@ namespace Network {
/* simple receiver */
list< TimestampedState<RemoteState> > received_states;
uint64_t receiver_quench_timer;
RemoteState last_receiver_state; /* the state we were in when user last queried state */
FragmentAssembly fragments;
bool verbose;