mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-18 15:49:56 +00:00
loader: Create ast_module_running_ref.
This function returns NULL if the module in question is not running. I did not change ast_module_ref as most callers do not check the result and they always call ast_module_unref. Make use of this function when running registered items from: * app_stack API's * bridge technologies * CLI commands * File formats * Manager Actions * RTP engines * Sorcery Wizards * Timing Interfaces * Translators * AGI Commands * Fax Technologies ASTERISK-20346 #close Change-Id: Ia16fd28e188b2fc0b9d18b8a5d9cacc31df73fcc
This commit is contained in:
12
main/file.c
12
main/file.c
@@ -425,11 +425,17 @@ static void filestream_destructor(void *arg)
|
||||
static struct ast_filestream *get_filestream(struct ast_format_def *fmt, FILE *bfile)
|
||||
{
|
||||
struct ast_filestream *s;
|
||||
|
||||
int l = sizeof(*s) + fmt->buf_size + fmt->desc_size; /* total allocation size */
|
||||
if ( (s = ao2_alloc(l, filestream_destructor)) == NULL)
|
||||
|
||||
if (!ast_module_running_ref(fmt->module)) {
|
||||
return NULL;
|
||||
ast_module_ref(fmt->module);
|
||||
}
|
||||
|
||||
s = ao2_alloc(l, filestream_destructor);
|
||||
if (!s) {
|
||||
ast_module_unref(fmt->module);
|
||||
return NULL;
|
||||
}
|
||||
s->fmt = fmt;
|
||||
s->f = bfile;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user