summaryrefslogtreecommitdiff
path: root/zaptel.c
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2004-06-16 03:52:49 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2004-06-16 03:52:49 +0000
commit644fbb9766ba8d9e76e710e639bc137e9e2323ac (patch)
treeef02b1b8ecaf2caf9da8634f1ffe77b8354e474f /zaptel.c
parenta72868fc9d542b50de04017cd9bd34dd89ace6e8 (diff)
Hold the big zap lock when allocating and freeing the pseudo channels
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@411 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'zaptel.c')
-rwxr-xr-xzaptel.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/zaptel.c b/zaptel.c
index 1d05fcb..fd15352 100755
--- a/zaptel.c
+++ b/zaptel.c
@@ -2137,6 +2137,7 @@ static int zt_specchan_release(struct inode *node, struct file *file, int unit)
static struct zt_chan *zt_alloc_pseudo(void)
{
struct zt_chan *pseudo;
+ unsigned long flags;
/* Don't allow /dev/zap/pseudo to open if there are no spans */
if (maxspans < 1)
return NULL;
@@ -2147,18 +2148,23 @@ static struct zt_chan *zt_alloc_pseudo(void)
pseudo->sig = ZT_SIG_CLEAR;
pseudo->sigcap = ZT_SIG_CLEAR;
pseudo->flags = ZT_FLAG_PSEUDO | ZT_FLAG_AUDIO;
+ spin_lock_irqsave(&bigzaplock, flags);
if (zt_chan_reg(pseudo)) {
kfree(pseudo);
- return NULL;
- }
- sprintf(pseudo->name, "Pseudo/%d", pseudo->channo);
+ pseudo = NULL;
+ } else
+ sprintf(pseudo->name, "Pseudo/%d", pseudo->channo);
+ spin_unlock_irqrestore(&bigzaplock, flags);
return pseudo;
}
static void zt_free_pseudo(struct zt_chan *pseudo)
{
+ unsigned long flags;
if (pseudo) {
+ spin_lock_irqsave(&bigzaplock, flags);
zt_chan_unreg(pseudo);
+ spin_unlock_irqrestore(&bigzaplock, flags);
kfree(pseudo);
}
}