Changeset 416b0e4


Ignore:
Timestamp:
Jan 17, 2009 5:28:37 PM (12 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
807f0665
Parents:
0ea532c7
Message:

Prevent two NTCP Pumpers

Location:
router/java/src/net/i2p/router/transport
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java

    r0ea532c7 r416b0e4  
    286286        t.stopListening();
    287287        newAddr.setOptions(newProps);
    288         // Give NTCP Pumper time to stop so we don't end up with two...
    289         // Need better way
    290         try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
     288        // Wait for NTCP Pumper to stop so we don't end up with two...
     289        while (t.isAlive()) {
     290            try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
     291        }
    291292        t.restartListening(newAddr);
    292293        _log.warn("Changed NTCP Address and started up, address is now " + newAddr);
  • router/java/src/net/i2p/router/transport/ntcp/EventPumper.java

    r0ea532c7 r416b0e4  
    8686    }
    8787   
     88    /**
     89     *  Selector can take quite a while to close after calling stopPumping()
     90     */
     91    public boolean isAlive() {
     92        return _alive || (_selector != null && _selector.isOpen());
     93    }
     94
    8895    public void register(ServerSocketChannel chan) {
    8996        if (_log.shouldLog(Log.DEBUG)) _log.debug("Registering server socket channel");
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    r0ea532c7 r416b0e4  
    433433    }
    434434
     435    public boolean isAlive() {
     436        return _pumper.isAlive();
     437    }
     438
    435439    private RouterAddress bindAddress() {
    436440        if (_myAddress != null) {
     
    539543    }
    540544   
     545    /**
     546     *  This doesn't (completely) block, caller should check isAlive()
     547     *  before calling startListening() or restartListening()
     548     */
    541549    public void stopListening() {
    542550        if (_log.shouldLog(Log.DEBUG)) _log.debug("Stopping ntcp transport");
Note: See TracChangeset for help on using the changeset viewer.