ASYNC_IO patch to prevent threads closing non-blocking network sockets

From: Stewart Forster <slf@dont-contact.us>
Date: Wed, 13 May 1998 10:26:42 +1000

--MimeMultipartBoundary
Content-Type: text/plain; charset=us-ascii

Hiya,

        This is a followup to Michael @ IINET's patch about Linux threads
never blocking on a network socket close. It turns that that Solaris only
blocks on some itself, so invoking a thread for each network socket close
is excessive, as the blocking condition can be pre-determined using fcntl.
An fcntl is always going to be cheaper than a thread, so the following
patch to comm_close in comm.c (1.2 beta20) fixes excessive thread use for
close() of network sockets when using async.

        Cheers,

                Stew.

===================================================================
RCS file: RCS/comm.c,v
retrieving revision 1.1
diff -r1.1 comm.c
4c4
< * $Id: comm.c,v 1.1 1998/05/13 00:21:24 slf Exp slf $

---
>  * $Id: comm.c,v 1.252 1998/04/24 07:09:31 wessels Exp $
624a625,628
> #ifdef USE_ASYNC_IO
> int flags;
> int dummy = 0;
> #endif
649c653,660
<     aioClose(fd);
---
>     if((flags = fcntl(fd, F_GETFL, dummy)) < 0)
>         aioClose(fd);
>     else {
>         if(flags & SQUID_NONBLOCK)
>             close(fd);
>         else
>           aioClose(fd);
>     }
--MimeMultipartBoundary--
Received on Tue Jul 29 2003 - 13:15:49 MDT

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