[asterisk-dev] Re: [asterisk-commits] oej: trunk r46513 - in /trunk: funcs/ include/asterisk/ main/

Kevin P. Fleming kpfleming at digium.com
Mon Oct 30 15:23:09 MST 2006


asterisk-commits at lists.digium.com wrote:
> Modified: trunk/main/loader.c
> URL: http://svn.digium.com/view/asterisk/trunk/main/loader.c?rev=46513&r1=46512&r2=46513&view=diff
> ==============================================================================
> --- trunk/main/loader.c (original)
> +++ trunk/main/loader.c Mon Oct 30 15:48:41 2006
> @@ -871,6 +871,26 @@
>  	return total_mod_loaded;
>  }
>  
> +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;
> +}
> +
> +

This is broken; it should call find_resource, which already does process
properly including more complex name matching rules.

Also, if the lock on the module list cannot be obtained, the function
should return a null result, rather than trying to scan the linked list
anyway (this could easily generate a segfault).


More information about the asterisk-dev mailing list