]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Async I/O from Pete Bentley <pete@demon.net>
authorwessels <>
Tue, 9 Jul 1996 10:46:46 +0000 (10:46 +0000)
committerwessels <>
Tue, 9 Jul 1996 10:46:46 +0000 (10:46 +0000)
ChangeLog
configure
configure.in
include/autoconf.h.in
src/Makefile.in
src/comm.cc
src/disk.cc
src/main.cc
src/squid.h

index 7cde21279e2fe7b4b9ecd7b45c311c37d98cf342..2ce607ddff4cd9afe33b625c1117cf711eab0fdd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 Changes to squid-1.1.alpha2:
 
        - Added Support for RFC931/ident
+       - Added Asynchronous Disk I/O routines from Pete Bentley.
 
 Changes to squid-1.0.1 (July 8, 1996):
 
index e00726abb8a62b1b3d229822f91222eaa9a3c81e..ef7772ce922dcc3f10c365b0e7be15b338069d4b 100755 (executable)
--- a/configure
+++ b/configure
@@ -517,7 +517,7 @@ fi
 
 
 
-# From configure.in Revision: 1.18.2.3
+# From configure.in Revision: 1.2
 ac_aux_dir=
 for ac_dir in aux $srcdir/aux; do
   if test -f $ac_dir/install-sh; then
@@ -1282,6 +1282,7 @@ fi
 
 for ac_hdr in \
        alloca.h \
+       aio.h \
        arpa/inet.h \
        arpa/nameser.h \
        bstring.h \
@@ -1330,7 +1331,7 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1334 "configure"
+#line 1335 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
@@ -1361,7 +1362,7 @@ done
 
 echo $ac_n "checking for tm->tm_gmtoff""... $ac_c" 1>&6
 cat > conftest.$ac_ext <<EOF
-#line 1365 "configure"
+#line 1366 "configure"
 #include "confdefs.h"
 #include <time.h>
 #include <sys/time.h>
@@ -1387,7 +1388,7 @@ rm -f conftest*
 
 echo $ac_n "checking for extended mallinfo""... $ac_c" 1>&6
 cat > conftest.$ac_ext <<EOF
-#line 1391 "configure"
+#line 1392 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <malloc.h>
@@ -1419,7 +1420,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 1423 "configure"
+#line 1424 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -1453,7 +1454,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 1457 "configure"
+#line 1458 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -1487,7 +1488,7 @@ if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1491 "configure"
+#line 1492 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() { return 0; }
@@ -1519,7 +1520,7 @@ if eval "test \"`echo '$''{'ac_cv_func_alloca'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1523 "configure"
+#line 1524 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -1578,7 +1579,7 @@ if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1582 "configure"
+#line 1583 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -1607,7 +1608,7 @@ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1611 "configure"
+#line 1612 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1661,7 +1662,7 @@ else
   ac_cv_c_stack_direction=0
 else
 cat > conftest.$ac_ext <<EOF
-#line 1665 "configure"
+#line 1666 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -1706,7 +1707,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1710 "configure"
+#line 1711 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1746,7 +1747,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1750 "configure"
+#line 1751 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1786,7 +1787,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lmalloc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1790 "configure"
+#line 1791 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1820,7 +1821,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1824 "configure"
+#line 1825 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1860,7 +1861,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbsd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1864 "configure"
+#line 1865 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1901,7 +1902,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l44bsd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1905 "configure"
+#line 1906 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1935,7 +1936,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1939 "configure"
+#line 1940 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1970,7 +1971,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1974 "configure"
+#line 1975 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -2048,7 +2049,7 @@ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2052 "configure"
+#line 2053 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2098,7 +2099,7 @@ if test "$cross_compiling" = yes; then
   SQUID_FD_SETSIZE=256
 else
 cat > conftest.$ac_ext <<EOF
-#line 2102 "configure"
+#line 2103 "configure"
 #include "confdefs.h"
 
 #include <unistd.h>
@@ -2166,7 +2167,7 @@ if test "$cross_compiling" = yes; then
   SQUID_UDP_SO_SNDBUF=8192
 else
 cat > conftest.$ac_ext <<EOF
-#line 2170 "configure"
+#line 2171 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -2202,7 +2203,7 @@ if test "$cross_compiling" = yes; then
   SQUID_UDP_SO_RCVBUF=8192
 else
 cat > conftest.$ac_ext <<EOF
-#line 2206 "configure"
+#line 2207 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -2238,7 +2239,7 @@ if test "$cross_compiling" = yes; then
   SQUID_TCP_SO_SNDBUF=8192
 else
 cat > conftest.$ac_ext <<EOF
-#line 2242 "configure"
+#line 2243 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -2274,7 +2275,7 @@ if test "$cross_compiling" = yes; then
   SQUID_TCP_SO_RCVBUF=8192
 else
 cat > conftest.$ac_ext <<EOF
-#line 2278 "configure"
+#line 2279 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -2307,7 +2308,7 @@ EOF
 
 echo $ac_n "checking if sys_errlist is already defined""... $ac_c" 1>&6
 cat > conftest.$ac_ext <<EOF
-#line 2311 "configure"
+#line 2312 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main() { return 0; }
index 23d12f526ffd25ad3ecbad0937b6fbb8896d8331..034eae283e6e14aa12f3444d52754b3502badee8 100644 (file)
@@ -3,13 +3,13 @@ dnl  Configuration input file for Squid
 dnl
 dnl  Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9)
 dnl
-dnl  $Id: configure.in,v 1.21 1996/07/09 03:41:04 wessels Exp $
+dnl  $Id: configure.in,v 1.22 1996/07/09 04:46:47 wessels Exp $
 dnl
 dnl
 dnl
 AC_INIT(src/main.c)
 AC_CONFIG_HEADER(include/autoconf.h)
-AC_REVISION($Revision: 1.21 $)dnl
+AC_REVISION($Revision: 1.22 $)dnl
 AC_PREFIX_DEFAULT(/usr/local/squid)
 AC_CONFIG_AUX_DIR(aux)
 
@@ -127,6 +127,7 @@ AC_HEADER_STDC
 
 AC_CHECK_HEADERS( \
        alloca.h \
+       aio.h \
        arpa/inet.h \
        arpa/nameser.h \
        bstring.h \
index 8f9bd102723ddbe4f90ce70ce9e188c994510281..e86925ac0780e5c221b94800c96785a88713ed54 100644 (file)
 /* Define if you have the timegm function.  */
 #undef HAVE_TIMEGM
 
+/* Define if you have the <aio.h> header file.  */
+#undef HAVE_AIO_H
+
 /* Define if you have the <alloca.h> header file.  */
 #undef HAVE_ALLOCA_H
 
index d288a4d8e5c4d09d9ce44b98888b0af8971a2bab..a4eae948c39328ad054da05c161f7aa6bb35bc8b 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.in,v 1.26 1996/07/09 03:41:17 wessels Exp $
+#  $Id: Makefile.in,v 1.27 1996/07/09 04:46:49 wessels Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -52,8 +52,8 @@ CLIENT_LIBS   = -L../lib -lmiscutil $(XTRA_LIBS)
 PROGS           = squid client
 UTILS           = dnsserver ftpget
 CGIPROGS       = cachemgr.cgi
-OBJS           = acl.o background.o cache_cf.o errorpage.o comm.o \
-               debug.o disk.o dynamic_array.o \
+OBJS           = acl.o async_io.o background.o cache_cf.o errorpage.o \
+               comm.o debug.o disk.o dynamic_array.o \
                fdstat.o filemap.o ftp.o gopher.o \
                hash.o http.o icp.o ident.o ipcache.o \
                main.o mime.o neighbors.o objcache.o \
index 8bdf4aea65e829643cadc865cacf136135e5249d..5049dce4aa7918d6d5c657d84c1a26a7e816bc79 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.33 1996/07/09 03:41:20 wessels Exp $
+ * $Id: comm.cc,v 1.34 1996/07/09 04:46:50 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -668,6 +668,11 @@ int comm_select(sec, failtime)
        nfds = 0;
        maxfd = fdstat_biggest_fd() + 1;
        for (i = 0; i < maxfd; i++) {
+#if USE_ASYNC_IO
+           /* Using async IO for disk handle, so don't select on them */
+           if (fdstat_type(i) == FD_FILE) 
+               continue;
+#endif
            /* Check each open socket for a handler. */
            if (fd_table[i].read_handler && fd_table[i].stall_until <= squid_curtime) {
                nfds++;
@@ -692,8 +697,14 @@ int comm_select(sec, failtime)
        if (shutdown_pending || reread_pending)
            debug(5, 2, "comm_select: Still waiting on %d FDs\n", nfds);
        while (1) {
+#if USE_ASYNC_IO
+           /* Another CPU vs latency tradeoff for async IO */
+           poll_time.tv_sec = 0;
+           poll_time.tv_usec = 250000;
+#else      
            poll_time.tv_sec = sec > 1 ? 1 : 0;
            poll_time.tv_usec = 0;
+#endif
            num = select(maxfd, &readfds, &writefds, &exceptfds, &poll_time);
            if (num >= 0)
                break;
@@ -705,6 +716,9 @@ int comm_select(sec, failtime)
            return COMM_ERROR;
            /* NOTREACHED */
        }
+#if USE_ASYNC_IO
+       aioExamine();          /* See if any IO completed */
+#endif
        if (num < 0)
            continue;
        debug(5, num ? 5 : 8, "comm_select: %d sockets ready at %d\n",
index 08b4db484ecca684582e475fb6c71b5a7e74b29b..f4e1a5d963c5ea61f104624ce6fa70923549b5f5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: disk.cc,v 1.13 1996/07/09 03:41:22 wessels Exp $
+ * $Id: disk.cc,v 1.14 1996/07/09 04:46:51 wessels Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
 #include "squid.h"
 
 #define DISK_LINE_LEN  1024
-#define MAX_FILE_NAME_LEN 256
-
-typedef struct _dread_ctrl {
-    int fd;
-    off_t offset;
-    int req_len;
-    char *buf;
-    int cur_len;
-    int end_of_file;
-    int (*handler) _PARAMS((int fd, char *buf, int size, int errflag, void *data,
-           int offset));
-    void *client_data;
-} dread_ctrl;
 
 typedef struct _dwalk_ctrl {
     int fd;
@@ -131,40 +118,6 @@ typedef struct _dwalk_ctrl {
     void *line_data;
 } dwalk_ctrl;
 
-typedef struct _dwrite_q {
-    char *buf;
-    int len;
-    int cur_offset;
-    struct _dwrite_q *next;
-} dwrite_q;
-
-typedef struct _FileEntry {
-    char filename[MAX_FILE_NAME_LEN];
-    enum {
-       NO, YES
-    } at_eof;
-    enum {
-       NOT_OPEN, OPEN
-    } open_stat;
-    enum {
-       NOT_REQUEST, REQUEST
-    } close_request;
-    enum {
-       NOT_PRESENT, PRESENT
-    } write_daemon;
-    enum {
-       UNLOCK, LOCK
-    } write_lock;
-    int access_code;           /* use to verify write lock */
-    enum {
-       NO_WRT_PENDING, WRT_PENDING
-    } write_pending;
-    void (*wrt_handle) ();
-    void *wrt_handle_data;
-    dwrite_q *write_q;
-    dwrite_q *write_q_tail;
-} FileEntry;
-
 /* table for FILE variable, write lock and queue. Indexed by fd. */
 FileEntry *file_table;
 
@@ -479,12 +432,20 @@ int file_write(fd, ptr_to_buf, len, access_code, handle, handle_data)
        file_table[fd].write_q_tail = wq;
     }
 
-    if (file_table[fd].write_daemon == NOT_PRESENT) {
-       /* got to start write routine for this fd */
-       comm_set_select_handler(fd, COMM_SELECT_WRITE, (PF) diskHandleWrite,
-           (void *) &file_table[fd]);
-    }
+    if (file_table[fd].write_daemon == PRESENT)
+       return DISK_OK;
+    /* got to start write routine for this fd */
+#if USE_ASYNC_IO
+    return aioFileQueueWrite(fd,
+       file_aio_write_complete,
+       &file_table[fd]);
+#else
+    comm_set_select_handler(fd,
+       COMM_SELECT_WRITE,
+       (PF) diskHandleWrite,
+        (void *) &file_table[fd]);
     return DISK_OK;
+#endif
 }
 
 
@@ -571,12 +532,15 @@ int file_read(fd, buf, req_len, offset, handler, client_data)
     ctrl_dat->handler = handler;
     ctrl_dat->client_data = client_data;
 
+#if USE_ASYNC_IO
+    return aioFileQueueRead(fd, file_aio_read_complete, ctrl_dat);
+#else
     comm_set_select_handler(fd,
        COMM_SELECT_READ,
        (PF) diskHandleRead,
        (void *) ctrl_dat);
-
     return DISK_OK;
+#endif
 }
 
 
index 5ae143e14ee839a4b70e1d50417b4b934e3f7e82..181eba9eb0240fb8f2ee3091935ee89ebe113f4b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.cc,v 1.47 1996/07/09 03:41:32 wessels Exp $
+ * $Id: main.cc,v 1.48 1996/07/09 04:46:52 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -388,6 +388,9 @@ static void mainInitialize()
     }
     squid_signal(SIGPIPE, SIG_IGN, SA_RESTART);
     squid_signal(SIGCHLD, sig_child, SA_NODEFER | SA_RESTART);
+#if USE_ASYNC_IO
+    squid_signal(SIGIO, aioSigHandler, SA_RESTART);
+#endif
 
     if (ConfigFile == NULL)
        ConfigFile = xstrdup(DefaultConfigFile);
index 488c1c4dfbfabff0d8263905094c858a3bb132f4..d689715b1a76bd8ccb60af296cbc730855e2fe49 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: squid.h,v 1.23 1996/07/09 03:41:39 wessels Exp $
+ * $Id: squid.h,v 1.24 1996/07/09 04:46:52 wessels Exp $
  *
  * AUTHOR: Duane Wessels
  *
 #if HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #endif
+#if USE_ASYNC_IO && HAVE_AIO_H
+#include <aio.h>
+#endif
 
 #if defined(__STRICT_ANSI__)
 #include <stdarg.h>