On Sunday 25 May 2008 12:37, Daniel Cheng wrote:
> >> @@ -174,6 +186,14 @@
> >> } catch (KeyVerifyException e) {
> >> // ignore
> >> }
> >> +
> >> + // Overwrite old offset
> >> + Entry entry = new Entry(routingKey, header, data);
> >> + writeEntry(entry, oldOffset);
> >> + return;
> >> + } finally {
> >> + unlockEntry(oldOffset);
> >> + }
> >
> > You should move this into the catch (KeyVerifyException) block. It would
be
> > much clearer what's going on.
>
> No only KeyVerifyException.
> It have to be unlocked on IOException and !collisionPossible too.
> If we catch IOException here, it have to be rethrow ...
>
> Too many exit path, it's cleaner to have one finally{} block.
Sorry, I meant the overwrite bit. Unclear quoting on my part. :|
> >> @@ -197,19 +217,18 @@
> >> }
> >> }
> >>
> >> - // no free blocks?
> >> - int i = random.nextInt(offset.length);
> >> - if (!lockEntry(offset[i])) {
> >> - Logger.error(this, "can't lock entry: " +
offset[i]);
> >> + // no free blocks, overwrite the first one
> >> + if (!lockEntry(offset[0])) {
> >> + Logger.error(this, "can't lock entry: " +
offset[0]);
> >> return;
> >
> > To reduce average seeks? You can't think of a good reason to use a random
one?
>
> wasn't that what you have suggested?
I dunno. :|
>
> >> }
> >> try {
> >> if (logDEBUG)
> >> - Logger.debug(this, "collision, write to i="
+ i + ", offset=" +
> > offset[i]);
> >> - writeEntry(entry, offset[i]);
> >> + Logger.debug(this, "collision, write to
i=0, offset=" + offset[0]);
> >> + writeEntry(entry, offset[0]);
> >
> > What's going on here?
> >
>
> same as above.
> write to offset[0] instead of offset[ random value ].
-------------- 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/20080527/c4aa1e15/attachment.pgp>