i2psnark: Fix leaked requests and partial pieces with data

This commit is contained in:
zzz
2024-06-04 11:32:57 +00:00
parent 4b9a0ddcbc
commit 4659a922b8
4 changed files with 93 additions and 63 deletions
@@ -371,7 +371,7 @@ class WebPeer extends Peer implements EepGet.StatusListener {
PartialPiece pp = last.getPartialPiece();
synchronized(pp) {
// Last chunk needed for this piece?
if (pp.getLength() == pp.getDownloaded()) {
if (pp.isComplete()) {
if (listener.gotPiece(this, pp)) {
if (_log.shouldDebug())
_log.debug("Got " + piece + ": " + this);
@@ -650,15 +650,8 @@ class WebPeer extends Peer implements EepGet.StatusListener {
List<Request> rv = new ArrayList<Request>(pcs.size());
for (Integer p : pcs) {
Request req = getLowestOutstandingRequest(p.intValue());
if (req != null) {
PartialPiece pp = req.getPartialPiece();
synchronized(pp) {
int dl = pp.getDownloaded();
if (req.off != dl)
req = new Request(pp, dl);
}
if (req != null)
rv.add(req);
}
}
outstandingRequests.clear();
return rv;