]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixes to get pipelined client requests working better. Need a function
authorwessels <>
Tue, 25 Nov 1997 05:32:36 +0000 (05:32 +0000)
committerwessels <>
Tue, 25 Nov 1997 05:32:36 +0000 (05:32 +0000)
called storeClientPending() whose purpose is to tell the client side
if there is already a callback registered for the entry and the client.
If not, then we'll register one via storeClientCopy().  This is due to
a race condition; when we have pipelined requests, we can not guarantee
that we'll get Deferred in clientSendMoreData() before its time to
send the object off to the client, so the original handler may still
be in place.

src/client_side.cc
src/protos.h
src/store.cc

index 41d788a9835b083139c64009e53d34525838c322..bb13ecbb4dcb120207da08f6da9077d7afc3578c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.157 1997/11/23 06:50:27 wessels Exp $
+ * $Id: client_side.cc,v 1.158 1997/11/24 22:32:36 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -972,13 +972,14 @@ clientWriteComplete(int fd, char *bufnotused, size_t size, int errflag, void *da
            httpRequestFree(http);
            if ((http = conn->chr) != NULL) {
                debug(12, 1) ("clientWriteComplete: FD %d Sending next request\n", fd);
-               storeClientCopy(entry,
-                   http->out.offset,
-                   http->out.offset,
-                   SM_PAGE_SIZE,
-                   get_free_4k_page(),
-                   clientSendMoreData,
-                   http);
+               if (!storeClientCopyPending(http->entry, http))
+                   storeClientCopy(http->entry,
+                       http->out.offset,
+                       http->out.offset,
+                       SM_PAGE_SIZE,
+                       get_free_4k_page(),
+                       clientSendMoreData,
+                       http);
            } else {
                debug(12, 5) ("clientWriteComplete: FD %d Setting read handler for next request\n", fd);
                fd_note(fd, "Reading next request");
@@ -1872,26 +1873,26 @@ clientHttpConnectionsOpen(void)
 {
     ushortlist *u;
     int fd;
-debug(0,0)("clientHttpConnectionsOpen\n");
+    debug(0, 0) ("clientHttpConnectionsOpen\n");
     for (u = Config.Port.http; u; u = u->next) {
-debug(0,0)("clientHttpConnectionsOpen: port=%d\n", (int) u->i);
-        enter_suid();
-        fd = comm_open(SOCK_STREAM,
-            0,
-            Config.Addrs.tcp_incoming,
-            u->i,
-            COMM_NONBLOCKING,
-            "HTTP Socket");
-        leave_suid();
-        if (fd < 0)
-            continue;
-        comm_listen(fd);
-        commSetSelect(fd, COMM_SELECT_READ, httpAccept, NULL, 0);
-        commSetDefer(fd, httpAcceptDefer, NULL);
-        debug(1, 1) ("Accepting HTTP connections on port %d, FD %d.\n",
-            (int) u->i, fd);
-        HttpSockets[NHttpSockets++] = fd;
+       debug(0, 0) ("clientHttpConnectionsOpen: port=%d\n", (int) u->i);
+       enter_suid();
+       fd = comm_open(SOCK_STREAM,
+           0,
+           Config.Addrs.tcp_incoming,
+           u->i,
+           COMM_NONBLOCKING,
+           "HTTP Socket");
+       leave_suid();
+       if (fd < 0)
+           continue;
+       comm_listen(fd);
+       commSetSelect(fd, COMM_SELECT_READ, httpAccept, NULL, 0);
+       commSetDefer(fd, httpAcceptDefer, NULL);
+       debug(1, 1) ("Accepting HTTP connections on port %d, FD %d.\n",
+           (int) u->i, fd);
+       HttpSockets[NHttpSockets++] = fd;
     }
     if (NHttpSockets < 1)
-        fatal("Cannot open HTTP Port");
+       fatal("Cannot open HTTP Port");
 }
index 0a598a456170c534e0186d7d9901af433a80cacd..3ec9e63ee00793eb83319e90796c5040b53ae44d 100644 (file)
@@ -443,6 +443,7 @@ extern void storeNegativeCache(StoreEntry *);
 extern void storeFreeMemory(void);
 extern int expiresMoreThan(time_t, time_t);
 extern void storeClientListAdd(StoreEntry *, void *);
+extern int storeClientCopyPending(StoreEntry *, void *);
 extern void InvokeHandlers(StoreEntry *);
 extern int storeEntryValidToSend(StoreEntry *);
 extern void storeTimestampsSet(StoreEntry *);
index 33e95135e6c4ebaf8f426913c3e1798bdabe71da..d7afd0f12d5dfebd3bdfd8e98781a6c6011be25e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.346 1997/11/18 01:02:42 wessels Exp $
+ * $Id: store.cc,v 1.347 1997/11/24 22:32:38 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -702,7 +702,6 @@ InvokeHandlers(StoreEntry * e)
 {
     int i = 0;
     MemObject *mem = e->mem_obj;
-    STCB *callback = NULL;
     store_client *sc;
     store_client *nx = NULL;
     assert(mem->clients != NULL || mem->nclients == 0);
@@ -710,10 +709,10 @@ InvokeHandlers(StoreEntry * e)
     /* walk the entire list looking for valid callbacks */
     for (sc = mem->clients; sc; sc = nx) {
        nx = sc->next;
-       debug(20, 3) ("InvokeHandlers: checking client #%d\n", i++);
+       debug(20, 0) ("InvokeHandlers: checking client #%d\n", i++);
        if (sc->callback_data == NULL)
            continue;
-       if ((callback = sc->callback) == NULL)
+       if (sc->callback == NULL)
            continue;
        storeClientCopy2(e, sc);
     }
@@ -1694,7 +1693,7 @@ storeClientCopy(StoreEntry * e,
 {
     store_client *sc;
     static int recurse_detect = 0;
-    assert(e->store_status != STORE_ABORTED);
+    /*assert(e->store_status != STORE_ABORTED); */
     assert(recurse_detect < 3);        /* could == 1 for IMS not modified's */
     debug(20, 3) ("storeClientCopy: %s, seen %d, want %d, size %d, cb %p, cbdata %p\n",
        storeKeyText(e->key),
@@ -1798,6 +1797,18 @@ storeClientCopyHandleRead(int fd, const char *buf, int len, int flagnotused, voi
     callback(sc->callback_data, sc->copy_buf, len);
 }
 
+int
+storeClientCopyPending(StoreEntry * e, void *data)
+{
+    /* return 1 if there is a callback registered for this client */
+    store_client *sc = storeClientListSearch(e->mem_obj, data);
+    if (sc == NULL)
+       return 0;
+    if (sc->callback == NULL)
+       return 0;
+    return 1;
+}
+
 static int
 storeEntryValidLength(const StoreEntry * e)
 {
@@ -2378,15 +2389,15 @@ storeCopyNotModifiedReplyHeaders(MemObject * oldmem, MemObject * newmem)
 
 /* this just sets DELAY_SENDING */
 void
-storeBuffer(StoreEntry *e)
+storeBuffer(StoreEntry * e)
 {
-       EBIT_SET(e->flag, DELAY_SENDING);
+    EBIT_SET(e->flag, DELAY_SENDING);
 }
 
 /* this just clears DELAY_SENDING and Invokes the handlers */
 void
-storeBufferFlush(StoreEntry *e)
+storeBufferFlush(StoreEntry * e)
 {
-       EBIT_CLR(e->flag, DELAY_SENDING);
-       InvokeHandlers(e);
+    EBIT_CLR(e->flag, DELAY_SENDING);
+    InvokeHandlers(e);
 }