]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
register icpHandleStore, not icpSendMoreData; requires lots of rearranging
authorwessels <>
Thu, 15 May 1997 12:55:44 +0000 (12:55 +0000)
committerwessels <>
Thu, 15 May 1997 12:55:44 +0000 (12:55 +0000)
src/client_side.cc
src/main.cc
src/squid.h
src/ssl.cc
src/store.cc
src/tunnel.cc

index f6ed1898189c6d48285e057c0bbc46a8ae23205a..7ff6c441dd8b193f5608de71b4fcdf7912413d1b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.102 1997/05/08 07:22:01 wessels Exp $
+ * $Id: client_side.cc,v 1.103 1997/05/15 06:55:44 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -351,9 +351,9 @@ icpProcessExpired(int fd, void *data)
     entry->refcount++;         /* EXPIRED CASE */
     http->entry = entry;
     http->out.offset = 0;
-    /* Register with storage manager to receive updates when data comes in. */
-    storeRegister(entry, fd, icpHandleIMSReply, http);
     protoDispatch(fd, http->entry, http->request);
+    /* Register with storage manager to receive updates when data comes in. */
+    storeRegister(entry, icpHandleIMSReply, http, http->out.offset);
 }
 
 static int
@@ -409,10 +409,7 @@ icpHandleIMSReply(void *data)
     } else if (mem->reply->code == 0) {
        debug(33, 3, "icpHandleIMSReply: Incomplete headers for '%s'\n",
            entry->url);
-       storeRegister(entry,
-           fd,
-           icpHandleIMSReply,
-           http);
+       storeRegister(entry, icpHandleIMSReply, http, http->out.offset);
        return;
     } else if (clientGetsOldEntry(entry, http->old_entry, http->request)) {
        /* We initiated the IMS request, the client is not expecting
@@ -420,10 +417,7 @@ icpHandleIMSReply(void *data)
         * headers have been loaded from disk. */
        oldentry = http->old_entry;
        if (oldentry->mem_obj->e_current_len == 0) {
-           storeRegister(entry,
-               fd,
-               icpHandleIMSReply,
-               http);
+           storeRegister(entry, icpHandleIMSReply, http, http->out.offset);
            return;
        }
        http->log_type = LOG_TCP_REFRESH_HIT;
@@ -464,7 +458,7 @@ icpHandleIMSReply(void *data)
        storeUnlockObject(http->old_entry);
     }
     http->old_entry = NULL;    /* done with old_entry */
-    icpSendMoreData(fd, http); /* give data to the client */
+    storeRegister(http->entry, icpHandleStore, http, http->out.offset);
 }
 
 int
index 4637008c8fbcb5699ccb18375d2c0eac69674682..7beec0601f2f6536684b1573c0a7eb5eb7cd6689 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.cc,v 1.145 1997/05/15 01:18:46 wessels Exp $
+ * $Id: main.cc,v 1.146 1997/05/15 06:55:46 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -374,8 +374,8 @@ serverConnectionsOpen(void)
                icpHandleUdp,
                NULL, 0);
            comm_join_mcast_groups(theInIcpConnection);
-           debug(1, 1, "Accepting ICP connections on FD %d.\n",
-               theInIcpConnection);
+           debug(1, 1, "Accepting ICP connections on port %d, FD %d.\n",
+               (int) port, theInIcpConnection);
 
            if ((addr = Config.Addrs.udp_outgoing).s_addr != no_addr.s_addr) {
                enter_suid();
@@ -392,8 +392,8 @@ serverConnectionsOpen(void)
                    COMM_SELECT_READ,
                    icpHandleUdp,
                    NULL, 0);
-               debug(1, 1, "Accepting ICP connections on FD %d.\n",
-                   theOutIcpConnection);
+               debug(1, 1, "Accepting ICP connections on port %d, FD %d.\n",
+                       (int) port, theInIcpConnection);
                fd_note(theOutIcpConnection, "Outgoing ICP socket");
                fd_note(theInIcpConnection, "Incoming ICP socket");
            } else {
index 746aab3cd541cd49c268e05015661bd69523cf12..376f8c970b3dfe5ab5e6f4ec69ae76b28a4b6d67 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: squid.h,v 1.112 1997/05/15 01:18:48 wessels Exp $
+ * $Id: squid.h,v 1.113 1997/05/15 06:55:49 wessels Exp $
  *
  * AUTHOR: Duane Wessels
  *
 #if HAVE_GETOPT_H
 #include <getopt.h>
 #endif
-
 #if HAVE_POLL_H
 #include <poll.h>
 #endif
+#if HAVE_ASSERT_H
+#include <assert.h>
+#else
+#define assert(X) ((void)0)
+#endif
 
 #ifdef __STDC__
 #include <stdarg.h>
@@ -264,6 +268,7 @@ typedef unsigned long u_num32;
 
 typedef void SIH _PARAMS((void *, int));       /* swap in */
 typedef int QS _PARAMS((const void *, const void *));  /* qsort */
+typedef void STCB _PARAMS((void *));   /* store callback */
 
 #include "cache_cf.h"
 #include "fd.h"
index 74fb5be78de86ee9289704e9fb40c52dcbd87503..d8d001e10a9ba0086163d5234a6a9197aac13e06 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ssl.cc,v 1.49 1997/05/08 07:22:07 wessels Exp $
+ * $Id: ssl.cc,v 1.50 1997/05/15 06:55:49 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -92,10 +92,7 @@ sslClientClosed(int fd, void *data)
     debug(26, 3, "sslClientClosed: FD %d\n", fd);
     /* we have been called from comm_close for the client side, so
      * just need to clean up the server side */
-    protoUnregister(sslState->server.fd,
-       NULL,
-       sslState->request,
-       no_addr);
+    protoUnregister(NULL, sslState->request, no_addr);
     comm_close(sslState->server.fd);
 }
 
index 95242f4469c9dea21c2191acd75aa571a1298912..1ff506ee5aba1b7ee77e58772b25ae82a8144e78 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.233 1997/05/15 01:07:03 wessels Exp $
+ * $Id: store.cc,v 1.234 1997/05/15 06:55:50 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -884,19 +884,26 @@ storeAddDiskRestore(const char *url, int file_number, int size, time_t expires,
 }
 
 /* Register interest in an object currently being retrieved. */
-int
-storeRegister(StoreEntry * e, int fd, STCB * handler, void *data)
+void
+storeRegister(StoreEntry * e, STCB * callback, void *data, off_t offset)
 {
     int i;
     MemObject *mem = e->mem_obj;
-    debug(20, 3, "storeRegister: FD %d '%s'\n", fd, e->key);
+    struct _store_client *sc;
+    debug(20, 3, "storeRegister: '%s'\n", e->key);
     if ((i = storeClientListSearch(mem, data)) < 0)
        i = storeClientListAdd(e, data, 0);
-    if (mem->clients[i].callback)
-       fatal_dump("storeRegister: handler already exists");
-    mem->clients[i].callback = handler;
-    mem->clients[i].callback_data = data;
-    return 0;
+    sc = &mem->clients[i];
+    if (sc->callback)
+       fatal_dump("storeRegister: callback already exists");
+    sc->offset = offset;
+    sc->callback = callback;
+    sc->callback_data = data;
+    if (offset < e->object_len) {
+        sc->callback = NULL;
+       /* Don't NULL the callback_data, its used to identify the client */
+        callback(data);
+    }
 }
 
 int
@@ -904,14 +911,16 @@ storeUnregister(StoreEntry * e, void *data)
 {
     int i;
     MemObject *mem = e->mem_obj;
+    struct _store_client *sc;
     if (mem == NULL)
        return 0;
     debug(20, 3, "storeUnregister: called for '%s'\n", e->key);
     if ((i = storeClientListSearch(mem, data)) < 0)
        return 0;
-    mem->clients[i].last_offset = 0;
-    mem->clients[i].callback = NULL;
-    mem->clients[i].callback_data = NULL;
+    sc = &mem->clients[i];
+    sc->offset = 0;
+    sc->callback = NULL;
+    sc->callback_data = NULL;
     debug(20, 9, "storeUnregister: returning 1\n");
     return 1;
 }
@@ -925,8 +934,8 @@ storeGetLowestReaderOffset(const StoreEntry * entry)
     for (i = 0; i < mem->nclients; i++) {
        if (mem->clients[i].callback_data == NULL)
            continue;
-       if (mem->clients[i].last_offset < lowest)
-           lowest = mem->clients[i].last_offset;
+       if (mem->clients[i].offset < lowest)
+           lowest = mem->clients[i].offset;
     }
     return lowest;
 }
@@ -2227,7 +2236,7 @@ storeClientListSearch(const MemObject * mem, void *data)
 
 /* add client with fd to client list */
 int
-storeClientListAdd(StoreEntry * e, void *data, int last_offset)
+storeClientListAdd(StoreEntry * e, void *data, int offset)
 {
     int i;
     MemObject *mem = e->mem_obj;
@@ -2256,7 +2265,7 @@ storeClientListAdd(StoreEntry * e, void *data, int last_offset)
        i = oldsize;
     }
     mem->clients[i].callback_data = data;
-    mem->clients[i].last_offset = last_offset;
+    mem->clients[i].offset = offset;
     return i;
 }
 
@@ -2290,7 +2299,7 @@ storeClientCopy(StoreEntry * e,
     }
     sz = (available_to_write >= maxSize) ? maxSize : available_to_write;
     /* update the lowest requested offset */
-    mem->clients[ci].last_offset = stateoffset + sz;
+    mem->clients[ci].offset = stateoffset + sz;
     if (sz > 0)
        if (mem->data->mem_copy(mem->data, stateoffset, buf, sz) < 0)
            return -1;
index 4c8aba2117c389d2e7cdca271119e00bb64cfa98..8ee39c45ff7ed278901759467f4858085aabf630 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tunnel.cc,v 1.49 1997/05/08 07:22:07 wessels Exp $
+ * $Id: tunnel.cc,v 1.50 1997/05/15 06:55:49 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -92,10 +92,7 @@ sslClientClosed(int fd, void *data)
     debug(26, 3, "sslClientClosed: FD %d\n", fd);
     /* we have been called from comm_close for the client side, so
      * just need to clean up the server side */
-    protoUnregister(sslState->server.fd,
-       NULL,
-       sslState->request,
-       no_addr);
+    protoUnregister(NULL, sslState->request, no_addr);
     comm_close(sslState->server.fd);
 }