From 04873686458b667fa7149e8a97c3437efc014277 Mon Sep 17 00:00:00 2001
From: Olle Johansson <oej@edvina.net>
Date: Tue, 31 Oct 2006 08:08:56 +0000
Subject: [PATCH] Take two, using find_resource on Kevin's suggestion. Might
 need better locking support, giving up if we can't get the lock. Right now,
 using existing locking in find_resource

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 main/loader.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/main/loader.c b/main/loader.c
index c0636142aa..525eef4150 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -871,23 +871,17 @@ int ast_update_module_list(int (*modentry)(const char *module, const char *descr
 	return total_mod_loaded;
 }
 
+/*! \brief Check if module exists */
 int ast_module_check(char *name)
 {
 	struct ast_module *cur;
-	int unlock = -1;
-	int res = 0;
 
 	if (ast_strlen_zero(name))
 		return 0;       /* FALSE */
 
-	if (ast_mutex_trylock(&module_list.lock))
-		unlock = 0;
-	AST_LIST_TRAVERSE(&module_list, cur, entry)
-	if (!res && !strcasecmp(name, cur->resource))
-		res = 1;
-	if (unlock)
-		AST_LIST_UNLOCK(&module_list);
-	return res;
+	cur = find_resource(name, 1);
+
+	return (cur != NULL);
 }
 
 
-- 
GitLab