[zaptel-commits] sruffell: branch 1.4 r3885 - /branches/1.4/kernel/zaptel-base.c
SVN commits to the Zaptel project
zaptel-commits at lists.digium.com
Wed Feb 27 12:30:57 CST 2008
Author: sruffell
Date: Wed Feb 27 12:30:56 2008
New Revision: 3885
URL: http://svn.digium.com/view/zaptel?view=rev&rev=3885
Log:
Set the default tone zone to to the first loaded zone by default.
Should prevent the crash reported in issue 0012053.
Modified:
branches/1.4/kernel/zaptel-base.c
Modified: branches/1.4/kernel/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/zaptel-base.c?view=diff&rev=3885&r1=3884&r2=3885
==============================================================================
--- branches/1.4/kernel/zaptel-base.c (original)
+++ branches/1.4/kernel/zaptel-base.c Wed Feb 27 12:30:56 2008
@@ -2590,6 +2590,23 @@
}
+static int zt_set_default_zone(int defzone)
+{
+ if ((defzone < 0) || (defzone >= ZT_TONE_ZONE_MAX))
+ return -EINVAL;
+ write_lock(&zone_lock);
+ if (!tone_zones[defzone]) {
+ write_unlock(&zone_lock);
+ return -EINVAL;
+ }
+ if ((default_zone != -1) && tone_zones[default_zone])
+ atomic_dec(&tone_zones[default_zone]->refcount);
+ atomic_inc(&tone_zones[defzone]->refcount);
+ default_zone = defzone;
+ write_unlock(&zone_lock);
+ return 0;
+}
+
/* No bigger than 32k for everything per tone zone */
#define MAX_SIZE 32768
/* No more than 128 subtones */
@@ -2737,8 +2754,13 @@
samples[x]->next = samples[next[x]];
}
- if ((res = zt_register_tone_zone(th.zone, z)))
+ if ((res = zt_register_tone_zone(th.zone, z))) {
kfree(slab);
+ } else {
+ if ( -1 == default_zone ) {
+ zt_set_default_zone(th.zone);
+ }
+ }
return res;
}
@@ -3664,19 +3686,7 @@
case ZT_DEFAULTZONE:
if (get_user(j,(int *)data))
return -EFAULT;
- if ((j < 0) || (j >= ZT_TONE_ZONE_MAX))
- return -EINVAL;
- write_lock(&zone_lock);
- if (!tone_zones[j]) {
- write_unlock(&zone_lock);
- return -EINVAL;
- }
- if ((default_zone != -1) && tone_zones[default_zone])
- atomic_dec(&tone_zones[default_zone]->refcount);
- atomic_inc(&tone_zones[j]->refcount);
- default_zone = j;
- write_unlock(&zone_lock);
- break;
+ return zt_set_default_zone(j);
case ZT_LOADZONE:
return ioctl_load_zone(data);
case ZT_FREEZONE:
More information about the zaptel-commits
mailing list