Changeset 036b777
- Timestamp:
- Jun 17, 2015 2:16:06 AM (6 years ago)
- Branches:
- master
- Children:
- 8096e4f6
- Parents:
- bc85543
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
core/java/src/net/i2p/client/I2PSessionImpl.java
rbc85543 r036b777 82 82 private SessionId _sessionId; 83 83 /** currently granted lease set, or null */ 84 pr ivatevolatile LeaseSet _leaseSet;84 protected volatile LeaseSet _leaseSet; 85 85 86 86 // subsession stuff … … 131 131 132 132 /** monitor for waiting until a lease set has been granted */ 133 pr ivatefinal Object _leaseSetWait = new Object();133 protected final Object _leaseSetWait = new Object(); 134 134 135 135 /** -
core/java/src/net/i2p/client/SubSession.java
rbc85543 r036b777 102 102 } 103 103 } 104 _primary.connect(); 105 synchronized(_stateLock) { 106 if (_state != State.OPEN) { 107 Thread notifier = new I2PAppThread(_availabilityNotifier, "ClientNotifier " + getPrefix(), true); 108 notifier.start(); 109 _state = State.OPEN; 104 boolean success = false; 105 try { 106 _primary.connect(); 107 // wait until we have created a lease set 108 int waitcount = 0; 109 while (_leaseSet == null) { 110 if (waitcount++ > 5*60) { 111 throw new IOException("No tunnels built after waiting 5 minutes. Your network connection may be down, or there is severe network congestion."); 112 } 113 synchronized (_leaseSetWait) { 114 // InterruptedException caught below 115 _leaseSetWait.wait(1000); 116 } 117 } 118 synchronized(_stateLock) { 119 if (_state != State.OPEN) { 120 Thread notifier = new I2PAppThread(_availabilityNotifier, "ClientNotifier " + getPrefix(), true); 121 notifier.start(); 122 _state = State.OPEN; 123 } 124 } 125 success = true; 126 } catch (InterruptedException ie) { 127 throw new I2PSessionException("Interrupted", ie); 128 } catch (IOException ioe) { 129 throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, ioe); 130 } finally { 131 if (!success) { 132 _availabilityNotifier.stopNotifying(); 133 changeState(State.CLOSED); 110 134 } 111 135 } -
core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java
rbc85543 r036b777 159 159 160 160 public void run() { 161 try { 162 run2(); 163 } catch (Exception e) { 164 _log.log(Log.CRIT, "Uncaught I2CP error", e); 165 _listener.readError(I2CPMessageReader.this, e); 166 cancelRunner(); 167 } 168 } 169 170 /** 171 * Called by run() 172 * @since 0.9.21 173 */ 174 protected void run2() { 161 175 while (_stayAlive) { 162 176 while (_doRun) { -
core/java/src/net/i2p/internal/QueuedI2CPMessageReader.java
rbc85543 r036b777 43 43 */ 44 44 @Override 45 p ublic void run() {45 protected void run2() { 46 46 while (_stayAlive) { 47 47 while (_doRun) { -
router/java/src/net/i2p/router/client/ClientConnectionRunner.java
rbc85543 r036b777 229 229 * will be null if session not found 230 230 * IS subsession aware. 231 * Returns null if id is null. 231 232 * @since 0.9.21 added id param 232 233 */ 233 234 public SessionConfig getConfig(SessionId id) { 235 if (id == null) 236 return null; 234 237 for (SessionParams sp : _sessions.values()) { 235 238 if (id.equals(sp.sessionId)) … … 318 321 */ 319 322 public Hash getDestHash(SessionId id) { 323 if (id == null) 324 return null; 320 325 for (Map.Entry<Hash, SessionParams> e : _sessions.entrySet()) { 321 326 if (id.equals(e.getValue().sessionId)) … … 331 336 */ 332 337 public Destination getDestination(SessionId id) { 338 if (id == null) 339 return null; 333 340 for (SessionParams sp : _sessions.values()) { 334 341 if (id.equals(sp.sessionId)) … … 392 399 if (hash == null) 393 400 throw new IllegalStateException(); 401 if (id == null) 402 throw new NullPointerException(); 394 403 SessionParams sp = _sessions.get(hash); 395 404 if (sp == null || sp.sessionId != null) … … 404 413 */ 405 414 void removeSession(SessionId id) { 415 if (id == null) 416 return; 406 417 boolean isPrimary = false; 407 418 for (Iterator<SessionParams> iter = _sessions.values().iterator(); iter.hasNext(); ) { … … 814 825 state = sp.leaseRequest; 815 826 if (state != null) { 816 if (_log.shouldLog(Log.DEBUG))817 _log.debug("Already requesting " + state);818 827 LeaseSet requested = state.getRequested(); 819 828 LeaseSet granted = state.getGranted(); … … 822 831 ( (granted != null) && (granted.getEarliestLeaseDate() > ours) ) ) { 823 832 // theirs is newer 833 if (_log.shouldLog(Log.DEBUG)) 834 _log.debug("Already requesting, theirs newer, do nothing: " + state); 824 835 } else { 825 836 // ours is newer, so wait a few secs and retry 826 837 set.setDestination(dest); 827 838 _context.simpleTimer2().addEvent(new Rerequest(set, expirationTime, onCreateJob, onFailedJob), 3*1000); 839 if (_log.shouldLog(Log.DEBUG)) 840 _log.debug("Already requesting, ours newer, wait 3 sec: " + state); 828 841 } 829 842 // fire onCreated? -
router/java/src/net/i2p/router/client/ClientMessageEventListener.java
rbc85543 r036b777 81 81 */ 82 82 public void messageReceived(I2CPMessageReader reader, I2CPMessage message) { 83 if (_runner.isDead()) return; 83 if (_runner.isDead()) { 84 if (_log.shouldLog(Log.WARN)) 85 _log.warn("Received but runner dead: \n" + message); 86 return; 87 } 84 88 if (_log.shouldLog(Log.DEBUG)) 85 89 _log.debug("Message received: \n" + message); … … 363 367 if (cfg == null) { 364 368 if (_log.shouldLog(Log.ERROR)) 365 _log.error("SendMessage w/o session ");366 _runner.disconnectClient("SendMessage w/o session ");369 _log.error("SendMessage w/o session: " + sid); 370 _runner.disconnectClient("SendMessage w/o session: " + sid); 367 371 return; 368 372 } … … 373 377 long timeToDistribute = _context.clock().now() - beforeDistribute; 374 378 // TODO validate session id 375 _runner.ackSendMessage( message.getSessionId(), id, message.getNonce());379 _runner.ackSendMessage(sid, id, message.getNonce()); 376 380 _context.statManager().addRateData("client.distributeTime", timeToDistribute); 377 if ( (timeToDistribute > 50) && (_log.shouldLog(Log. INFO)) )378 _log. info("Took too long to distribute the message (which holds up the ack): " + timeToDistribute);381 if ( (timeToDistribute > 50) && (_log.shouldLog(Log.DEBUG)) ) 382 _log.debug("Took too long to distribute the message (which holds up the ack): " + timeToDistribute); 379 383 } 380 384 … … 387 391 if (_runner.isDead()) return; 388 392 if (_log.shouldLog(Log.DEBUG)) 389 _log.debug("Handling rec ieve begin: id = " + message.getMessageId());393 _log.debug("Handling receive begin: id = " + message.getMessageId()); 390 394 MessagePayloadMessage msg = new MessagePayloadMessage(); 391 395 msg.setMessageId(message.getMessageId()); … … 410 414 411 415 /** 412 * The client told us that the message has been rec ieved completely. This currently416 * The client told us that the message has been received completely. This currently 413 417 * does not do any security checking prior to removing the message from the 414 418 * pending queue, though it should. … … 444 448 if (cfg == null) { 445 449 if (_log.shouldLog(Log.ERROR)) 446 _log.error("CreateLeaseSet w/o session ");447 _runner.disconnectClient("CreateLeaseSet w/o session ");450 _log.error("CreateLeaseSet w/o session: " + id); 451 _runner.disconnectClient("CreateLeaseSet w/o session: " + id); 448 452 return; 449 453 } … … 534 538 if (cfg == null) { 535 539 if (_log.shouldLog(Log.ERROR)) 536 _log.error("ReconfigureSession w/o session ");540 _log.error("ReconfigureSession w/o session: " + id); 537 541 //sendStatusMessage(id, SessionStatusMessage.STATUS_INVALID); 538 _runner.disconnectClient("ReconfigureSession w/o session ");542 _runner.disconnectClient("ReconfigureSession w/o session: " + id); 539 543 return; 540 544 }
Note: See TracChangeset
for help on using the changeset viewer.