[or-cvs] r10854: free bridge list on exit; try harder to free buffer freelist (tor/trunk/src/or)
arma at seul.org
arma at seul.org
Tue Jul 17 11:33:38 UTC 2007
Author: arma
Date: 2007-07-17 07:33:38 -0400 (Tue, 17 Jul 2007)
New Revision: 10854
Modified:
tor/trunk/src/or/buffers.c
tor/trunk/src/or/circuitbuild.c
Log:
free bridge list on exit; try harder to free buffer freelists on exit.
Modified: tor/trunk/src/or/buffers.c
===================================================================
--- tor/trunk/src/or/buffers.c 2007-07-17 09:37:00 UTC (rev 10853)
+++ tor/trunk/src/or/buffers.c 2007-07-17 11:33:38 UTC (rev 10854)
@@ -262,16 +262,19 @@
int j;
for (j = 0; j < 2; ++j) {
free_mem_list_t *list = j ? &free_mem_list_16k : &free_mem_list_4k;
- if (list->lowwater > list->slack) {
+ if (list->lowwater > list->slack || free_all) {
int i, n_to_skip, n_to_free;
char **ptr;
- log_info(LD_GENERAL, "We haven't used %d/%d allocated %d-byte buffer "
+ if (free_all) { /* Free every one of them */
+ log_info(LD_GENERAL, "Freeing all %d elements from %d-byte freelist.",
+ list->len, (int)list->chunksize);
+ n_to_free = list->len;
+ } else { /* Skip over the slack and non-lowwater entries */
+ log_info(LD_GENERAL, "We haven't used %d/%d allocated %d-byte buffer "
"memory chunks since the last call; freeing all but %d of them",
list->lowwater, list->len, (int)list->chunksize, list->slack);
- if (free_all) /* Free every one of them */
- n_to_free = list->len;
- else /* Skip over the slack and non-lowwater entries */
n_to_free = list->lowwater - list->slack;
+ }
n_to_skip = list->len - n_to_free;
for (ptr = &list->list, i = 0; i < n_to_skip; ++i) {
char *mem = *ptr;
Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c 2007-07-17 09:37:00 UTC (rev 10853)
+++ tor/trunk/src/or/circuitbuild.c 2007-07-17 11:33:38 UTC (rev 10854)
@@ -2083,17 +2083,6 @@
entry_guards_changed();
}
-/** Release all storage held by the list of entry guards. */
-void
-entry_guards_free_all(void)
-{
- if (entry_guards) {
- SMARTLIST_FOREACH(entry_guards, entry_guard_t *, e, tor_free(e));
- smartlist_free(entry_guards);
- entry_guards = NULL;
- }
-}
-
/** How long (in seconds) do we allow an entry guard to be nonfunctional,
* unlisted, excluded, or otherwise nonusable before we give up on it? */
#define ENTRY_GUARD_REMOVE_AFTER (30*24*60*60)
@@ -2823,3 +2812,18 @@
#endif
}
+/** Release all storage held by the list of entry guards and related
+ * memory structs. */
+void
+entry_guards_free_all(void)
+{
+ if (entry_guards) {
+ SMARTLIST_FOREACH(entry_guards, entry_guard_t *, e, tor_free(e));
+ smartlist_free(entry_guards);
+ entry_guards = NULL;
+ }
+ clear_bridge_list();
+ smartlist_free(bridge_list);
+ bridge_list = NULL;
+}
+
More information about the tor-commits
mailing list