On Thursday 10 January 2008 23:31, Robert Hailey wrote:
>
> On Jan 10, 2008, at 5:23 PM, Matthew Toseland wrote:
>
> > On Tuesday 08 January 2008 00:46, you wrote:
> >> Author: robert
> >> Date: 2008-01-08 00:46:35 +0000 (Tue, 08 Jan 2008)
> >> New Revision: 16962
> >>
> >> Modified:
> >> trunk/freenet/src/freenet/io/xfer/BlockReceiver.java
> >> trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
> >> Log:
> >> trivial: comments, logging, readability
> >
> > Doesn't look that way to me e.g. timeAllSent affects when we kill the
> > transfer. What's going on here?
>
> There was more than one problem with timeAllSent... there are a number
> of commits regarding the block transmittion/reception. This change
> actually is trivial because the only time that timeAllSent was set is
> on breaking out of the loop, so I moved it to the break statement so
> that one can see that.
And what about removing else if(_allSent) { ... return } ?
>
> --
> Robert Hailey
>
> >
> >>
> >>
> >> Modified: trunk/freenet/src/freenet/io/xfer/BlockReceiver.java
> >> ===================================================================
> >> --- trunk/freenet/src/freenet/io/xfer/BlockReceiver.java 2008-01-07
> >> 20:56:43
> > UTC (rev 16961)
> >> +++ trunk/freenet/src/freenet/io/xfer/BlockReceiver.java 2008-01-08
> >> 00:46:35
> > UTC (rev 16962)
> >> @@ -66,6 +66,7 @@
> >>
> >> public byte[] receive() throws RetrievalException {
> >> int consecutiveMissingPacketReports = 0;
> >> + boolean logMINOR=Logger.shouldLog(Logger.MINOR, this);
> >> try {
> >> while (!_prb.allReceived()) {
> >> Message m1;
> >> @@ -80,7 +81,7 @@
> >> _prb.abort(RetrievalException.SENDER_DIED,
> >> "Disconnected
> > during receive");
> >> throw new
> > RetrievalException(RetrievalException.SENDER_DISCONNECTED);
> >> }
> >> - if(Logger.shouldLog(Logger.MINOR, this))
> >> + if(logMINOR)
> >> Logger.minor(this, "Received "+m1);
> >> if ((m1 != null) &&
> >> m1.getSpec().equals(DMT.sendAborted)) {
> >> _prb.abort(m1.getInt(DMT.REASON),
> >> m1.getString(DMT.DESCRIPTION));
> >> @@ -112,7 +113,7 @@
> >> }
> >> }
> >> }
> >> - if(Logger.shouldLog(Logger.MINOR, this))
> >> + if(logMINOR)
> >> Logger.minor(this, "Missing:
> >> "+missing.size());
> >> if (missing.size() > 0) {
> >> Message mn =
> >> DMT.createMissingPacketNotification(_uid, missing);
> >>
> >> Modified: trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
> >> ===================================================================
> >> --- trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
> >> 2008-01-07
> > 20:56:43 UTC (rev 16961)
> >> +++ trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
> >> 2008-01-08
> > 00:46:35 UTC (rev 16962)
> >> @@ -84,9 +84,13 @@
> >> try {
> >> while (true) {
> >>
> >> synchronized(_senderThread) {
> >> -
> >> if(_unsent.size() != 0) break;
> >> +
> >> if(_unsent.size() != 0) {
> >> +
> >> timeAllSent = -1;
> >> + break;
> >> + }
> >> // No unsent
> >> packets
> >> if(getNumSent()
> >> == _prb.getNumPackets()) {
> >> + //No
> >> unreceived packets
> >>
> >> if(Logger.shouldLog(Logger.MINOR, this))
> >>
> >> Logger.minor(this, "Sent all blocks, none unsent");
> >>
> >> if(timeAllSent <= 0)
> >> @@ -96,7 +100,6 @@
> >>
> >> _senderThread.wait(10*1000);
> >> }
> >> }
> >> - timeAllSent = -1;
> >> } catch (InterruptedException e) {
> >> } catch (AbortedException e) {
> >> synchronized(_senderThread) {
> >> @@ -136,9 +139,8 @@
> >> }
> >> }
> >>
> >> - /** @return True if _sendComplete */
> >> private void delay(long startCycleTime) {
> >> -
> >> + //FIXME: startCycleTime is not used in this
> >> function, why is
> >> it passed
> > in?
> >> long startThrottle = System.currentTimeMillis();
> >>
> >> // Get the current inter-packet delay
> >> @@ -164,6 +166,7 @@
> >> int x = (int) (Math.min(l, 120*1000));
> >> if(x > 0) {
> >> try {
> >> + //FIXME: if the
> >> senderThread sleeps here for two minutes,
> >> that will
> > timeout the receiver, no? Should this be a wait()?
> >> Thread.sleep(x);
> >> } catch (InterruptedException
> >> e) {
> >> // Ignore
> >> @@ -239,6 +242,7 @@
> >> return false;
> >> if (msg == null) {
> >> long now = System.currentTimeMillis();
> >> + //SEND_TIMEOUT (one minute) after all
> >> packets have been
> >> transmitted,
> > terminate the send.
> >> if((timeAllSent > 0) && ((now -
> >> timeAllSent) > SEND_TIMEOUT) &&
> >> (getNumSent() ==
> >> _prb.getNumPackets())) {
> >> synchronized(_senderThread) {
> >> @@ -280,9 +284,8 @@
> >> _senderThread.notifyAll();
> >> }
> >> return false;
> >> - } else if(_sendComplete) {
> >> - // Terminated abnormally
> >> - return false;
> >> + } else {
> >> + Logger.error(this, "Transmitter
> >> received unknown message
> > type: "+msg.getSpec().getName());
> >> }
> >> }
> >> } catch (AbortedException e) {
> >>
> >> _______________________________________________
> >> cvs mailing list
> >> cvs at freenetproject.org
> >> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
> >>
> >>
> > _______________________________________________
> > Devl mailing list
> > Devl at freenetproject.org
> > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
>
> _______________________________________________
> Devl mailing list
> Devl at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20080111/927b25c2/attachment.pgp>