Opened 9 years ago

Closed 9 years ago

#669 closed enhancement (fixed)

Postpone establishment timeout if anything received

Reported by: Zlatin Balevsky Owned by: zzz
Priority: minor Milestone: 0.9.2
Component: router/transport Version: 0.9
Keywords: SSU Cc:
Parent Tickets: Sensitive: no


The current session establishment timeout is hardcoded to 10 seconds. Sometimes Bob is more than 5 seconds away but is up and running fine, in these cases Alice times out before a session can be established and that results in a "path" exception. One way to handle this is to be lenient and postpone the timeout once if Alice received anything at all from Bob.

More detailed description: http://zzz.i2p/topics/1198 post 10
Log fragment demonstrating the scenario: http://pastethis.i2p/show/1497/
Suggestion how to fix against trunk: http://pastethis.i2p/show/1507
Suggestion how to fix against ST2: http://pastethis.i2p/show/1508

the trunk version:

# old_revision [2f0cb347b150657d54b5fa0c059c3f6d1dbcbe29]
# patch "router/java/src/net/i2p/router/transport/udp/"
#  from [edb5f79e5c6206e7408de1a25073481d5839dfcc]
#    to [bdbcbeebbcc10f0217debd62ee523b02605eaeb4]
--- router/java/src/net/i2p/router/transport/udp/	edb5f79e5c6206e7408de1a25073481d5839dfcc
+++ router/java/src/net/i2p/router/transport/udp/	bdbcbeebbcc10f0217debd62ee523b02605eaeb4
@@ -6,6 +6,7 @@ import java.util.concurrent.ConcurrentHa
 import java.util.Iterator;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
@@ -25,6 +26,8 @@ import net.i2p.util.SimpleTimer;
 import net.i2p.util.SimpleScheduler;
 import net.i2p.util.SimpleTimer;
+import static net.i2p.router.transport.udp.OutboundEstablishState.*;
  * Coordinate the establishment of new sessions - both inbound and outbound.
  * This has its own thread to add packets to the packet queue when necessary,
@@ -254,11 +257,22 @@ class EstablishmentManager {
     private class Expire implements SimpleTimer.TimedEvent {
         private RemoteHostId _to;
         private OutboundEstablishState _state;
+        private AtomicBoolean _secondChance = new AtomicBoolean(true);
         public Expire(RemoteHostId to, OutboundEstablishState state) { 
             _to = to;
             _state = state; 
         public void timeReached() {
+        	// give a second chance we received anything at all from the remote side
+        	switch(_state.getState()) {
+        		if (!_secondChance.compareAndSet(true,false))
+        			break; // already given second chance
+        		SimpleScheduler.getInstance().addEvent(this, 10*1000);
+        		return;
+        	default : break;
+        	}
             // remove only if value == state
             boolean removed = _outboundStates.remove(_to, _state);
             if (removed) {


Change History (3)

comment:1 Changed 9 years ago by Zlatin Balevsky

Example of a session that was given a second chance and established successfully: http://pastethis.i2p/show/1514/

comment:2 Changed 9 years ago by zzz

Milestone: 0.9.2
Status: newaccepted

I think you're on the right track with this

comment:3 Changed 9 years ago by zzz

Resolution: fixed
Status: acceptedclosed

Fixed in 0.9.1-8:

  • Removed all SimpleTimer? use in establishment manager, moved everything to be handled in the Establisher thread, for sanity
  • Increased total establishment timeouts
  • Implemented timeouts for individual establishment phases (states)
  • Many other establishment state machine changes and bug fixes which will hopefully reduce "path" exceptions, i.e. unknown messages

Not claiming this fixes all causes of "path" but it should fix the timeout issue stated in the OP.

Note: See TracTickets for help on using tickets.