Changeset 1298


Ignore:
Timestamp:
Feb 25, 2011, 2:25:09 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

Fixes issues with connecting to a tracker if it doesn't immediately respond or if no peers are currently available. Previously the tracker was only updated when a peer was disconnected and if no peer could be contacted in the first place the download would never start. This should hopefully fix the problems mentioned in [1255].

Location:
extensions/net.sf.basedb.torrent/trunk/src/external/hpbtc/hpbtc/protocol
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.torrent/trunk/src/external/hpbtc/hpbtc/protocol/processor/MessageWriter.java

    r1248 r1298  
    8080                contactFreshPeers(torrent);
    8181                torrent.setTrackerTask(null);
     82               
     83                if (torrent.getRemainingPeers() < 20) {
     84                    scheduleTrackerTask(torrent,
     85                            torrent.getTracker().getRemainingMillisUntilUpdate());
     86                }
    8287            }
    8388        };
     
    114119                torrent.beginTracker();
    115120                contactFreshPeers(torrent);
     121                if (torrent.getRemainingPeers() < 20) {
     122                    scheduleTrackerTask(torrent,
     123                            torrent.getTracker().getRemainingMillisUntilUpdate());
     124                }
    116125            }
    117126        };
  • extensions/net.sf.basedb.torrent/trunk/src/external/hpbtc/hpbtc/protocol/torrent/Tracker.java

    r1248 r1298  
    3030    private String byteEncoding;
    3131    private int complete;
    32     private int interval;
     32    private int interval = 60;
    3333    private int incomplete;
    3434    private byte[] trackerId;
    35     private int minInterval;
     35    private int minInterval = 60;
    3636    private byte[] infoHash;
    3737    private byte[] pid;
     
    5959    public Set<Peer> updateTracker(final Event event, final long uploaded,
    6060            final long downloaded, final long bytesLeft, final boolean compact) {
    61         for (LinkedList<byte[]> ul : trackers) {
     61      lastTrackerContact = System.currentTimeMillis();
     62      for (LinkedList<byte[]> ul : trackers) {
    6263            final Iterator<byte[]> i = ul.iterator();
    6364            while (i.hasNext()) {
     
    6667                    final Set<Peer> peers = connectToTracker(event, tracker,
    6768                            uploaded, downloaded, bytesLeft, compact);
    68                     lastTrackerContact = System.currentTimeMillis();
    6969                    i.remove();
    7070                    ul.addFirst(tracker);
     
    7272                    return peers;
    7373                } catch (IOException e) {
    74                     logger.log(Level.FINE, e.getLocalizedMessage(), e);
     74                    logger.log(Level.WARNING, e.getLocalizedMessage(), e);
    7575                }
    7676            }
     
    150150            }
    151151            final Object o = response.get("peers".getBytes(byteEncoding));
    152             return o instanceof List ? TrackerUtil.doLoosePeer((List<Map<byte[], Object>>) o,
    153                     byteEncoding) : TrackerUtil.doCompactPeer((byte[]) o);
     152            if (o != null)
     153            {
     154              return o instanceof List ? TrackerUtil.doLoosePeer((List<Map<byte[], Object>>) o,
     155                      byteEncoding) : TrackerUtil.doCompactPeer((byte[]) o);
     156            }
    154157        }
    155158        return new HashSet<Peer>();
Note: See TracChangeset for help on using the changeset viewer.