[asterisk-r2] handle a removed DAHDI device

Moises Silva moises.silva at gmail.com
Thu Jun 15 12:52:18 CDT 2017


On Thu, Jun 15, 2017 at 1:10 PM, Tzafrir Cohen <tzafrir.cohen at xorcom.com>
wrote:

> diff --git a/src/r2chan.c b/src/r2chan.c
> index a0ffc7c..fecf9d1 100755
> --- a/src/r2chan.c
> +++ b/src/r2chan.c
> @@ -281,6 +281,10 @@ static int openr2_chan_handle_zap_event(openr2_chan_t
> *r2chan
>                 r2chan->inalarm = (event == OR2_HW_EVENT_ALARM) ? 1 : 0;
>                 EMI(r2chan)->on_hardware_alarm(r2chan, r2chan->inalarm);
>                 break;
> +       case OR2_HW_EVENT_REMOVED:
> +               openr2_log(r2chan, OR2_LOG_DEBUG, "Channel removed\n");
> +               /* FIXME: remove span */
> +               break;
>         default:
>                 openr2_log(r2chan, OR2_LOG_DEBUG, "Unhandled hardware
> event %d\n",
>                 break;
>
> But I suspect it should the fix should be done in Asterisk. Any hint on
> how to proceed?
>

I'd probably modify the event interface so you do there
EMI(r2chan)->on_device_removed(); which then can be handled in Asterisk by
stop polling that channel (setting a "suspended" flag or whatever). If a
call was in progress on the device I suppose it should be hung up and the
read/write routines should check for the 'suspended'. I guess openr2
internally could also track the state of the channel (removed/suspended)
and return an error if the application tries to perform I/O on such channel.

Note the patch you wrote seems to be for master, which is good, but is not
the branch where openr2 releases for Asterisk are made from. I never fully
qualified master for Asterisk. I think it's supposed to work, but I'm not
sure. The master branch aimed to become openr2 version 2 that would support
both Asterisk and FreeSWITCH. It was tested well with FreeSWITCH but since
release 1 had been working well for Asterisk, I never found the motivation
to release it.

If you open a PR on github and/or an issue we can discuss and merge your
changes. If you don't like or want to use github I can make my private
openr2 gitlab repo public as well.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-r2/attachments/20170615/589ea06b/attachment.html>


More information about the asterisk-r2 mailing list