Revision: 14358
Author: adrian.chadd
Date: Wed Nov  4 15:05:00 2009
Log: Use statically allocated local prefix_t's in the client db code.
The radix tree code will copy-on-reference them as needed.


http://code.google.com/p/lusca-cache/source/detail?r=14358

Modified:
  /branches/LUSCA_HEAD/src/client_db.c

=======================================
--- /branches/LUSCA_HEAD/src/client_db.c        Wed Nov  4 06:22:43 2009
+++ /branches/LUSCA_HEAD/src/client_db.c        Wed Nov  4 15:05:00 2009
@@ -76,15 +76,13 @@
  clientdbAdd(struct in_addr addr)
  {
      radix_node_t *rn;
-    prefix_t *p;
+    prefix_t p;
      ClientInfo *c;

-    /* XXX should make this static? */
-    p = New_Prefix(AF_INET, &addr, 32, NULL);
+    Init_Prefix(&p, AF_INET, &addr, 32);
      c = memPoolAlloc(pool_client_info);
      c->addr = addr;
-    rn = radix_lookup(client_tree, p);
-    Deref_Prefix(p);
+    rn = radix_lookup(client_tree, &p);
      rn->data = c;
      statCounter.client_http.clients++;
      if ((statCounter.client_http.clients > max_clients)  
&& !cleanup_running && !cleanup_scheduled) {
@@ -114,15 +112,15 @@
  clientdbUpdate(struct in_addr addr, log_type ltype, protocol_t p,  
squid_off_t size)
  {
      radix_node_t *rn;
-    prefix_t *pr;
+    prefix_t pr;
      ClientInfo *c = NULL;

      if (!Config.onoff.client_db)
        return;

-    pr = New_Prefix(AF_INET, &addr, 32, NULL); /* XXX should be a static  
prefix_t! */
-    rn = radix_search_exact(client_tree, pr);
-    Deref_Prefix(pr);
+    Init_Prefix(&pr, AF_INET, &addr, 32);
+    rn = radix_search_exact(client_tree, &pr);
+
      if (rn)
          c = rn->data;
      if (c == NULL)
@@ -156,14 +154,13 @@
  clientdbEstablished(struct in_addr addr, int delta)
  {
      ClientInfo *c = NULL;
-    prefix_t *p;
+    prefix_t p;
      radix_node_t *rn;

      if (!Config.onoff.client_db)
        return 0;
-    p = New_Prefix(AF_INET, &addr, 32, NULL);          /* XXX should be a 
static  
prefix_t! */
-    rn = radix_search_exact(client_tree, p);
-    Deref_Prefix(p);
+    Init_Prefix(&p, AF_INET, &addr, 32);
+    rn = radix_search_exact(client_tree, &p);
      if (rn)
          c = rn->data;
      if (c == NULL)
@@ -182,15 +179,14 @@
      int ND;
      double p;
      ClientInfo *c = NULL;
-    prefix_t *pr;
+    prefix_t pr;
      radix_node_t *rn;

      if (!Config.onoff.client_db)
        return 0;

-    pr = New_Prefix(AF_INET, &addr, 32, NULL); /* XXX should be a static  
prefix_t! */
-    rn = radix_search_exact(client_tree, pr);
-    Deref_Prefix(pr);
+    Init_Prefix(&pr, AF_INET, &addr, 32);
+    rn = radix_search_exact(client_tree, &pr);
      if (rn)
          c = rn->data;


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to