[asterisk-commits] branch crichter/0.4.0 r37336 -
/team/crichter/0.4.0/channels/chan_misdn.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Jul 10 08:42:55 MST 2006
Author: crichter
Date: Mon Jul 10 10:42:54 2006
New Revision: 37336
URL: http://svn.digium.com/view/asterisk?rev=37336&view=rev
Log:
added a signal handler to allow waking up the misdn task thread (that may sleep in a poll call) via misdn_tasks_wakeup().
Modified:
team/crichter/0.4.0/channels/chan_misdn.c
Modified: team/crichter/0.4.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_misdn.c?rev=37336&r1=37335&r2=37336&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_misdn.c (original)
+++ team/crichter/0.4.0/channels/chan_misdn.c Mon Jul 10 10:42:54 2006
@@ -37,6 +37,7 @@
#include <arpa/inet.h>
#include <fcntl.h>
#include <sys/ioctl.h>
+#include <signal.h>
#include <sys/file.h>
#include <asterisk/channel.h>
@@ -430,14 +431,27 @@
}
/*************** Helpers END *************/
+static void sighandler(int sig) {
+ return;
+}
+
static void* misdn_tasks_thread_func (void *data)
{
int wait;
+
+ struct sigaction sa;
+ sa.sa_handler = sighandler;
+ sa.sa_flags = SA_NODEFER;
+ sigemptyset(&sa.sa_mask);
+ sigaddset(&sa.sa_mask, SIGUSR1);
+ sigaction(SIGUSR1, &sa, NULL);
+
while (1) {
wait = ast_sched_wait(misdn_tasks);
if (wait < 0)
- wait = 4000;
- poll(NULL, 0, wait);
+ wait = 8000;
+ if (poll(NULL, 0, wait) < 0)
+ chan_misdn_log(4, 0, "Waking up misdn_tasks thread\n");
ast_sched_runq(misdn_tasks);
}
return NULL;
@@ -462,12 +476,19 @@
}
}
+static void misdn_tasks_wakeup (void)
+{
+ pthread_kill(misdn_tasks_thread, SIGUSR1);
+}
+
static void misdn_tasks_add (int timeout, ast_sched_cb callback, void *data)
{
- if (!misdn_tasks)
+ if (!misdn_tasks) {
misdn_tasks_init();
+ poll(NULL, 0, 100);
+ }
ast_sched_add(misdn_tasks, timeout, callback, data);
- ast_sched_runq(misdn_tasks);
+ misdn_tasks_wakeup();
}
static int misdn_l1_task (void *data)
@@ -921,9 +942,7 @@
ast_cli(fd," %s Debug:%d%s\n", buf, misdn_debug[port], misdn_debug_only[port]?"(only)":"");
}
-
return 0;
-
}
@@ -3536,11 +3555,19 @@
struct chan_list *ch=find_chan_by_bc(cl_te, bc);
if (ch && ch->state != MISDN_NOTHING ) {
chan_misdn_log(1, bc->port, " --> Ignoring Call we have already one\n");
- return RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE; /* Ignore MSNs which are not in our List */
- }
- }
-
-
+ return RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE;
+ }
+ }
+
+
+ /* Overlap Dial */
+/* { */
+/* int overlap; */
+/* misdn_cfg_get(bc->port, MISDN_CFG_OVERLAP_DIAL, &overlap, sizeof(overlap)); */
+/* if (overlap) */
+/* chan_misdn_log(0, bc->port, "Overlap Dial activated. Waiting %d seconds of idle until continueing with EVENT_SETUP.\n", overlap); */
+/* } */
+
int msn_valid = misdn_cfg_is_msn_valid(bc->port, bc->dad);
if (!bc->nt && ! msn_valid) {
chan_misdn_log(1, bc->port, " --> Ignoring Call, its not in our MSN List\n");
More information about the asterisk-commits
mailing list