aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_iax2.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-04 14:23:18 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-04 14:23:18 +0000
commit6ea84616b767f99dd45f53807f19646ac54a1c69 (patch)
treebab7e563f6a48698c745328504c1bb70409799a0 /channels/chan_iax2.c
parent11223e1ff5c60a24489013da97ec2a5c7b5e372f (diff)
(closes issue #10632)
Reported by: jamesgolovich Patches: asterisk-iaxfirmwareleak.diff.txt uploaded by jamesgolovich (license 176) Fix memory leak when unloading chan_iax2. The firmware files were not being freed. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@81439 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r--channels/chan_iax2.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index d968219b6..af38cea8f 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1731,7 +1731,7 @@ static int iax_firmware_append(struct iax_ie_data *ied, const unsigned char *dev
}
-static void reload_firmware(void)
+static void reload_firmware(int unload)
{
struct iax_firmware *cur, *curl, *curp;
DIR *fwd;
@@ -1745,22 +1745,25 @@ static void reload_firmware(void)
cur->dead = 1;
cur = cur->next;
}
+
/* Now that we've freed them, load the new ones */
- snprintf(dir, sizeof(dir), "%s/firmware/iax", (char *)ast_config_AST_DATA_DIR);
- fwd = opendir(dir);
- if (fwd) {
- while((de = readdir(fwd))) {
- if (de->d_name[0] != '.') {
- snprintf(fn, sizeof(fn), "%s/%s", dir, de->d_name);
- if (!try_firmware(fn)) {
- if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Loaded firmware '%s'\n", de->d_name);
+ if (!unload) {
+ snprintf(dir, sizeof(dir), "%s/firmware/iax", (char *)ast_config_AST_DATA_DIR);
+ fwd = opendir(dir);
+ if (fwd) {
+ while((de = readdir(fwd))) {
+ if (de->d_name[0] != '.') {
+ snprintf(fn, sizeof(fn), "%s/%s", dir, de->d_name);
+ if (!try_firmware(fn)) {
+ if (option_verbose > 1)
+ ast_verbose(VERBOSE_PREFIX_2 "Loaded firmware '%s'\n", de->d_name);
+ }
}
}
- }
- closedir(fwd);
- } else
- ast_log(LOG_WARNING, "Error opening firmware directory '%s': %s\n", dir, strerror(errno));
+ closedir(fwd);
+ } else
+ ast_log(LOG_WARNING, "Error opening firmware directory '%s': %s\n", dir, strerror(errno));
+ }
/* Clean up leftovers */
cur = waresl.wares;
@@ -9834,7 +9837,7 @@ static int reload_config(void)
AST_LIST_UNLOCK(&registrations);
/* Qualify hosts, too */
ao2_callback(peers, 0, iax2_poke_peer_cb, NULL);
- reload_firmware();
+ reload_firmware(0);
iax_provision_reload();
return 0;
@@ -10616,6 +10619,7 @@ static int __unload_module(void)
delete_users();
iax_provision_unload();
sched_context_destroy(sched);
+ reload_firmware(1);
ast_mutex_destroy(&waresl.lock);
@@ -10747,7 +10751,7 @@ static int load_module(void)
ao2_callback(peers, 0, peer_set_sock_cb, NULL);
ao2_callback(peers, 0, iax2_poke_peer_cb, NULL);
- reload_firmware();
+ reload_firmware(0);
iax_provision_reload();
return res;
}