diff options
author | mattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-11-17 00:51:10 +0000 |
---|---|---|
committer | mattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-11-17 00:51:10 +0000 |
commit | 2494c875a8d4e3b2a5440b76c60095b0470fc614 (patch) | |
tree | 33d52e90e52ccbf9bdd947a65e432f38ab9a6360 /zaptel.c | |
parent | ee4cf21e67af1575a3df01760c058ba809160775 (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.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -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; } |