summaryrefslogtreecommitdiff
path: root/channels/chan_zap.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2007-03-08 01:06:00 +0000
committerRussell Bryant <russell@russellbryant.com>2007-03-08 01:06:00 +0000
commit9266a6b8d8f04d45133ee1303b704272f2bf43f6 (patch)
tree317989200e26cc92f0489bd12aeb77a658a9a0da /channels/chan_zap.c
parent32e03f9e4a21be12d2703dad8101948fe3510e08 (diff)
Merged revisions 58320 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r58320 | russell | 2007-03-07 19:01:46 -0600 (Wed, 07 Mar 2007) | 6 lines If we receive ZT_EVENT_REMOVED, destroy the specified channel. (issue #7256, tzafrir) Also, update the configure script to make sure that we don't try to build chan_zap if the installed version of zaptel does not include ZT_EVENT_REMOVED. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@58321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_zap.c')
-rw-r--r--channels/chan_zap.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 06bb13ad7..0715626b0 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -6866,6 +6866,24 @@ static void *ss_thread(void *data)
return NULL;
}
+/* destroy a zaptel channel, identified by its number */
+static int zap_destroy_channel_bynum(int channel)
+{
+ struct zt_pvt *tmp = NULL;
+ struct zt_pvt *prev = NULL;
+
+ tmp = iflist;
+ while (tmp) {
+ if (tmp->channel == channel) {
+ destroy_channel(prev, tmp, 1);
+ return RESULT_SUCCESS;
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
+ return RESULT_FAILURE;
+}
+
static int handle_init_event(struct zt_pvt *i, int event)
{
int res;
@@ -7056,6 +7074,12 @@ static int handle_init_event(struct zt_pvt *i, int event)
"polarity reversal on non-FXO (SIG_FXS) "
"interface %d\n", i->channel);
}
+ case ZT_EVENT_REMOVED: /* destroy channel */
+ ast_log(LOG_NOTICE,
+ "Got ZT_EVENT_REMOVED. Destroying channel %d\n",
+ i->channel);
+ zap_destroy_channel_bynum(i->channel);
+ break;
}
pthread_attr_destroy(&attr);
return 0;
@@ -10627,25 +10651,14 @@ static struct ast_cli_entry zap_pri_cli[] = {
static int zap_destroy_channel(int fd, int argc, char **argv)
{
- int channel = 0;
- struct zt_pvt *tmp = NULL;
- struct zt_pvt *prev = NULL;
+ int channel;
- if (argc != 4) {
+ if (argc != 4)
return RESULT_SHOWUSAGE;
- }
+
channel = atoi(argv[3]);
- tmp = iflist;
- while (tmp) {
- if (tmp->channel == channel) {
- destroy_channel(prev, tmp, 1);
- return RESULT_SUCCESS;
- }
- prev = tmp;
- tmp = tmp->next;
- }
- return RESULT_FAILURE;
+ return zap_destroy_channel_bynum(channel);
}
static int setup_zap(int reload);