(zzz)
* i2psnark: Implement retransmission of requests. This eliminates one cause of complete stalls with a peer. This problem is common on torrents with a small number of active peers where there are no choke/unchokes to kickstart things.
This commit is contained in:
@ -477,4 +477,14 @@ public class Peer implements Comparable
|
|||||||
s.keepAlive();
|
s.keepAlive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retransmit outstanding requests if necessary
|
||||||
|
*/
|
||||||
|
public void retransmitRequests()
|
||||||
|
{
|
||||||
|
PeerState s = state;
|
||||||
|
if (s != null)
|
||||||
|
s.retransmitRequests();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,7 @@ class PeerCheckerTask extends TimerTask
|
|||||||
worstDownloader = peer;
|
worstDownloader = peer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
peer.retransmitRequests();
|
||||||
peer.keepAlive();
|
peer.keepAlive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,6 +324,23 @@ class PeerConnectionOut implements Runnable
|
|||||||
addMessage(m);
|
addMessage(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** reransmit requests not received in 7m */
|
||||||
|
private static final int REQ_TIMEOUT = (2 * SEND_TIMEOUT) + (60 * 1000);
|
||||||
|
void retransmitRequests(List requests)
|
||||||
|
{
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
Iterator it = requests.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
Request req = (Request)it.next();
|
||||||
|
if(now > req.sendTime + REQ_TIMEOUT) {
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug("Retransmit request " + req + " to peer " + peer);
|
||||||
|
sendRequest(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void sendRequests(List requests)
|
void sendRequests(List requests)
|
||||||
{
|
{
|
||||||
Iterator it = requests.iterator();
|
Iterator it = requests.iterator();
|
||||||
@ -336,12 +353,15 @@ class PeerConnectionOut implements Runnable
|
|||||||
|
|
||||||
void sendRequest(Request req)
|
void sendRequest(Request req)
|
||||||
{
|
{
|
||||||
|
// should we check for duplicate requests to deal with fibrillating i2p-bt??
|
||||||
|
// or just send some cancels when we get an unwanted chunk??
|
||||||
Message m = new Message();
|
Message m = new Message();
|
||||||
m.type = Message.REQUEST;
|
m.type = Message.REQUEST;
|
||||||
m.piece = req.piece;
|
m.piece = req.piece;
|
||||||
m.begin = req.off;
|
m.begin = req.off;
|
||||||
m.length = req.len;
|
m.length = req.len;
|
||||||
addMessage(m);
|
addMessage(m);
|
||||||
|
req.sendTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendPiece(int piece, int begin, int length, byte[] bytes)
|
void sendPiece(int piece, int begin, int length, byte[] bytes)
|
||||||
|
@ -596,4 +596,10 @@ class PeerState
|
|||||||
{
|
{
|
||||||
out.sendAlive();
|
out.sendAlive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized void retransmitRequests()
|
||||||
|
{
|
||||||
|
if (interesting && !choked)
|
||||||
|
out.retransmitRequests(outstandingRequests);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ class Request
|
|||||||
final byte[] bs;
|
final byte[] bs;
|
||||||
final int off;
|
final int off;
|
||||||
final int len;
|
final int len;
|
||||||
|
long sendTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Request.
|
* Creates a new Request.
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
$Id: history.txt,v 1.520 2006-09-13 18:24:14 zzz Exp $
|
$Id: history.txt,v 1.521 2006-09-13 21:37:33 zzz Exp $
|
||||||
|
|
||||||
|
2006-09-16 zzz
|
||||||
|
* i2psnark: Implement retransmission of requests. This
|
||||||
|
eliminates one cause of complete stalls with a peer.
|
||||||
|
This problem is common on torrents with a small number of
|
||||||
|
active peers where there are no choke/unchokes to kickstart things.
|
||||||
|
|
||||||
2006-09-13 zzz
|
2006-09-13 zzz
|
||||||
* i2psnark: Fix restoral of partial pieces broken by last patch
|
* i2psnark: Fix restoral of partial pieces broken by last patch
|
||||||
|
@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RouterVersion {
|
public class RouterVersion {
|
||||||
public final static String ID = "$Revision: 1.457 $ $Date: 2006-09-13 18:02:07 $";
|
public final static String ID = "$Revision: 1.458 $ $Date: 2006-09-13 21:37:32 $";
|
||||||
public final static String VERSION = "0.6.1.25";
|
public final static String VERSION = "0.6.1.25";
|
||||||
public final static long BUILD = 4;
|
public final static long BUILD = 5;
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||||
System.out.println("Router ID: " + RouterVersion.ID);
|
System.out.println("Router ID: " + RouterVersion.ID);
|
||||||
|
Reference in New Issue
Block a user