1 Index: squid/src/client_db.c
2 diff -c squid/src/client_db.c:1.53 squid/src/client_db.c:1.53.2.1
3 *** squid/src/client_db.c:1.53 Fri Feb 23 13:59:50 2001
4 --- squid/src/client_db.c Sat Jul 17 16:37:30 2004
8 static hash_table *client_table = NULL;
9 static ClientInfo *clientdbAdd(struct in_addr addr);
10 static FREE clientdbFreeItem;
11 + static void clientdbStartGC(void);
13 + static int max_clients = 32;
14 + static int cleanup_running = 0;
15 + static int cleanup_scheduled = 0;
16 + static int cleanup_removed;
18 + #define CLIENT_DB_HASH_SIZE 467
21 clientdbAdd(struct in_addr addr)
26 hash_join(client_table, &c->hash);
27 statCounter.client_http.clients++;
28 + if ((statCounter.client_http.clients > max_clients) && !cleanup_running)
38 ! client_table = hash_create((HASHCMP *) strcmp, 467, hash_string);
39 cachemgrRegister("client_list",
46 ! client_table = hash_create((HASHCMP *) strcmp, CLIENT_DB_HASH_SIZE, hash_string);
47 cachemgrRegister("client_list",
53 if (LOG_UDP_HIT == ltype)
54 kb_incr(&c->Icp.hit_kbytes_out, size);
56 + c->last_seen = squid_curtime;
67 + clientdbScheduledGC(void *unused)
69 + cleanup_scheduled = 0;
74 + clientdbGC(void *unused)
76 + static int bucket = 0;
77 + hash_link *link_next;
79 + link_next = hash_get_bucket(client_table, bucket++);
80 + while (link_next != NULL) {
81 + ClientInfo *c = (ClientInfo *) link_next;
82 + int age = squid_curtime - c->last_seen;
83 + link_next = link_next->next;
84 + if (c->n_established)
87 + if (age < 24 * 3600 && c->Http.n_requests > 100)
89 + if (age < 4 * 3600 && (c->Http.n_requests > 10 || c->Icp.n_requests > 10))
91 + if (age < 5 * 60 && (c->Http.n_requests > 1 || c->Icp.n_requests > 1))
95 + hash_remove_link(client_table, &c->hash);
96 + clientdbFreeItem(c);
97 + statCounter.client_http.clients--;
101 + if (bucket < CLIENT_DB_HASH_SIZE)
102 + eventAdd("client_db garbage collector", clientdbGC, NULL, 0.15, 0);
105 + cleanup_running = 0;
106 + max_clients = statCounter.client_http.clients * 3 / 2;
107 + if (!cleanup_scheduled) {
108 + cleanup_scheduled = 1;
109 + eventAdd("client_db garbage collector", clientdbScheduledGC, NULL, 6 * 3600, 0);
111 + debug(49, 1) ("clientdbGC: Removed %d entries\n", cleanup_removed);
116 + clientdbStartGC(void)
118 + max_clients = statCounter.client_http.clients;
119 + cleanup_running = 1;
120 + cleanup_removed = 0;
126 client_entry(struct in_addr *current)
127 Index: squid/src/structs.h
128 diff -c squid/src/structs.h:1.408.2.24 squid/src/structs.h:1.408.2.25
129 *** squid/src/structs.h:1.408.2.24 Sun Apr 18 17:43:30 2004
130 --- squid/src/structs.h Sat Jul 17 16:37:30 2004
136 int n_established; /* number of current established connections */
140 struct _CacheDigest {