Changeset a6a0228


Ignore:
Timestamp:
Aug 11, 2012 11:23:27 AM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c70e372
Parents:
d2a5595
Message:
  • i2psnark: Fix DHT nodes not being saved at shutdown

Log infohashes in hex
Don't write out nodes if we don't have any

Location:
apps/i2psnark/java/src/org/klomp/snark
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java

    rd2a5595 ra6a0228  
    3737import net.i2p.util.SimpleScheduler;
    3838import net.i2p.util.SimpleTimer;
     39
     40import org.klomp.snark.dht.DHT;
    3941
    4042/**
     
    17531755        if (_util.connected()) {
    17541756            if (count > 0) {
     1757                DHT dht = _util.getDHT();
     1758                if (dht != null)
     1759                    dht.stop();
    17551760                // Schedule this even for final shutdown, as there's a chance
    17561761                // that it's just this webapp that is stopping.
  • apps/i2psnark/java/src/org/klomp/snark/dht/InfoHash.java

    rd2a5595 ra6a0228  
    55
    66import net.i2p.crypto.SHA1Hash;
     7import org.klomp.snark.I2PSnarkUtil;
    78
    89/**
     
    1718        super(data);
    1819    }
     20
     21    @Override
     22    public String toString() {
     23        if (_data == null) {
     24            return super.toString();
     25        } else {
     26            return "[InfoHash: " + I2PSnarkUtil.toHex(_data) + ']';
     27        }
     28    }
    1929}
  • apps/i2psnark/java/src/org/klomp/snark/dht/KRPC.java

    rd2a5595 ra6a0228  
    177177        _knownNodes = new DHTNodes(ctx, _myNID);
    178178
    179         session.addMuxedSessionListener(this, I2PSession.PROTO_DATAGRAM_RAW, _rPort);
    180         session.addMuxedSessionListener(this, I2PSession.PROTO_DATAGRAM, _qPort);
    181179        start();
    182180    }
     
    518516     *  Can't be restarted after stopping?
    519517     */
    520     public void start() {
     518    public synchronized void start() {
     519        if (_isRunning)
     520            return;
     521        session.addMuxedSessionListener(this, I2PSession.PROTO_DATAGRAM_RAW, _rPort);
     522        session.addMuxedSessionListener(this, I2PSession.PROTO_DATAGRAM, _qPort);
    521523        _knownNodes.start();
    522524        _tracker.start();
     
    537539     *  Stop everything.
    538540     */
    539     public void stop() {
     541    public synchronized void stop() {
     542        if (!_isRunning)
     543            return;
    540544        _isRunning = false;
    541545        // FIXME stop the explore thread
  • apps/i2psnark/java/src/org/klomp/snark/dht/PersistDHT.java

    rd2a5595 ra6a0228  
    5757
    5858    public static synchronized void saveDHT(DHTNodes nodes, File file) {
     59        if (nodes.isEmpty())
     60            return;
    5961        Log log = I2PAppContext.getGlobalContext().logManager().getLog(PersistDHT.class);
    6062        int count = 0;
Note: See TracChangeset for help on using the changeset viewer.