* Matthew Toseland <toad at amphibian.dyndns.org> [2006-07-12 00:20:28]:

> Expand the synchronization on the if(cw == null) { set cw }; if you
> check a variable and then set it, the check and the set should be
> synchronized (so it is atomic).

Ok, done in r9581

> 
> On Tue, Jul 11, 2006 at 10:58:27PM +0000, nextgens at freenetproject.org 
> wrote:
> > Author: nextgens
> > Date: 2006-07-11 22:58:25 +0000 (Tue, 11 Jul 2006)
> > New Revision: 9569
> > 
> > Modified:
> >    trunk/freenet/src/freenet/node/CHKInsertSender.java
> > Log:
> > maybe fix some locking issues ... it needs to be reviewed
> > 
> > Modified: trunk/freenet/src/freenet/node/CHKInsertSender.java
> > ===================================================================
> > --- trunk/freenet/src/freenet/node/CHKInsertSender.java     2006-07-11 
> > 22:35:55 UTC (rev 9568)
> > +++ trunk/freenet/src/freenet/node/CHKInsertSender.java     2006-07-11 
> > 22:58:25 UTC (rev 9569)
> > @@ -531,17 +531,16 @@
> >      private void finish(int code, PeerNode next) {
> >          Logger.minor(this, "Finished: "+code+" on "+this, new 
> > Exception("debug"));
> >          setStatusTime = System.currentTimeMillis();
> > -        synchronized(this) {
> > +     
> > +        synchronized(this) {   
> >             if(status != NOT_FINISHED)
> > -                   throw new IllegalStateException("finish() called with 
> > "+code+" when was already "+status);
> > +                   throw new IllegalStateException("finish() called with 
> > "+code+" when was already "+status);
> >  
> >             if((code == ROUTE_NOT_FOUND) && !sentRequest)
> >                     code = ROUTE_REALLY_NOT_FOUND;
> > -           
> > -           status = code;
> > -        
> > +
> > +            status = code;
> >             notifyAll();
> > -
> >             Logger.minor(this, "Set status code: "+getStatusString()+" on 
> > "+uid);
> >          }
> >          // Now wait for transfers, or for downstream transfer 
> > notifications.
> > @@ -611,7 +610,9 @@
> >             Thread t;
> >  
> >             if(cw == null)
> > -                   cw = new CompletionWaiter();
> > +                   synchronized (this) {
> > +                           cw = new CompletionWaiter();
> > +                   }
> >             else
> >                     return;
> >             t = new Thread(cw, "Completion waiter for "+uid);
> > @@ -636,20 +637,19 @@
> >                     int timeout;
> >                     boolean noTimeLeft = false;
> >  
> > -                   synchronized(this) {
> > -                           long now = System.currentTimeMillis();
> > -                           if((status == NOT_FINISHED) || (setStatusTime 
> > == -1)) {
> > -                                   // Wait 5 seconds, then try again
> > -                                   timeout = 5000;
> > -                           } else {
> > -                                   // Completed, wait for everything
> > -                                   timeout = 
> > (int)Math.min(Integer.MAX_VALUE, (setStatusTime + 
> > TRANSFER_COMPLETION_TIMEOUT) - now);
> > -                           }
> > -                           if(timeout <= 0) {
> > -                                   noTimeLeft = true;
> > -                                   timeout = 1;
> > -                           }
> > +                   long now = System.currentTimeMillis();
> > +                   if((status == NOT_FINISHED) || (setStatusTime == -1)) {
> > +                           // Wait 5 seconds, then try again
> > +                           timeout = 5000;
> > +                   } else {
> > +                           // Completed, wait for everything
> > +                           timeout = (int)Math.min(Integer.MAX_VALUE, 
> > (setStatusTime + TRANSFER_COMPLETION_TIMEOUT) - now);
> >                     }
> > +                   if(timeout <= 0) {
> > +                           noTimeLeft = true;
> > +                           timeout = 1;
> > +                   }
> > +
> >                     
> >                     MessageFilter mf = null;
> >                     for(int i=0;i<waiters.length;i++) {
> > 
> > _______________________________________________
> > cvs mailing list
> > cvs at freenetproject.org
> > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
> > 
> 
> -- 
> Matthew J Toseland - toad at amphibian.dyndns.org
> Freenet Project Official Codemonkey - http://freenetproject.org/
> ICTHUS - Nothing is impossible. Our Boss says so.



> _______________________________________________
> Devl mailing list
> Devl at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to