summaryrefslogtreecommitdiff
path: root/lib/hash.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-07-11 14:52:06 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2017-07-11 14:58:44 +0200
commit07181496b7c592ca1848166710dc0f27a49e3a0c (patch)
tree55ffca47517567ff2bf85e4c5c5f3c1864523362 /lib/hash.c
parent1c95bad18a0256bc7f85db773a39bbc7484078de (diff)
lib: hash: don't double-init hash list
hash_cmd_init will overwrite _hashes with a new list, while _hashes already has been initialised from cmd_init(), thread_master_create(), or any other function that may have created a hash. Found while valgrind'ing ospf6d/test_lsdb. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/hash.c')
-rw-r--r--lib/hash.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/hash.c b/lib/hash.c
index 95643bbae0..62a39953c6 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -428,6 +428,13 @@ DEFUN(show_hash_stats,
long double ssq; // ssq casted to long double
pthread_mutex_lock (&_hashes_mtx);
+ if (!_hashes)
+ {
+ pthread_mutex_unlock (&_hashes_mtx);
+ vty_outln (vty, "No hash tables in use.");
+ return CMD_SUCCESS;
+ }
+
for (ALL_LIST_ELEMENTS_RO (_hashes, ln, h))
{
if (!h->name)
@@ -482,6 +489,5 @@ DEFUN(show_hash_stats,
void
hash_cmd_init ()
{
- _hashes = list_new();
install_element (ENABLE_NODE, &show_hash_stats_cmd);
}