lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lynx-dev] Re: lynx randomly hanging at "HTTP/1.1 200 OK"


From: Thomas Dickey
Subject: Re: [Lynx-dev] Re: lynx randomly hanging at "HTTP/1.1 200 OK"
Date: Sat, 7 Jan 2006 07:44:20 -0500 (EST)

On Sat, 7 Jan 2006, Fr?d?ric L. W. Meunier wrote:

BTW, something I forgot and could be relevant. I set LYNX_TEMP_SPACE=~/tmp and ~/tmp is using tmpfs (half my RAM = 256Mb):

tmpfs /home/fredlwm/tmp tmpfs defaults,gid=102,mode=0700,uid=1000 0 0

The only thing I'm sure is that it never runs out of space when this happens (and there are always less than 60 lynx files). And also that I've been using it for years.

Perhaps some odd problem with the configure script is making the used_tempname[] array very small. You can verify that by adding
a
        CTRACE((tfp, "SIZEOF_used_tempname=%d\n", sizeof(used_tempname)));

to the beginning of the function and looking for that in the trace.

If it were looping in the caller of fmt_tempname(), I'd suspect that the
directory permissions are making lynx decide that it's insecure.  But it
seems to be stuck in this loop:

    counter = MAX_TEMPNAME;
    while (names_used < MAX_TEMPNAME) {
        counter = (unsigned) (((float) MAX_TEMPNAME * lynx_rand()) /
                              LYNX_RAND_MAX + 1);
        counter %= SIZE_TEMPNAME;       /* just in case... */
        /*
         * Avoid reusing a temporary name, since there are places in the code
         * which can refer to a temporary filename even after it has been
         * closed and removed from the filesystem.
         */
        offset = counter / BITS_PER_CHAR;
        mask = 1 << (counter % BITS_PER_CHAR);
        if ((used_tempname[offset] & mask) == 0) {
            names_used++;
            used_tempname[offset] |= mask;
            break;
        }
    }
    if (names_used >= MAX_TEMPNAME)
        HTAlert(gettext("Too many tempfiles"));

which sounds as if either the array is small, or there's something wrong
with the random number generated (whatever lynx_rand() happens to be defined to). Or else there's something wrong with my assumptions for the computation - thinking about it, since it is scaled (dividing by LYNX_RAND_MAX), it may keep trying to use the same filenames repeatedly.

We can improve on this by changing the loop to simply look for an unused entry in the table:

    counter = MAX_TEMPNAME;
    if (names_used < MAX_TEMPNAME) {
        counter = (unsigned) (((float) MAX_TEMPNAME * lynx_rand()) /
                              LYNX_RAND_MAX + 1);
        /*
         * Avoid reusing a temporary name, since there are places in the code
         * which can refer to a temporary filename even after it has been
         * closed and removed from the filesystem.
         */
        do {
            counter %= SIZE_TEMPNAME;
            offset = counter / BITS_PER_CHAR;
            mask = 1 << (counter % BITS_PER_CHAR);
            if ((used_tempname[offset] & mask) == 0) {
                names_used++;
                used_tempname[offset] |= mask;
                break;
            }
        } while ((used_tempname[offset] & mask) == 0);
    }
    if (names_used >= MAX_TEMPNAME)


--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

reply via email to

[Prev in Thread] Current Thread [Next in Thread]