dahdi_cfg's -S (apply only to a specific span) uses the array chan2span
to map channel numbers to span numbers.
The problem is that it assumes that channels first appear in system.conf
immediately after the span line of a specific span. Thus the following
configuration breaks it:
span=1,...
span=2,...
clear=1-2,4-5
dchan=3,6
The best fix for that is to require -C to be used when -S is used (which
is already the case in our udev hooks).
Fixes DAHTOOL-69.
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Logic was calling DAHDI_SPECIFY ioctl on all channels up to maximum channel
limit. Added a short circuit to prevent the ioctl on channels that aren't
configured.
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
Hopefully will save a little time in the future if anyone ever types into
/etc/dahdi/system.conf:
bchan=1-15,17-30:1101
when they meant:
cas=1-15,17-30:1101
in the future.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
If dahdi_cfg is terminated while holding the named semaphore, it is possible to
leave it behind and all subsequenct invocations of dahdi_cfg will block waiting
for it.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
This fixes a confusing error message. When sem_open failed, the system.conf line
number was being printed and the system error code was not.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Prior to this commit, if auto_assign_spans was set to 0, it was possible to
get in an endless loop creating and destroying spans. The primary reason was
that all dynamic spans are destroyed and recreated each time dahdi_cfg runs, BUT
dahdi_cfg was run each time a new span showed up in udev when auto_assign_spans
was set to 0.
Now dahdi_cfg will only destroy and recreate dynamic spans if dahdi_cfg is run
without a specifc span number. Also, while creating dynamic spans, dahdi_cfg
will pause for up to one second for the span to be assigned in order to ensure
that the spans are numbered consistently when auto span assignment is
configured.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
When dahdi is configured for fully dynamic configuration on a device and
span basis via sysfs and udev it is possible for multiple instances of
dahdi_cfg to be run in parallel on different spans. If this happens it
is possible to see errors on the console that tone zones are already
registered since the check for the existence of a tone zone and the
re-registering needs to be atomic.
dahdi_cfg will now prevent itself from running in parallel.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
When auto span assignment is disabled, it's possible that simply running
# /etc/init.d/dahdi restart
Will fail since dahdi_cfg can run in parallel with udev scripts that are
assigning spans, which results in /etc/dahdi/system.conf describing spans that
do not exist in the system.
This change sets up dahdi_cfg, when run without the -C or -S options, to look in
sysfs and make sure all spans for each device are assigned. dahdi_cfg will wait
5 seconds for span assignment to happen before proceeding normally.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
If the config file has two spans defined:
span=1,1,0,esf,b8zs
bchan=1-23
dchan=24
echocanceller=mg2,1-23
span=2,2,0,esf,b8zs
bchan=25-47
dchan=48
And you only want to configure span-2, you would need to pass -S 1 to
dahdi_cfg. Now make the -S option take the span number as assigned in the
config file.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
* dahdi_cfg -S <num>: only apply changes to span <num>.
* If span is analog (no 'span=<num>,<channels>,...' statement in
system.conf), we need to set range: -C <channels>
* With the <basechan> and <channels> attributes in sysfs
we easily configure each device on the fly.
Simply run: dahdi_cfg -S <spanno> -C <basechan>+<channels>-1
from udev script
Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
git-svn-id: http://svn.astersk.org/svn/dahdi/tools/trunk@10306 17933a7a-c749-41c5-a318-cba88f637d49
While slightly less efficient, this is only used when configuring the
channels initially (not the hot path) and allows dahdi-base.c to assume
that the open "file" pointer always refers to the channel on which to
perform the operation.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
git-svn-id: http://svn.astersk.org/svn/dahdi/tools/trunk@9352 17933a7a-c749-41c5-a318-cba88f637d49