ftpget.c O_NDELAY/O_NONBLOCK

From: Jean-Hugues ROYER <[email protected]>
Date: Sat, 16 Nov 1996 05:17:13 +0100

A little problem/fix with O_NONBLOCK/O_NDELAY in ftpget.c :

in squid-1.1.beta19:

-----------> ftpget.c line 2445:

        if ((flags = fcntl(c, F_GETFL, 0)) < 0)
            debug(38, 0, "fcntl F_GETFL: %s\n", xstrerror());
#ifdef O_NONBLOCK
        flags &= ~O_NONBLOCK;
#endif
#ifdef O_NDELAY
        flags &= ~O_NDELAY;
#endif
        if (fcntl(c, F_SETFL, flags) < 0)
            debug(38, 0, "fcntl F_SETFL: %s\n", xstrerror());

------------> should be:

        if ((flags = fcntl(c, F_GETFL, 0)) < 0)
            debug(38, 0, "fcntl F_GETFL: %s\n", xstrerror());
#if defined(O_NONBLOCK) && !defined(_SQUID_SUNOS_) &&
!defined(_SQUID_SOLARIS_)
        flags &= ~O_NONBLOCK;
#else
        flags &= ~O_NDELAY;
#endif
        if (fcntl(c, F_SETFL, flags) < 0)
            debug(38, 0, "fcntl F_SETFL: %s\n", xstrerror());

------------> ftpget.c line 802:

    orig_flags = fcntl(fd, F_GETFL, 0);
    debug(38, 7, "orig_flags = %x\n", orig_flags);
    if (fcntl(fd, F_SETFL, orig_flags | O_NDELAY) < 0)
        debug(38, 0, "fcntl O_NDELAY: %s\n", xstrerror());
    rc = connect_with_timeout2(fd, S, len);
    if (fcntl(fd, F_SETFL, orig_flags) < 0)
        debug(38, 0, "fcntl orig: %s\n", xstrerror());
    return rc;

------------> should be:

    orig_flags = fcntl(fd, F_GETFL, 0);
    debug(38, 7, "orig_flags = %x\n", orig_flags);
#if defined(O_NONBLOCK) && !defined(_SQUID_SUNOS_) &&
!defined(_SQUID_SOLARIS_)
    if (fcntl(fd, F_SETFL, orig_flags | O_NONBLOCK) < 0)
        debug(38, 0, "fcntl O_NONBLOCK: %s\n", xstrerror());
#else
    if (fcntl(fd, F_SETFL, orig_flags | O_NDELAY) < 0)
        debug(38, 0, "fcntl O_NDELAY: %s\n", xstrerror());
#endif
    rc = connect_with_timeout2(fd, S, len);
    if (fcntl(fd, F_SETFL, orig_flags) < 0)
        debug(38, 0, "fcntl orig: %s\n", xstrerror());
    return rc;
Received on Fri Nov 15 1996 - 20:17:22 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:33:34 MST