On Tue, Jan 29, 2002 at 07:34:54PM -0500, Tavin Cole wrote:
<> 
> What happens is that the node gets locked in a loop where it keeps
> reading the same request message from a socket over and over again.
> Since it has already handled that chain, it issues a QueryRejected.
> This loop is on a 3 second interval, so the unfortunate node that first
> sent that request to the evil-1.1 node starts receiving an identical
> QueryRejected every 3 seconds ad infinitum.

I know why this happens. Their implementation of BufferedInputStream
doesn't consider that there are IOExceptions that are non-terminal for
the InputStream and doesn't watch where the buffer pointer goes after an
exception is thrown. Consider something like:

    int pointer;
    int length;
    byte[] buffer;

    private int read() throws IOException {
        while (pointer >= length) {
            pointer = 0;
            length = in.read(buffer);
        }
        return buffer[pointer];
    }

compared to if you did in.read() first, and the then set pointer to
zero. The result is that when it comes back from an
InterruptedIOException while waiting on in.read() it thinks the pointer
is already reset - and reads the last message off the buffer.

This bug is quite common - I believe it was the reason for the problems
with Microsoft's 1.1 jvm ("jview") and I know I had to fix it for
Kaffe's BufferedReader (they accepted the patch).

We could use our own BufferedInputStream (grab it from kaffe) and see if
that helps.

-- 

Oskar Sandberg
oskar at freenetproject.org

_______________________________________________
Devl mailing list
Devl at freenetproject.org
http://lists.freenetproject.org/mailman/listinfo/devl

Reply via email to