]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Ripped out old 'comm_set_stall()' stuff. This broke because we would
authorwessels <>
Thu, 23 Oct 1997 11:13:36 +0000 (11:13 +0000)
committerwessels <>
Thu, 23 Oct 1997 11:13:36 +0000 (11:13 +0000)
decide to delay the server side for some fixed amount of time (1s), but
if the condition changed before that time was up, there was no way to
'undo' the stall.

Now we have a 'check_defer' function associated with a FD.  We'll
call F->check_defer every time through select().

14 files changed:
src/cf.data.pre
src/client.cc
src/comm.cc
src/defines.h
src/ftp.cc
src/gopher.cc
src/http.cc
src/main.cc
src/protos.h
src/stat.cc
src/stmem.cc
src/structs.h
src/typedefs.h
src/wais.cc

index 09c8db9b02d3acdcb012efcb21ca97551147e87b..8c1b6f7f34f15fa5e5101c7b47378063794ef934 100644 (file)
@@ -1034,24 +1034,6 @@ read_timeout 15 minutes
 DOC_END
 
 
-NAME: defer_timeout
-COMMENT: (in minutes)
-TYPE: time_t
-LOC: Config.Timeout.defer
-DEFAULT: 1 hour
-DOC_START
-       If your clients are behind slow (e.g. PPP/SLIP) connections,
-       then data may come in from the server-side faster than it can
-       be written to the client-side.  When the server side gets too
-       far ahead of the client-side, subsequent reads will be deferred
-       until the client catches up.  This timeout determines how long
-       to wait while in "deferred read mode." The default is one
-       hour.
-
-defer_timeout 1 hour
-DOC_END
-
-
 NAME: request_timeout
 TYPE: time_t
 LOC: Config.Timeout.request
index 06a68203a85d7803fb71085b8deee34bc060f520..96c0cc6e07026c9adecfa09685738862855b96a7 100644 (file)
@@ -2,8 +2,9 @@
 
 
 
+
 /*
- * $Id: client.cc,v 1.32 1997/10/20 22:59:43 wessels Exp $
+ * $Id: client.cc,v 1.33 1997/10/23 05:13:37 wessels Exp $
  *
  * DEBUG: section 0     WWW Client
  * AUTHOR: Harvest Derived
index a9a9f29605754d12b99568000d27bc2e5d7f287c..89dee33d3cef690c46d3ba632de19e6cff224ea9 100644 (file)
@@ -1,5 +1,6 @@
+
 /*
- * $Id: comm.cc,v 1.189 1997/10/23 04:01:23 wessels Exp $
+ * $Id: comm.cc,v 1.190 1997/10/23 05:13:37 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -154,6 +155,7 @@ static PF commHandleWrite;
 static int fdIsHttpOrIcp _PARAMS((int fd));
 static IPH commConnectDnsHandle;
 static void commConnectCallback _PARAMS((ConnectStateData * cs, int status));
+static int commDeferRead(int fd);
 
 static struct timeval zero_tv;
 
@@ -628,13 +630,20 @@ comm_udp_sendto(int fd,
 }
 
 void
-comm_set_stall(int fd, int delta)
+commSetDefer(int fd, DEFER * func)
 {
-    if (fd < 0)
-       return;
-    fd_table[fd].stall_until = squid_curtime + delta;
+    fde *F = &fd_table[fd];
+    F->defer_check = func;
 }
 
+static int
+commDeferRead(int fd)
+{
+    fde *F = &fd_table[fd];
+    if (F->defer_check == NULL)
+       return 0;
+    return F->defer_check(fd, F->read_data);
+}
 
 #if HAVE_POLL
 
@@ -661,7 +670,7 @@ comm_poll_incoming(void)
     for (j = 0; j < NHttpSockets; j++) {
        if (HttpSockets[j] < 0)
            continue;
-       if (fd_table[HttpSockets[j]].stall_until > squid_curtime)
+       if (commDeferRead(HttpSockets[j]))
            continue;
        fds[N++] = HttpSockets[j];
     }
@@ -724,7 +733,7 @@ comm_select_incoming(void)
     for (i = 0; i < NHttpSockets; i++) {
        if (HttpSockets[i] < 0)
            continue;
-       if (fd_table[HttpSockets[i]].stall_until > squid_curtime)
+       if (commDeferRead(HttpSockets[i]))
            continue;
        fds[N++] = HttpSockets[i];
     }
@@ -826,7 +835,7 @@ comm_poll(time_t sec)
            int events;
            events = 0;
            /* Check each open socket for a handler. */
-           if (fd_table[i].read_handler && fd_table[i].stall_until <= squid_curtime)
+           if (fd_table[i].read_handler && !commDeferRead(i))
                events |= POLLRDNORM;
            if (fd_table[i].write_handler)
                events |= POLLWRNORM;
@@ -971,9 +980,7 @@ comm_select(time_t sec)
        maxfd = Biggest_FD + 1;
        for (i = 0; i < maxfd; i++) {
            /* Check each open socket for a handler. */
-           if (fd_table[i].stall_until > squid_curtime)
-               continue;
-           if (fd_table[i].read_handler) {
+           if (fd_table[i].read_handler && !commDeferRead(i)) {
                nfds++;
                FD_SET(i, &readfds);
            }
index 3b321f6bd4efd80c43f666d14528f42f418842ba..da3981c9f712f706b919630ca029f119c8a86653 100644 (file)
  */
 
 #define ENTRY_VALIDATED                (1<<16)
-#define READ_DEFERRED          (1<<15)
+#define ENTRY_UNUSED15         (1<<15)
 #define ENTRY_NEGCACHED                (1<<14)
 #define HIERARCHICAL           (1<<13)         /* can we query neighbors? */
 #define KEY_PRIVATE            (1<<12)         /* is the key currently private? */
index cd20586a8128930dbbc02ca6463aa43791dde98c..b7bd2900d9b8774ae7c01d23f42fd445d1635bb7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.144 1997/10/22 18:51:15 wessels Exp $
+ * $Id: ftp.cc,v 1.145 1997/10/23 05:13:39 wessels Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -623,21 +623,6 @@ ftpReadData(int fd, void *data)
     /* check if we want to defer reading */
     clen = entry->mem_obj->inmem_hi;
     off = storeLowestMemReaderOffset(entry);
-    if ((clen - off) > READ_AHEAD_GAP) {
-       IOStats.Ftp.reads_deferred++;
-       debug(9, 3) ("ftpReadData: Read deferred for Object: %s\n",
-           entry->url);
-       commSetSelect(fd, COMM_SELECT_READ, ftpReadData, data, 0);
-       if (!BIT_TEST(entry->flag, READ_DEFERRED)) {
-           commSetTimeout(fd, Config.Timeout.defer, NULL, NULL);
-           BIT_SET(entry->flag, READ_DEFERRED);
-       }
-       /* dont try reading again for a while */
-       comm_set_stall(fd, 1);
-       return;
-    } else {
-       BIT_RESET(entry->flag, READ_DEFERRED);
-    }
     if (EBIT_TEST(ftpState->flags, FTP_ISDIR))
        if (!EBIT_TEST(ftpState->flags, FTP_HTML_HEADER_SENT))
            ftpListingStart(ftpState);
@@ -1446,6 +1431,7 @@ ftpReadList(FtpStateData * ftpState)
            ftpReadData,
            ftpState,
            0);
+       commSetDefer(ftpState->data.fd, protoCheckDeferRead);
        ftpState->state = READING_DATA;
        return;
     } else if (!EBIT_TEST(ftpState->flags, FTP_TRIED_NLST)) {
@@ -1472,6 +1458,7 @@ ftpReadRetr(FtpStateData * ftpState)
            ftpReadData,
            ftpState,
            0);
+       commSetDefer(ftpState->data.fd, protoCheckDeferRead);
        ftpState->state = READING_DATA;
     } else {
        ftpFail(ftpState);
index 5a54882ad9adab630a18eef9f1c6b1c9c297eb73..cc73d3cfba6f543d78c40f5496d4dbccf883a820 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: gopher.cc,v 1.100 1997/10/22 05:50:29 wessels Exp $
+ * $Id: gopher.cc,v 1.101 1997/10/23 05:13:39 wessels Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -684,28 +684,6 @@ gopherReadReply(int fd, void *data)
     /* check if we want to defer reading */
     clen = entry->mem_obj->inmem_hi;
     off = storeLowestMemReaderOffset(entry);
-    if ((clen - off) > READ_AHEAD_GAP) {
-       IOStats.Gopher.reads_deferred++;
-       debug(10, 3) ("gopherReadReply: Read deferred for Object: %s\n",
-           entry->url);
-       debug(10, 3) ("                Current Gap: %d bytes\n", clen - off);
-       /* reschedule, so it will automatically reactivated when
-        * Gap is big enough.  */
-       commSetSelect(fd,
-           COMM_SELECT_READ,
-           gopherReadReply,
-           data, 0);
-       /* don't install read timeout until we are below the GAP */
-       if (!BIT_TEST(entry->flag, READ_DEFERRED)) {
-           commSetTimeout(fd, Config.Timeout.defer, NULL, NULL);
-           BIT_SET(entry->flag, READ_DEFERRED);
-       }
-       /* dont try reading again for a while */
-       comm_set_stall(fd, 1);
-       return;
-    } else {
-       BIT_RESET(entry->flag, READ_DEFERRED);
-    }
     buf = get_free_4k_page();
     errno = 0;
     /* leave one space for \0 in gopherToHTML */
@@ -833,6 +811,7 @@ gopherSendComplete(int fd, char *buf, int size, int errflag, void *data)
     }
     /* Schedule read reply. */
     commSetSelect(fd, COMM_SELECT_READ, gopherReadReply, gopherState, 0);
+    commSetDefer(fd, protoCheckDeferRead);
     if (buf)
        put_free_4k_page(buf);  /* Allocated by gopherSendRequest. */
 }
index a7738a9e9c0e6322c7c7afe29ef7bd0fe3e116b6..30bfe43281e2d73002c9e783ff283bd4c59babcb 100644 (file)
@@ -1,5 +1,6 @@
+
 /*
- * $Id: http.cc,v 1.193 1997/10/22 05:50:30 wessels Exp $
+ * $Id: http.cc,v 1.194 1997/10/23 05:13:40 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -616,28 +617,6 @@ httpReadReply(int fd, void *data)
     /* check if we want to defer reading */
     clen = entry->mem_obj->inmem_hi;
     off = storeLowestMemReaderOffset(entry);
-    if ((clen - off) > READ_AHEAD_GAP) {
-       IOStats.Http.reads_deferred++;
-       debug(11, 3) ("httpReadReply: Read deferred for Object: %s\n",
-           entry->url);
-       debug(11, 3) ("                Current Gap: %d bytes\n", clen - off);
-       /* reschedule, so it will be automatically reactivated
-        * when Gap is big enough. */
-       commSetSelect(fd,
-           COMM_SELECT_READ,
-           httpReadReply,
-           httpState, 0);
-       /* disable read timeout until we are below the GAP */
-       if (!BIT_TEST(entry->flag, READ_DEFERRED)) {
-           commSetTimeout(fd, Config.Timeout.defer, NULL, NULL);
-           BIT_SET(entry->flag, READ_DEFERRED);
-       }
-       /* dont try reading again for a while */
-       comm_set_stall(fd, 1);
-       return;
-    } else {
-       BIT_RESET(entry->flag, READ_DEFERRED);
-    }
     errno = 0;
     len = read(fd, buf, SQUID_TCP_SO_RCVBUF);
     fd_bytes(fd, len, FD_READ);
@@ -730,6 +709,7 @@ httpSendComplete(int fd, char *buf, int size, int errflag, void *data)
            COMM_SELECT_READ,
            httpReadReply,
            httpState, 0);
+       commSetDefer(fd, protoCheckDeferRead);
     }
 }
 
index 8306cc7f710a09baaf062bd74dd72fd2cad8ac3c..c7b2818cf3989c14fe671e53d18296a664f2e458 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.175 1997/10/20 22:59:47 wessels Exp $
+ * $Id: main.cc,v 1.176 1997/10/23 05:13:42 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -326,6 +326,7 @@ serverConnectionsOpen(void)
            continue;
        comm_listen(fd);
        commSetSelect(fd, COMM_SELECT_READ, httpAccept, NULL, 0);
+       commSetDefer(fd, httpAcceptDefer);
        debug(1, 1) ("Accepting HTTP connections on port %d, FD %d.\n",
            (int) u->i, fd);
        HttpSockets[NHttpSockets++] = fd;
index 8775862fd734c168f662bbbf80d4d9a0a06b3e7a..2828256e878d15fb6171c06af019e5d96cfc80aa 100644 (file)
@@ -99,7 +99,6 @@ extern void comm_add_close_handler _PARAMS((int fd, PF *, void *));
 extern void comm_remove_close_handler _PARAMS((int fd, PF *, void *));
 extern int comm_udp_send _PARAMS((int fd, const char *host, u_short port, const char *buf, int len));
 extern int comm_udp_sendto _PARAMS((int fd, const struct sockaddr_in *, int size, const char *buf, int len));
-extern void comm_set_stall _PARAMS((int, int));
 extern void comm_write _PARAMS((int fd,
        char *buf,
        int size,
@@ -108,6 +107,7 @@ extern void comm_write _PARAMS((int fd,
        FREE *));
 extern void commCallCloseHandlers _PARAMS((int fd));
 extern int commSetTimeout _PARAMS((int fd, int, PF *, void *));
+extern void commSetDefer(int fd, DEFER * func);
 
 extern void _db_init _PARAMS((const char *logfile, const char *options));
 extern void _db_rotate_log _PARAMS((void));
@@ -257,6 +257,7 @@ extern void icpUdpSend _PARAMS((int fd,
        protocol_t));
 extern PF icpHandleUdp;
 extern PF httpAccept;
+extern DEFER httpAcceptDefer;
 #ifdef SQUID_SNMP
 extern PF snmpAccept;
 #endif /* SQUID_SNMP */
@@ -354,7 +355,7 @@ extern void protoDispatch _PARAMS((int, StoreEntry *, request_t *));
 extern int protoUnregister _PARAMS((StoreEntry *, request_t *, struct in_addr));
 extern void protoStart _PARAMS((int, StoreEntry *, peer *, request_t *));
 extern int protoAbortFetch _PARAMS((StoreEntry * entry));
-
+extern DEFER protoCheckDeferRead;
 
 extern void redirectStart _PARAMS((clientHttpRequest *, RH *, void *));
 extern void redirectOpenServers _PARAMS((void));
index fd0023989859434e831daae665b0e3bae7a19e5a..24656e35e4f865cd491216d33cdabf5c20c2f940 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.160 1997/10/20 22:49:42 wessels Exp $
+ * $Id: stat.cc,v 1.161 1997/10/23 05:13:44 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -311,8 +311,6 @@ describeFlags(const StoreEntry * entry)
        strcat(buf, "HI,");
     if (BIT_TEST(flags, ENTRY_NEGCACHED))
        strcat(buf, "NG,");
-    if (BIT_TEST(flags, READ_DEFERRED))
-       strcat(buf, "RD,");
     if ((t = strrchr(buf, ',')))
        *t = '\0';
     return buf;
index 7c2f92b241897509fbdc8a028c9404900274fcb0..8533ce38e6383526c5d3b1ae5e695e05c7654307 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stmem.cc,v 1.50 1997/10/22 17:07:25 wessels Exp $
+ * $Id: stmem.cc,v 1.51 1997/10/23 05:13:45 wessels Exp $
  *
  * DEBUG: section 19    Memory Primitives
  * AUTHOR: Harvest Derived
@@ -128,7 +128,7 @@ memFree(mem_hdr * mem)
            p = p->next;
            if (lastp) {
                put_free_4k_page(lastp->data);
-               store_mem_size -= SM_PAGE_SIZE;
+               store_mem_size -= SM_PAGE_SIZE;
                safe_free(lastp);
            }
        }
index 79f0448c3e29c33f8827d0766fec71465bc7a32b..89968309805aace067e48253cce57e36653935ce 100644 (file)
@@ -116,7 +116,6 @@ struct _SquidConfig {
     time_t neighborTimeout;
     struct {
        time_t read;
-       time_t defer;
        time_t lifetime;
        time_t connect;
        time_t request;
@@ -327,7 +326,7 @@ struct _fde {
     void *timeout_data;
     void *lifetime_data;
     close_handler *close_handler;      /* linked list */
-    time_t stall_until;                /* don't select for read until this time */
+    DEFER *defer_check;                /* check if we should defer read */
     CommWriteStateData *rwstate;       /* State data for comm_write */
 };
 
@@ -496,6 +495,10 @@ struct _ConnStateData {
     CommWriteStateData *commWriteState;
     int nrequests;
     int persistent;
+    struct {
+       int n;
+       time_t until;
+    } defer;
 };
 
 struct _ipcache_addrs {
index 3e888d445b12aa0f9edc9d65a236f7e8102a4fe8..d3bb3bbd058fddba34d5f5d2bd8f946f0957ec7d 100644 (file)
@@ -92,6 +92,7 @@ typedef void IPH _PARAMS((const ipcache_addrs *, void *));
 typedef void IRCB _PARAMS((peer *, peer_t, icp_common_t *, void *data));
 typedef void PSC _PARAMS((peer *, void *));
 typedef void RH _PARAMS((void *data, char *result));
+typedef int DEFER(int fd, void *data);
 
 typedef void SIH _PARAMS((int fd, void *));    /* swap in */
 typedef int QS _PARAMS((const void *, const void *));  /* qsort */
index 15ac25585473ae6584468412099dba15c584dba2..ec41d7579541c596b2aacacf8174432876afc97e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: wais.cc,v 1.86 1997/10/21 19:38:54 wessels Exp $
+ * $Id: wais.cc,v 1.87 1997/10/23 05:13:46 wessels Exp $
  *
  * DEBUG: section 24    WAIS Relay
  * AUTHOR: Harvest Derived
@@ -182,28 +182,6 @@ waisReadReply(int fd, void *data)
     /* check if we want to defer reading */
     clen = entry->mem_obj->inmem_hi;
     off = storeLowestMemReaderOffset(entry);
-    if ((clen - off) > READ_AHEAD_GAP) {
-       IOStats.Wais.reads_deferred++;
-       debug(24, 3) ("waisReadReply: Read deferred for Object: %s\n",
-           entry->url);
-       debug(24, 3) ("                Current Gap: %d bytes\n", clen - off);
-       /* reschedule, so it will automatically reactivated
-        * when Gap is big enough. */
-       commSetSelect(fd,
-           COMM_SELECT_READ,
-           waisReadReply,
-           waisState, 0);
-       /* don't install read handler while we're above the gap */
-       if (!BIT_TEST(entry->flag, READ_DEFERRED)) {
-           commSetTimeout(fd, Config.Timeout.defer, NULL, NULL);
-           BIT_SET(entry->flag, READ_DEFERRED);
-       }
-       /* dont try reading again for a while */
-       comm_set_stall(fd, 1);
-       return;
-    } else {
-       BIT_RESET(entry->flag, READ_DEFERRED);
-    }
     len = read(fd, buf, 4096);
     fd_bytes(fd, len, FD_READ);
     debug(24, 5) ("waisReadReply: FD %d read len:%d\n", fd, len);
@@ -290,6 +268,7 @@ waisSendComplete(int fd, char *buf, int size, int errflag, void *data)
            COMM_SELECT_READ,
            waisReadReply,
            waisState, 0);
+       commSetDefer(fd, protoCheckDeferRead);
     }
 }