summaryrefslogtreecommitdiff
path: root/zaptel.c
diff options
context:
space:
mode:
authormattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-11-17 00:51:10 +0000
committermattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-11-17 00:51:10 +0000
commit2494c875a8d4e3b2a5440b76c60095b0470fc614 (patch)
tree33d52e90e52ccbf9bdd947a65e432f38ab9a6360 /zaptel.c
parentee4cf21e67af1575a3df01760c058ba809160775 (diff)
Make the master span change more atomic, in face of not doing actual locking like we need to do.
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1607 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'zaptel.c')
-rw-r--r--zaptel.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/zaptel.c b/zaptel.c
index 3d0ae85..97aecce 100644
--- a/zaptel.c
+++ b/zaptel.c
@@ -4731,16 +4731,23 @@ int zt_unregister(struct zt_span *span)
span->flags &= ~ZT_FLAG_REGISTERED;
for (x=0;x<span->channels;x++)
zt_chan_unreg(&span->chans[x]);
- maxspans = 0;
+ new_maxspans = 0;
+ new_master = master; /* FIXME: locking */
if (master == span)
- master = NULL;
+ new_master = NULL;
for (x=1;x<ZT_MAX_SPANS;x++) {
if (spans[x]) {
- maxspans = x+1;
- if (!master)
- master = spans[x];
+ new_maxspans = x+1;
+ if (!new_master)
+ new_master = spans[x];
}
}
+ maxspans = new_maxspans;
+ if (master != new_master)
+ if (debug)
+ printk("%s: Span ('%s') is new master\n", __FUNCTION__,
+ (new_master)? new_master->name: "no master");
+ master = new_master;
return 0;
}