Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mike Perry
Tor
Commits
fcbb817d
Commit
fcbb817d
authored
Jul 17, 2007
by
Roger Dingledine
Browse files
free another string, and the buffer freelists, on exit.
svn:r10851
parent
ccfda2e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/or/buffers.c
View file @
fcbb817d
...
...
@@ -254,9 +254,10 @@ buf_get_initial_mem(buf_t *buf, size_t sz)
}
/** Remove elements from the freelists that haven't been needed since the
* last call to this function. */
* last call to this function. If <b>free_all</b>, we're exiting and we
* should clear the whole lists. */
void
buf_shrink_freelists
(
void
)
buf_shrink_freelists
(
int
free_all
)
{
int
j
;
for
(
j
=
0
;
j
<
2
;
++
j
)
{
...
...
@@ -267,8 +268,10 @@ buf_shrink_freelists(void)
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
);
/* Skip over the slack and non-lowwater entries */
n_to_free
=
list
->
lowwater
-
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
;
...
...
src/or/config.c
View file @
fcbb817d
...
...
@@ -715,21 +715,22 @@ set_options(or_options_t *new_val, char **msg)
extern
const
char
tor_svn_revision
[];
/* from tor_main.c */
static
char
*
_version
=
NULL
;
/** Return the current Tor version, possibly */
const
char
*
get_version
(
void
)
{
static
char
*
version
=
NULL
;
if
(
version
==
NULL
)
{
if
(
_version
==
NULL
)
{
if
(
strlen
(
tor_svn_revision
))
{
size_t
len
=
strlen
(
VERSION
)
+
strlen
(
tor_svn_revision
)
+
8
;
version
=
tor_malloc
(
len
);
tor_snprintf
(
version
,
len
,
"%s (r%s)"
,
VERSION
,
tor_svn_revision
);
_
version
=
tor_malloc
(
len
);
tor_snprintf
(
_
version
,
len
,
"%s (r%s)"
,
VERSION
,
tor_svn_revision
);
}
else
{
version
=
tor_strdup
(
VERSION
);
_
version
=
tor_strdup
(
VERSION
);
}
}
return
version
;
return
_
version
;
}
/** Release all memory and resources held by global configuration structures.
...
...
@@ -746,6 +747,7 @@ config_free_all(void)
global_state
=
NULL
;
}
tor_free
(
torrc_fname
);
tor_free
(
_version
);
}
/** If options->SafeLogging is on, return a not very useful string,
...
...
src/or/main.c
View file @
fcbb817d
...
...
@@ -1046,7 +1046,7 @@ run_scheduled_events(time_t now)
buf_shrink
(
conn
->
inbuf
);
});
clean_cell_pool
();
buf_shrink_freelists
();
buf_shrink_freelists
(
0
);
time_to_shrink_memory
=
now
+
MEM_SHRINK_INTERVAL
;
}
...
...
@@ -1767,6 +1767,7 @@ tor_free_all(int postfork)
circuit_free_all
();
entry_guards_free_all
();
connection_free_all
();
buf_shrink_freelists
(
1
);
policies_free_all
();
if
(
!
postfork
)
{
config_free_all
();
...
...
src/or/or.h
View file @
fcbb817d
...
...
@@ -2149,7 +2149,7 @@ buf_t *buf_new_with_capacity(size_t size);
void
buf_free
(
buf_t
*
buf
);
void
buf_clear
(
buf_t
*
buf
);
void
buf_shrink
(
buf_t
*
buf
);
void
buf_shrink_freelists
(
void
);
void
buf_shrink_freelists
(
int
free_all
);
size_t
buf_datalen
(
const
buf_t
*
buf
);
size_t
buf_capacity
(
const
buf_t
*
buf
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment