(zzz)
* i2psnark: Second try at synchronization fix - synch addRequest() completely rather than just portions of it and requestNextPiece()
This commit is contained in:
@ -462,16 +462,12 @@ class PeerState
|
|||||||
/**
|
/**
|
||||||
* Adds a new request to the outstanding requests list.
|
* Adds a new request to the outstanding requests list.
|
||||||
*/
|
*/
|
||||||
private void addRequest()
|
synchronized private void addRequest()
|
||||||
{
|
{
|
||||||
boolean more_pieces = true;
|
boolean more_pieces = true;
|
||||||
while (more_pieces)
|
while (more_pieces)
|
||||||
{
|
|
||||||
synchronized(this)
|
|
||||||
{
|
{
|
||||||
more_pieces = outstandingRequests.size() < MAX_PIPELINE;
|
more_pieces = outstandingRequests.size() < MAX_PIPELINE;
|
||||||
}
|
|
||||||
|
|
||||||
// We want something and we don't have outstanding requests?
|
// We want something and we don't have outstanding requests?
|
||||||
if (more_pieces && lastRequest == null)
|
if (more_pieces && lastRequest == null)
|
||||||
more_pieces = requestNextPiece();
|
more_pieces = requestNextPiece();
|
||||||
@ -479,18 +475,13 @@ class PeerState
|
|||||||
{
|
{
|
||||||
int pieceLength;
|
int pieceLength;
|
||||||
boolean isLastChunk;
|
boolean isLastChunk;
|
||||||
synchronized(this)
|
|
||||||
{
|
|
||||||
pieceLength = metainfo.getPieceLength(lastRequest.piece);
|
pieceLength = metainfo.getPieceLength(lastRequest.piece);
|
||||||
isLastChunk = lastRequest.off + lastRequest.len == pieceLength;
|
isLastChunk = lastRequest.off + lastRequest.len == pieceLength;
|
||||||
}
|
|
||||||
|
|
||||||
// Last part of a piece?
|
// Last part of a piece?
|
||||||
if (isLastChunk)
|
if (isLastChunk)
|
||||||
more_pieces = requestNextPiece();
|
more_pieces = requestNextPiece();
|
||||||
else
|
else
|
||||||
{
|
|
||||||
synchronized(this)
|
|
||||||
{
|
{
|
||||||
int nextPiece = lastRequest.piece;
|
int nextPiece = lastRequest.piece;
|
||||||
int nextBegin = lastRequest.off + PARTSIZE;
|
int nextBegin = lastRequest.off + PARTSIZE;
|
||||||
@ -507,7 +498,6 @@ class PeerState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug(peer + " requests " + outstandingRequests);
|
_log.debug(peer + " requests " + outstandingRequests);
|
||||||
@ -523,8 +513,6 @@ class PeerState
|
|||||||
// Check for adopting an orphaned partial piece
|
// Check for adopting an orphaned partial piece
|
||||||
Request r = listener.getPeerPartial(bitfield);
|
Request r = listener.getPeerPartial(bitfield);
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
synchronized(this)
|
|
||||||
{
|
|
||||||
// Check that r not already in outstandingRequests
|
// Check that r not already in outstandingRequests
|
||||||
int[] arr = getRequestedPieces();
|
int[] arr = getRequestedPieces();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@ -542,12 +530,9 @@ class PeerState
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
int nextPiece = listener.wantPiece(peer, bitfield);
|
int nextPiece = listener.wantPiece(peer, bitfield);
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug(peer + " want piece " + nextPiece);
|
_log.debug(peer + " want piece " + nextPiece);
|
||||||
synchronized(this)
|
|
||||||
{
|
|
||||||
if (nextPiece != -1
|
if (nextPiece != -1
|
||||||
&& (lastRequest == null || lastRequest.piece != nextPiece))
|
&& (lastRequest == null || lastRequest.piece != nextPiece))
|
||||||
{
|
{
|
||||||
@ -563,7 +548,6 @@ class PeerState
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
$Id: history.txt,v 1.528 2006-09-26 23:44:13 complication Exp $
|
$Id: history.txt,v 1.529 2006-09-27 01:00:33 jrandom Exp $
|
||||||
|
|
||||||
|
2006-09-29 zzz
|
||||||
|
* i2psnark: Second try at synchronization fix - synch addRequest()
|
||||||
|
completely rather than just portions of it and requestNextPiece()
|
||||||
|
|
||||||
2006-09-27 jrandom
|
2006-09-27 jrandom
|
||||||
* added HMAC-SHA256
|
* added HMAC-SHA256
|
||||||
|
@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RouterVersion {
|
public class RouterVersion {
|
||||||
public final static String ID = "$Revision: 1.463 $ $Date: 2006-09-26 23:02:15 $";
|
public final static String ID = "$Revision: 1.464 $ $Date: 2006-09-27 01:00:37 $";
|
||||||
public final static String VERSION = "0.6.1.25";
|
public final static String VERSION = "0.6.1.25";
|
||||||
public final static long BUILD = 10;
|
public final static long BUILD = 11;
|
||||||
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