[MERGE] Add an optional 'token' keyword argument to LockableFiles.lock_write

Andrew Bennetts andrew at canonical.com
Thu Feb 15 06:59:17 GMT 2007


Just a quick reply to one point, rather than a comprehensive response to the
review (which will come soon):

Martin Pool wrote:
[...]
> >  
> > +    def validate_token(self, token):
> > +        if token is not None:
> > +            info = self.peek()
> > +            if info is None:
> > +                # Lock isn't held
> > +                lock_token = None
> > +            else:
> > +                lock_token = info.get('nonce')
> > +            if token != lock_token:
> > +                raise errors.TokenMismatch(token, lock_token)
> > +
> 
> Why not use the whole info object as the token?  Doing so makes it a
> little more sure we won't collide and might help debug any problems.

Collisions aren't a concern; the nonce is 20 bytes of randomness already, and I
believe that's all the existing lock code compares anyway.

The debugging point is a good one though.  I need to see what's needed on the
smart server branch to make sure useful information gets put in the info, and
then returned to the client in the case of contention.

-Andrew.




More information about the bazaar mailing list