Index: main/utils.c =================================================================== --- main/utils.c (revision 398366) +++ main/utils.c (working copy) @@ -968,9 +968,6 @@ struct thr_lock_info *lock_info; struct ast_str *str; - if (!(str = ast_str_create(4096))) - return CLI_FAILURE; - switch (cmd) { case CLI_INIT: e->command = "core show locks"; @@ -984,7 +981,10 @@ return NULL; } - ast_str_append(&str, 0, "\n" + if (!(str = ast_str_create(4096))) + return CLI_FAILURE; + + ast_str_append(&str, 0, "\n" "=======================================================================\n" "=== %s\n" "=== Currently Held Locks\n" @@ -2094,6 +2094,17 @@ return 0; } +static void utils_shutdown(void) +{ +#ifdef HAVE_DEV_URANDOM + close(dev_urandom_fd); + dev_urandom_fd = -1; +#endif +#if defined(DEBUG_THREADS) && !defined(LOW_MEMORY) + ast_cli_unregister_multiple(utils_cli, ARRAY_LEN(utils_cli)); +#endif +} + int ast_utils_init(void) { #ifdef HAVE_DEV_URANDOM @@ -2105,6 +2116,7 @@ ast_cli_register_multiple(utils_cli, ARRAY_LEN(utils_cli)); #endif #endif + ast_register_atexit(utils_shutdown); return 0; }