[svn-commits] file: branch 1.4 r81439 - /branches/1.4/channels/chan_iax2.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Sep 4 09:23:18 CDT 2007
Author: file
Date: Tue Sep 4 09:23:18 2007
New Revision: 81439
URL: http://svn.digium.com/view/asterisk?view=rev&rev=81439
Log:
(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.
Modified:
branches/1.4/channels/chan_iax2.c
Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=81439&r1=81438&r2=81439
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Tue Sep 4 09:23:18 2007
@@ -1731,7 +1731,7 @@
}
-static void reload_firmware(void)
+static void reload_firmware(int unload)
{
struct iax_firmware *cur, *curl, *curp;
DIR *fwd;
@@ -1745,22 +1745,25 @@
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 @@
AST_LIST_UNLOCK(®istrations);
/* 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 @@
delete_users();
iax_provision_unload();
sched_context_destroy(sched);
+ reload_firmware(1);
ast_mutex_destroy(&waresl.lock);
@@ -10747,7 +10751,7 @@
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;
}
More information about the svn-commits
mailing list