From e2bdb0dcd12c42342a84614981703c489aa0cee4 Mon Sep 17 00:00:00 2001 From: Louis Royer Date: Mon, 13 Apr 2020 22:04:14 +0200 Subject: [PATCH] Fix udp sending ratio for tracker instead of server used --- src/clientP2P/ClientDownloadUDP.java | 2 +- src/tracker/TrackerManagement.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/clientP2P/ClientDownloadUDP.java b/src/clientP2P/ClientDownloadUDP.java index 50f4081..cd56769 100644 --- a/src/clientP2P/ClientDownloadUDP.java +++ b/src/clientP2P/ClientDownloadUDP.java @@ -64,7 +64,7 @@ public class ClientDownloadUDP extends ClientDownload { * @param hostItem Hostitem of the server */ protected ClientDownloadPart createDownloadPart(HostItem hostItem) { - return (ClientDownloadPart)new ClientDownloadPartUDP((ClientDownload)this, filename, hostItem.getUDPSocket(), partsSubdir, logger, client, tracker); + return (ClientDownloadPart)new ClientDownloadPartUDP((ClientDownload)this, filename, hostItem.getUDPSocket(), partsSubdir, logger, client, hostItem); } /** Implementation of writeLog diff --git a/src/tracker/TrackerManagement.java b/src/tracker/TrackerManagement.java index d94da76..00c75ba 100644 --- a/src/tracker/TrackerManagement.java +++ b/src/tracker/TrackerManagement.java @@ -259,7 +259,11 @@ public abstract class TrackerManagement extends ServeErrors implements Runnable while(readLock.get() > 0) { this.wait(); } - if (!ratioDown.containsKey(updateRatioClient) || ! ratioUp.containsKey(updateRatioServer)) { + if (!ratioDown.containsKey(updateRatioClient)) { + writeLog("Unkwnow client host " + updateRatioClient, LogLevel.Debug); + sendUnknownHost(pd); + } else if (!ratioUp.containsKey(updateRatioServer)) { + writeLog("Unkwnow server host " + updateRatioServer, LogLevel.Debug); sendUnknownHost(pd); } else { ratioDown.put(updateRatioClient, Long.valueOf(ratioDown.get(updateRatioClient).longValue() + ratioSize));