[freenet-dev] [freenet-cvs] r19304 - in trunk/freenet/src/freenet: client/async keys node support

Florent Daignière nextgens at freenetproject.org
Mon Apr 14 07:21:10 UTC 2008


* Daniel Cheng (SDiZ) <sdiz at sdiz.net> [2008-04-14 15:09:45]:

> On Mon, Apr 14, 2008 at 3:05 PM, Florent Daignière
> <nextgens at freenetproject.org> wrote:
> > * Daniel Cheng <j16sdiz+freenet at gmail.com> [2008-04-14 15:00:50]:
> >
> >  > On Mon, Apr 14, 2008 at 2:21 PM,  <nextgens at freenetproject.org> wrote:
> >  > > Author: nextgens
> >  > >  Date: 2008-04-14 06:21:05 +0000 (Mon, 14 Apr 2008)
> >  > >  New Revision: 19304
> >  > >
> >  > >  Modified:
> >  > >    trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
> >  > >    trunk/freenet/src/freenet/keys/ClientCHKBlock.java
> >  > >    trunk/freenet/src/freenet/keys/FreenetURI.java
> >  > >    trunk/freenet/src/freenet/node/FailureTable.java
> >  > >    trunk/freenet/src/freenet/node/PeerManager.java
> >  > >    trunk/freenet/src/freenet/node/PeerNode.java
> >  > >    trunk/freenet/src/freenet/support/LoggerHookChain.java
> >  > >    trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java
> >  > >  Log:
> >  > >  some paranoia code to prevent race conditions and out-of-bound exceptions
> >  > >
> >  > >  Modified: trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
> >  > >  ===================================================================
> >  > >  --- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  2008-04-14 05:28:57 UTC (rev 19303)
> >  > >  +++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  2008-04-14 06:21:05 UTC (rev 19304)
> >  > >  @@ -531,10 +531,11 @@
> >  > >                                 }
> >  > >                         } else {
> >  > >                                 SendableGet[] gets = (SendableGet[]) o;
> >  > >  -                               SendableGet[] newGets = new SendableGet[gets.length-1];
> >  > >  +                               final int getsLength = gets.length;
> >  > <snip>
> >  > >  @@ -555,7 +556,7 @@
> >  > >                                 } else if(x == 1) {
> >  > >                                         pendingKeys.put(key, newGets[0]);
> >  > >                                 } else {
> >  > >  -                                       if(x != gets.length-1) {
> >  > >  +                                       if(x != -1) {
> >  > >                                                 SendableGet[] newNewGets = new SendableGet[x];
> >  > Should this be
> >  >    if  ( x != getsLength-1)  {
> >  > ?
> >
> >  Doh, fixed in r19305.
> >
> 
> Is this "race condition" fix really needed?

Heh, it's paranoia code; I haven't claimed that it's needed nor even
useful. It's just good practice and looking cleaner.

> As far as I can see, all related objects are protected by
> synchronized(pendingKeys).

On that snippet of code it's probably useless, yes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://emu.freenetproject.org/pipermail/devl/attachments/20080414/086cd34f/attachment.pgp 


More information about the Devl mailing list