From c6ccf1c513ea84a6daf251f76fc79996cd841c9a Mon Sep 17 00:00:00 2001 From: Brian West Date: Thu, 2 Jul 2015 10:08:54 -0500 Subject: [PATCH] FS-7761 [core] fix shutdown races running api commands during shutdown --- src/switch_loadable_module.c | 4 ++-- src/switch_time.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index 193eb8fce0..b49af923c4 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -2172,8 +2172,8 @@ SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_inte #define HASH_FUNC(_kind_) SWITCH_DECLARE(switch_##_kind_##_interface_t *) switch_loadable_module_get_##_kind_##_interface(const char *name) \ { \ - switch_##_kind_##_interface_t *i; \ - if ((i = switch_core_hash_find_locked(loadable_modules._kind_##_hash, name, loadable_modules.mutex))) { \ + switch_##_kind_##_interface_t *i = NULL; \ + if (loadable_modules._kind_##_hash && (i = switch_core_hash_find_locked(loadable_modules._kind_##_hash, name, loadable_modules.mutex))) { \ PROTECT_INTERFACE(i); \ } \ return i; \ diff --git a/src/switch_time.c b/src/switch_time.c index 7642be10e2..b539d9be10 100644 --- a/src/switch_time.c +++ b/src/switch_time.c @@ -1362,7 +1362,11 @@ SWITCH_DECLARE(const char *) switch_lookup_timezone(const char *tz_name) { char *value = NULL; - if (tz_name && (value = switch_core_hash_find(TIMEZONES_LIST.hash, tz_name)) == NULL) { + if (zstr(tz_name) || !TIMEZONES_LIST.hash) { + return NULL; + } + + if ((value = switch_core_hash_find(TIMEZONES_LIST.hash, tz_name)) == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timezone '%s' not found!\n", tz_name); }