private void unregisterRequestHandlerWithNode() { RequestSender r; synchronized(this) { r = rs; } if(r != null) { PeerNode p = r.successFrom(); if(p != null) tag.finishedWaitingForOpennet(p); } tag.unlockHandler(); }
public void setRequestSenderFinished(int status) { boolean noRecordUnlock; synchronized(this) { if(status == RequestSender.NOT_FINISHED) throw new IllegalArgumentException(); requestSenderFinishedCode = status; if(!mustUnlock()) return; noRecordUnlock = this.noRecordUnlock; } innerUnlock(noRecordUnlock); }
@Override public synchronized int expectedTransfersOut(boolean ignoreLocalVsRemote, int outwardTransfersPerInsert, boolean forAccept) { if(!accepted) return 0; if(completedDownstreamTransfers) return 0; if(forAccept && (sourceRestarted || unlockedHandler)) return 0; return ((!isLocal()) || ignoreLocalVsRemote) ? 1 : 0; }
ClientSSKBlock realGetSSK(ClientSSK key, boolean localOnly, boolean ignoreStore, boolean canWriteClientCache, boolean realTimeFlag) throws LowLevelGetException { long startTime = System.currentTimeMillis(); long uid = makeUID(); RequestTag tag = new RequestTag(true, RequestTag.START.LOCAL, null, realTimeFlag, uid, node); if(!tracker.lockUID(uid, true, false, false, true, realTimeFlag, tag)) { Logger.error(this, "Could not lock UID just randomly generated: " + uid + " - probably indicates broken PRNG"); throw new LowLevelGetException(LowLevelGetException.INTERNAL_ERROR); tag.setAccepted(); RequestSender rs = null; try { if(o instanceof SSKBlock) try { tag.setServedFromDatastore(); SSKBlock block = (SSKBlock) o; key.setPublicKey(block.getPubKey()); tag.unlockHandler();
Key key = (Key) m.getObject(DMT.FREENET_ROUTING_KEY); boolean realTimeFlag = DMT.getRealTimeFlag(m); final RequestTag tag = new RequestTag(isSSK, RequestTag.START.REMOTE, source, realTimeFlag, id, node); if(!tracker.lockUID(id, isSSK, false, false, false, realTimeFlag, tag)) { if(logMINOR) Logger.minor(this, "Could not lock ID "+id+" -> rejecting (already running)"); KeyBlock block = node.fetch(key, false, false, false, false, meta); if(block != null) tag.setNotRoutedOnwards(); Logger.normal(this, "Rejecting (overload) data request from "+source.getPeer()+": "+e); tag.setRejected(); tag.unlockHandler(rejectReason.soft);
@Override public void onCHKTransferBegins() { if(tag.hasSourceReallyRestarted()) { Logger.normal(this, "requestor is gone, can't send terminal message"); applyByteCounts(); tag.handlerTransferBegins(); bt.sendAsync(); } catch(NotConnectedException e) { disconnected = true; tag.handlerDisconnected(); Logger.normal(this, "requestor is gone, can't begin CHK transfer");
} else if (origTag.shouldStop()) { origTag.finishedWaitingForOpennet(next); origTag.finishedWaitingForOpennet(next); origTag.finishedWaitingForOpennet(next); } catch (WaitedTooLongForOpennetNoderefException e) { Logger.error(this, "RequestSender timed out waiting for noderef from "+next+" for "+this); origTag.timedOutToHandlerButContinued(); // Since we will tell downstream that we are finished. Logger.warning(this, "RequestSender timed out waiting for noderef from "+next+" for "+this); synchronized(this) {
final long uid = makeUID(); final boolean isSSK = key instanceof NodeSSK; final RequestTag tag = new RequestTag(isSSK, RequestTag.START.ASYNC_GET, null, realTimeFlag, uid, node); if(!tracker.lockUID(uid, isSSK, false, false, true, realTimeFlag, tag)) { Logger.error(this, "Could not lock UID just randomly generated: " + uid + " - probably indicates broken PRNG"); return; tag.setAccepted(); short htl = node.maxHTL();
@Override public void acknowledged() { synchronized(this) { if(completed) return; completed = true; } origTag.finishedWaitingForOpennet(next); }
@Override public void run() { freenet.support.Logger.OSThread.logPID(this); try { realRun(); //The last thing that realRun() does is register as a request-sender listener, so any exception here is the end. } catch(NotConnectedException e) { Logger.normal(this, "requestor gone, could not start request handler wait"); tag.handlerThrew(e); } catch(Throwable t) { Logger.error(this, "Caught " + t, t); tag.handlerThrew(t); } }
@Override public void logStillPresent(Long uid) { StringBuffer sb = new StringBuffer(); sb.append("Still present after ").append(TimeUtil.formatTime(age())); sb.append(" : ").append(uid).append(" : start=").append(start); sb.append(" ssk=").append(isSSK).append(" from store=").append(servedFromDatastore);
tag.handlerTransferBegins(); source.sendAsync(df, null, this); bt.sendAsync();
private OFFER_STATUS tryOffer(final BlockOffer offer, final PeerNode pn, final OfferList offers) { if(pn == null) return OFFER_STATUS.TRY_ANOTHER; if(pn.getBootID() != offer.bootID) return OFFER_STATUS.TRY_ANOTHER; origTag.addRoutedTo(pn, true); Message msg = DMT.createFNPGetOfferedKey(key, offer.authenticator, pubKey == null, uid); msg.addSubMessage(DMT.createFNPRealTimeFlag(realTimeFlag));
@Override public void onRequestSenderFinished(int status, boolean fromOfferedKey, RequestSender rs) { if(tag.hasSourceReallyRestarted()) { Logger.normal(this, "requestor is gone, can't send terminal message"); applyByteCounts();
long startTime = System.currentTimeMillis(); long uid = makeUID(); RequestTag tag = new RequestTag(false, RequestTag.START.LOCAL, null, realTimeFlag, uid, node); if(!tracker.lockUID(uid, false, false, false, true, realTimeFlag, tag)) { Logger.error(this, "Could not lock UID just randomly generated: " + uid + " - probably indicates broken PRNG"); throw new LowLevelGetException(LowLevelGetException.INTERNAL_ERROR); tag.setAccepted(); RequestSender rs = null; try { if(o instanceof CHKBlock) try { tag.setServedFromDatastore(); return new ClientCHKBlock((CHKBlock) o, key); } catch(CHKVerifyException e) { tag.unlockHandler();
@Override public void disconnected() { synchronized(this) { if(completed) return; completed = true; } origTag.finishedWaitingForOpennet(next); }
@Override public void blockTransferFinished(boolean success) { if(success) { // for byte logging status = RequestSender.SUCCESS; // We've fetched it from our datastore, so there won't be a downstream noderef. // But we want to send at least an FNPOpennetCompletedAck, otherwise the request source // may have to timeout waiting for one. That will be the terminal message. try { finishOpennetNoRelay(); } catch (NotConnectedException e) { Logger.normal(this, "requestor gone, could not start request handler wait"); tag.handlerThrew(e); } } else { //also for byte logging, since the block is the 'terminal' message. applyByteCounts(); unregisterRequestHandlerWithNode(); } node.nodeStats.remoteRequest(false, success, true, htl, key.toNormalizedDouble(), realTimeFlag, false); }
tag.unlockHandler(); rs.ackOpennet(dataSource); } else { tag.finishedWaitingForOpennet(dataSource); tag.unlockHandler(); applyByteCounts();
public void finishedWaitingForOpennet(PeerNode next) { boolean noRecordUnlock; synchronized(this) { if(waitingForOpennet == null) { if(logMINOR) Logger.minor(this, "Not waiting for opennet!"); return; } PeerNode got = waitingForOpennet.get(); if(got != next) { Logger.error(this, "Finished waiting for opennet on "+next+" but was waiting for "+got); } waitingForOpennet = null; if(!mustUnlock()) return; noRecordUnlock = this.noRecordUnlock; } innerUnlock(noRecordUnlock); }
@Override public void fatalError() { synchronized(this) { if(completed) return; completed = true; } origTag.finishedWaitingForOpennet(next); }