]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
- StoreEntry didn't need to have the method_t member, so its been
authorwessels <>
Fri, 28 Nov 1997 15:11:58 +0000 (15:11 +0000)
committerwessels <>
Fri, 28 Nov 1997 15:11:58 +0000 (15:11 +0000)
  moved to MemObject->method.
- storeEntryListAdd and storeEntryListDelete are quite general.  They
  have been moved to tools.c and named dlinkAdd() and dlinkDelete().
- we want to be able to cache ALL methods, so store_key_url.c now
  always puts the request method into the cache key.
- made StoreEntry->refcount and StoreEntry->flag 16-bit shorts.

src/stat.cc
src/store.cc
src/structs.h
src/tools.cc

index 6430442a70ecc0db70997526a23f3be135fbd2ae..8962bb35b9766879931c080ca07a0acfee52ab22 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.175 1997/11/20 06:25:31 wessels Exp $
+ * $Id: stat.cc,v 1.176 1997/11/28 08:11:58 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -331,8 +331,9 @@ statObjects(StoreEntry * sentry, int vm_or_not)
        }
        storeBuffer(sentry);
        storeAppendPrintf(sentry, "KEY %s\n", storeKeyText(entry->key));
-       storeAppendPrintf(sentry, "\t%s %s\n",
-           RequestMethodStr[entry->method], storeUrl(entry));
+       if (mem)
+           storeAppendPrintf(sentry, "\t%s %s\n",
+               RequestMethodStr[mem->method], mem->url);
        storeAppendPrintf(sentry, "\t%s\n", describeStatuses(entry));
        storeAppendPrintf(sentry, "\t%s\n", describeFlags(entry));
        storeAppendPrintf(sentry, "\t%s\n", describeTimestamps(entry));
index 49fe1ab42c8976d8e294da11e34c2eab9e2a42ab..46978527773d3ab3e685a1184b9707eaf6da3a35 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.348 1997/11/24 22:36:24 wessels Exp $
+ * $Id: store.cc,v 1.349 1997/11/28 08:11:59 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -259,8 +259,6 @@ static SIH storeClientCopyFileOpened;
 static DRCB storeClientCopyHandleRead;
 static FOCB storeSwapInFileOpened;
 static void storeClientCopyFileRead(store_client * sc);
-static void storeEntryListAdd(StoreEntry * e, dlink_node *, dlink_list *);
-static void storeEntryListDelete(dlink_node *, dlink_list *);
 static void storeSetMemStatus(StoreEntry * e, int);
 static void storeClientCopy2(StoreEntry *, store_client *);
 static void storeHashInsert(StoreEntry * e, const cache_key *);
@@ -375,14 +373,14 @@ storeHashInsert(StoreEntry * e, const cache_key * key)
        e, storeKeyText(key));
     e->key = storeKeyDup(key);
     hash_join(store_table, (hash_link *) e);
-    storeEntryListAdd(e, &e->lru, &all_list);
+    dlinkAdd(e, &e->lru, &all_list);
 }
 
 static void
 storeHashDelete(StoreEntry * e)
 {
     hash_remove_link(store_table, (hash_link *) e);
-    storeEntryListDelete(&e->lru, &all_list);
+    dlinkDelete(&e->lru, &all_list);
     storeKeyFree(e->key);
     e->key = NULL;
 }
@@ -417,7 +415,7 @@ storeLog(int tag, const StoreEntry * e)
        reply->content_type[0] ? reply->content_type : "unknown",
        reply->content_length,
        (int) (mem->inmem_hi - mem->reply->hdr_sz),
-       RequestMethodStr[e->method],
+       RequestMethodStr[mem->method],
        mem->log_url);
     file_write(storelog_fd,
        xstrdup(logmsg),
@@ -448,8 +446,8 @@ void
 storeLockObject(StoreEntry * e)
 {
     if (e->lock_count++ == 0) {
-       storeEntryListDelete(&e->lru, &all_list);
-       storeEntryListAdd(e, &e->lru, &all_list);
+       dlinkDelete(&e->lru, &all_list);
+       dlinkAdd(e, &e->lru, &all_list);
     }
     debug(20, 3) ("storeLockObject: key '%s' count=%d\n",
        storeKeyText(e->key), (int) e->lock_count);
@@ -522,7 +520,7 @@ storeSetPrivateKey(StoreEntry * e)
        storeHashDelete(e);
     if (mem != NULL) {
        mem->reqnum = getKeyCounter();
-       newkey = storeKeyPrivate(mem->url, e->method, mem->reqnum);
+       newkey = storeKeyPrivate(mem->url, mem->method, mem->reqnum);
     } else {
        newkey = storeKeyPrivate("JUNK", METHOD_NONE, getKeyCounter());
     }
@@ -540,12 +538,12 @@ storeSetPublicKey(StoreEntry * e)
     if (e->key && !EBIT_TEST(e->flag, KEY_PRIVATE))
        return;                 /* is already public */
     assert(mem);
-    newkey = storeKeyPublic(mem->url, e->method);
+    newkey = storeKeyPublic(mem->url, mem->method);
     if ((e2 = (StoreEntry *) hash_lookup(store_table, newkey))) {
        debug(20, 3) ("storeSetPublicKey: Making old '%s' private.\n", mem->url);
        storeSetPrivateKey(e2);
        storeRelease(e2);
-       newkey = storeKeyPublic(mem->url, e->method);
+       newkey = storeKeyPublic(mem->url, mem->method);
     }
     if (e->key)
        storeHashDelete(e);
@@ -563,7 +561,7 @@ storeCreateEntry(const char *url, const char *log_url, int flags, method_t metho
     e = new_StoreEntry(WITH_MEMOBJ, url, log_url);
     e->lock_count = 1;         /* Note lock here w/o calling storeLock() */
     mem = e->mem_obj;
-    e->method = method;
+    mem->method = method;
     if (neighbors_do_private_keys || !EBIT_TEST(flags, REQ_HIERARCHICAL))
        storeSetPrivateKey(e);
     else
@@ -611,7 +609,6 @@ storeAddDiskRestore(const cache_key * key,
     /* if you call this you'd better be sure file_number is not 
      * already in use! */
     e = new_StoreEntry(WITHOUT_MEMOBJ, NULL, NULL);
-    e->method = METHOD_GET;
     storeHashInsert(e, key);
     e->store_status = STORE_OK;
     storeSetMemStatus(e, NOT_IN_MEMORY);
@@ -1388,9 +1385,12 @@ storeStartRebuildFromDisk(void)
 static int
 storeCheckCachable(StoreEntry * e)
 {
-    if (e->method != METHOD_GET) {
+#if CACHE_ALL_METHODS
+    if (e->mem_obj->method != METHOD_GET) {
        debug(20, 2) ("storeCheckCachable: NO: non-GET method\n");
-    } else if (!EBIT_TEST(e->flag, ENTRY_CACHABLE)) {
+    } else
+#endif
+    if (!EBIT_TEST(e->flag, ENTRY_CACHABLE)) {
        debug(20, 2) ("storeCheckCachable: NO: not cachable\n");
     } else if (EBIT_TEST(e->flag, RELEASE_REQUEST)) {
        debug(20, 2) ("storeCheckCachable: NO: release requested\n");
@@ -2297,33 +2297,6 @@ storeMemObjectDump(MemObject * mem)
        checkNullString(mem->log_url));
 }
 
-static void
-storeEntryListAdd(StoreEntry * e, dlink_node * m, dlink_list * list)
-{
-    debug(20, 3) ("storeEntryListAdd: %s\n", storeKeyText(e->key));
-    m->data = e;
-    m->prev = NULL;
-    m->next = list->head;
-    if (list->head)
-       list->head->prev = m;
-    list->head = m;
-    if (list->tail == NULL)
-       list->tail = m;
-}
-
-static void
-storeEntryListDelete(dlink_node * m, dlink_list * list)
-{
-    if (m->next)
-       m->next->prev = m->prev;
-    if (m->prev)
-       m->prev->next = m->next;
-    if (m == list->head)
-       list->head = m->next;
-    if (m == list->tail)
-       list->tail = m->prev;
-}
-
 /* NOTE, this function assumes only two mem states */
 static void
 storeSetMemStatus(StoreEntry * e, int new_status)
@@ -2334,10 +2307,10 @@ storeSetMemStatus(StoreEntry * e, int new_status)
     assert(mem != NULL);
     if (new_status == IN_MEMORY) {
        assert(mem->inmem_lo == 0);
-       storeEntryListAdd(e, &mem->lru, &inmem_list);
+       dlinkAdd(e, &mem->lru, &inmem_list);
        meta_data.hot_vm++;
     } else {
-       storeEntryListDelete(&mem->lru, &inmem_list);
+       dlinkDelete(&mem->lru, &inmem_list);
        meta_data.hot_vm--;
     }
     e->mem_status = new_status;
index e2c8938c3ec49475707eafde98fc37ccfcdc2763..5c6779d021cd8602475cdd165440500ec06a1741 100644 (file)
@@ -133,7 +133,7 @@ struct _SquidConfig {
        char *mibPath;
        u_short localPort;
        int do_queueing;
-       } Snmp;
+    } Snmp;
     struct {
        char *log;
        char *access;
@@ -511,6 +511,17 @@ struct _ConnStateData {
     } defer;
 };
 
+struct _dlink_node {
+    void *data;
+    dlink_node *prev;
+    dlink_node *next;
+};
+
+struct _dlink_list {
+    dlink_node *head;
+    dlink_node *tail;
+};
+
 struct _ipcache_addrs {
     struct in_addr *in_addrs;
     unsigned char *bad_mask;
@@ -528,7 +539,8 @@ struct _ipcache_entry {
     ipcache_addrs addrs;
     struct _ip_pending *pending_head;
     char *error_message;
-    unsigned char locks;
+    dlink_node lru;
+    u_char locks;
     ipcache_status_t status:3;
 };
 
@@ -748,19 +760,9 @@ struct _store_client {
     struct _store_client *next;
 };
 
-struct _dlink_node {
-    void *data;
-    dlink_node *prev;
-    dlink_node *next;
-};
-
-struct _dlink_list {
-    dlink_node *head;
-    dlink_node *tail;
-};
-
 /* This structure can be freed while object is purged out from memory */
 struct _MemObject {
+    method_t method;
     char *url;
     mem_hdr *data;
     off_t inmem_hi;
@@ -792,8 +794,6 @@ struct _StoreEntry {
     const cache_key *key;
     struct _StoreEntry *next;
     MemObject *mem_obj;
-    u_num32 flag;
-    u_num32 refcount;
     time_t timestamp;
     time_t lastref;
     time_t expires;
@@ -801,12 +801,13 @@ struct _StoreEntry {
     int object_len;
     int swap_file_number;
     dlink_node lru;
+    u_short flag;
+    u_short refcount;
+    u_char lock_count;         /* Assume < 256! */
     mem_status_t mem_status:3;
     ping_status_t ping_status:3;
     store_status_t store_status:3;
     swap_status_t swap_status:3;
-    method_t method:4;
-    unsigned char lock_count;  /* Assume < 256! */
 };
 
 struct _SwapDir {
index 1d5d2a46468947bea20737040afa2644b634dd56..236335583f3b1aef5f5ab6788b6a08ccc51d354e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.130 1997/11/15 00:14:52 wessels Exp $
+ * $Id: tools.cc,v 1.131 1997/11/28 08:12:02 wessels Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -815,3 +815,29 @@ checkNullString(char *p)
 {
     return p ? p : "(NULL)";
 }
+
+void
+dlinkAdd(void *data, dlink_node * m, dlink_list * list)
+{
+    m->data = data;
+    m->prev = NULL;
+    m->next = list->head;
+    if (list->head)
+       list->head->prev = m;
+    list->head = m;
+    if (list->tail == NULL)
+       list->tail = m;
+}
+
+void
+dlinkDelete(dlink_node * m, dlink_list * list)
+{
+    if (m->next)
+       m->next->prev = m->prev;
+    if (m->prev)
+       m->prev->next = m->next;
+    if (m == list->head)
+       list->head = m->next;
+    if (m == list->tail)
+       list->tail = m->prev;
+}