private boolean addInternal(RemoteFileDesc host) { // initialize the sha1 if we don't have one if (sha1 == null) { if (host.getSHA1Urn() != null) sha1 = host.getSHA1Urn(); else // BUGFIX: We can't discard sources w/out a SHA1 when we dont' have // a SHA1 for the download, or else it won't be possible to download a // file from a query hit without a SHA1, if we can received UDP pings return testedLocations.add(host); // we can't do anything yet } // do not allow duplicate hosts if (running && knowsAboutHost(host)) return false; if (LOG.isDebugEnabled()) LOG.debug("adding new host " + host + " " + host.getPushAddr()); boolean ret = false; // don't bother ranking multicasts if (host.isReplyToMulticast()) ret = verifiedHosts.add(host); else ret = newHosts.add(host); // rank // make sure that if we were stopped, we return true ret = ret | !running; // initialize the guid if we don't have one if (myGUID == null && meshHandler != null) { myGUID = new GUID(GUID.makeGuid()); RouterService.getMessageRouter().registerMessageListener(myGUID.bytes(), this); } return ret; }
protected synchronized void clearState() { if (myGUID != null) { RouterService.getMessageRouter().unregisterMessageListener(myGUID.bytes(), this); myGUID = null; } }