[asterisk-commits] branch crichter/0.4.0 r29802 - in /team/crichter/0.4.0: ./ channels/ channels...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue May 23 12:36:34 MST 2006


Author: crichter
Date: Tue May 23 14:36:34 2006
New Revision: 29802

URL: http://svn.digium.com/view/asterisk?rev=29802&view=rev
Log:
added a l1watcher timeout, therefore removed the old behaviour of guessing the l1state. settet the svnmerge-integrated prop to the 0.3.0 branch

Modified:
    team/crichter/0.4.0/   (props changed)
    team/crichter/0.4.0/channels/chan_misdn.c
    team/crichter/0.4.0/channels/misdn/chan_misdn_config.h
    team/crichter/0.4.0/channels/misdn/isdn_lib.c
    team/crichter/0.4.0/channels/misdn/isdn_lib.h
    team/crichter/0.4.0/channels/misdn_config.c
    team/crichter/0.4.0/configs/misdn.conf.sample

Propchange: team/crichter/0.4.0/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue May 23 14:36:34 2006
@@ -1,1 +1,1 @@
-/branches/1.2:1-29054 /team/crichter/0.3.0:1-29160
+/team/crichter/0.3.0:1-29160

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=29802&r1=29801&r2=29802&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_misdn.c (original)
+++ team/crichter/0.4.0/channels/chan_misdn.c Tue May 23 14:36:34 2006
@@ -656,39 +656,6 @@
 		misdn_debug[i] = cfg_debug;
 		misdn_debug_only[i] = 0;
 	}
-
-#ifdef M_TIMER
-	if (misdn_sched) 
-		sched_context_destroy(misdn_sched);
-	
-	misdn_sched=sched_context_create();
-
-	if (!misdn_sched) {
-		ast_log(LOG_ERROR,"Couldn't create scheduler\n");
-		return -1;
-	}
-
-	/* Loop through all ports and find out which one should be 
-	 * watched regarding the l1 */
-	int port; 
-	int dotimer=0;
-	for (	port=misdn_cfg_get_next_port(0);
-		port>0;
-		port=misdn_cfg_get_next_port(port)) {
-		int l1timer;
-		misdn_cfg_get( port, MISDN_CFG_L1_TIMER, &l1timer, sizeof(l1timer));
-		if (l1timer>0) {
-			ast_sched_add(misdn_sched, l1timer*1000, l1_timer_cb, &port);
-			dotimer=1;
-;		}
-	}
-
-	if (dotimer) {
-		/*start timer thread*/
-		pthread_create( &misdn_timer, NULL, (void*)misdn_timerd, NULL);
-	}
-#endif
-
 }
 
 static int misdn_reload (int fd, int argc, char *argv[])
@@ -3799,21 +3766,6 @@
 
 /** TE STUFF END **/
 
-#ifdef M_TIMER
-/* timer thread */
-pthread_t misdn_timer;
-struct sched_context *misdn_sched;
-
-void misdn_timerd(void *arg)
-{
-
-	
-}
-
-
-/* timer thread end */
-#endif
-
 /******************************************
  *
  *   Asterisk Channel Endpoint END
@@ -3869,7 +3821,11 @@
 
 	misdn_cfg_update_ptp();
 	misdn_cfg_get_ports_string(ports);
-		
+
+
+	int l1watcher_timeout=0;
+	misdn_cfg_get( 0, MISDN_GEN_L1_TIMEOUT, &l1watcher_timeout, sizeof(int));
+	
 	if (strlen(ports))
 		chan_misdn_log(0, 0, "Got: %s from get_ports\n",ports);
 	
@@ -3878,7 +3834,9 @@
 			.cb_event = cb_events,
 			.cb_log = chan_misdn_log,
 			.cb_jb_empty = chan_misdn_jb_empty,
+			.l1watcher_timeout=l1watcher_timeout,
 		};
+		
 		if (misdn_lib_init(ports, &iface, NULL))
 			chan_misdn_log(0, 0, "No te ports initialized\n");
 	}

Modified: team/crichter/0.4.0/channels/misdn/chan_misdn_config.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/chan_misdn_config.h?rev=29802&r1=29801&r2=29802&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/chan_misdn_config.h (original)
+++ team/crichter/0.4.0/channels/misdn/chan_misdn_config.h Tue May 23 14:36:34 2006
@@ -57,7 +57,6 @@
 	MISDN_CFG_PICKUPGROUP,         /* ast_group_t */
 	MISDN_CFG_MAX_IN,              /* int */
 	MISDN_CFG_MAX_OUT,              /* int */
-	MISDN_CFG_L1_POLL,              /* int */
 	MISDN_CFG_MSNS,                /* char[] */
 	MISDN_CFG_PTP,                 /* int (bool) */
 	MISDN_CFG_LAST,
@@ -73,6 +72,7 @@
 	MISDN_GEN_DYNAMIC_CRYPT,       /* int (bool) */
 	MISDN_GEN_CRYPT_PREFIX,        /* char[] */
 	MISDN_GEN_CRYPT_KEYS,          /* char[] */
+	MISDN_GEN_L1_TIMEOUT,          /* int */
 	MISDN_GEN_LAST
 };
 

Modified: team/crichter/0.4.0/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib.c?rev=29802&r1=29801&r2=29802&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib.c (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib.c Tue May 23 14:36:34 2006
@@ -91,9 +91,12 @@
 	int midev;
 	int midev_nt;
 
+	pthread_t l1watcher_thread;
 	pthread_t event_thread;
 	pthread_t event_handler_thread;
-  
+
+	int l1watcher_timeout;
+	
 	void *user_data;
 
 	msg_queue_t upqueue;
@@ -143,6 +146,7 @@
 unsigned char tone_425_flip[TONE_425_SIZE];
 unsigned char tone_silence_flip[TONE_SILENCE_SIZE];
 
+static void misdn_lib_isdn_l1watcher(void *arg);
 static void misdn_lib_isdn_event_catcher(void *arg);
 static int handle_event_nt(void *dat, void *arg);
 
@@ -2504,19 +2508,13 @@
 
 		case SSTATUS_L1_DEACTIVATED:
 			cb_log(1, stack->port, "MGMT: SSTATUS: L1_DEACTIVATED \n");
-			/*reopen L1 if down*/
-			if (stack->l1link==2)
-				stack->l1link--;
-			else			
-				stack->l1link=0;
+			stack->l1link=0;
 			
 			break;
 
 		case SSTATUS_L2_ESTABLISHED:
 			cb_log(1, stack->port, "MGMT: SSTATUS: L2_ESTABLISH \n");
 			stack->l2link=1;
-			if ( !stack->ptp && !stack->nt )
-				stack->l1link=2;
 			break;
 			
 		case SSTATUS_L2_RELEASED:
@@ -2598,6 +2596,33 @@
 	return NULL;
 }
 
+static void misdn_lib_isdn_l1watcher(void *arg)
+{
+	struct misdn_lib *mgr = arg;
+	struct misdn_stack *stack;
+
+	while (1) {
+		sleep(mgr->l1watcher_timeout);
+		
+		/* look out for l1 which are down
+		   and try to pull the up.
+
+		   We might even try to pull the l2 up in the
+		   ptp case.
+		*/
+		for (stack = mgr->stack_list;
+		     stack;
+		     stack = stack->next) {
+			cb_log(4,stack->port,"Checking L1 State\n");	
+			if (!stack->l1link) {
+				cb_log(4,stack->port,"L1 State Down, trying to get it up again\n");	
+				misdn_lib_get_short_status(stack);
+				misdn_lib_get_l1_up(stack); 
+				misdn_lib_get_l2_up(stack); 
+			}
+		}
+	}
+}
 
 static void misdn_lib_isdn_event_catcher(void *arg)
 {
@@ -3392,7 +3417,13 @@
 	pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr);
   
 	cb_log(4, 0, "Event Catcher started\n");
-  
+
+	if (iface->l1watcher_timeout > 0) {
+		mgr->l1watcher_timeout=iface->l1watcher_timeout;
+		cb_log(4, 0, "Starting L1 watcher\n");
+		pthread_create( &mgr->l1watcher_thread, NULL, (void*)misdn_lib_isdn_l1watcher, mgr);
+	}
+	
 	global_state= MISDN_INITIALIZED; 
   
 	return (mgr == NULL);

Modified: team/crichter/0.4.0/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib.h?rev=29802&r1=29801&r2=29802&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib.h (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib.h Tue May 23 14:36:34 2006
@@ -321,6 +321,8 @@
 	enum event_response_e (*cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data);
 	void (*cb_log)(int level, int port, char *tmpl, ...);
 	int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
+	
+	int l1watcher_timeout;
 };
 
 /***** USER IFACE **********/

Modified: team/crichter/0.4.0/channels/misdn_config.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn_config.c?rev=29802&r1=29801&r2=29802&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn_config.c (original)
+++ team/crichter/0.4.0/channels/misdn_config.c Tue May 23 14:36:34 2006
@@ -118,7 +118,6 @@
 	{ "pickupgroup", MISDN_CFG_PICKUPGROUP, MISDN_CTYPE_ASTGROUP, NO_DEFAULT, NONE },
 	{ "max_incoming", MISDN_CFG_MAX_IN, MISDN_CTYPE_INT, "-1", NONE },
 	{ "max_outgoing", MISDN_CFG_MAX_OUT, MISDN_CTYPE_INT, "-1", NONE },
-	{ "l1_poll_timer", MISDN_CFG_L1_POLL, MISDN_CTYPE_INT, "-1", NONE },
 	{ "msns", MISDN_CFG_MSNS, MISDN_CTYPE_MSNLIST, NO_DEFAULT, NONE }
 };
 
@@ -131,7 +130,9 @@
 	{ "append_digits2exten", MISDN_GEN_APPEND_DIGITS2EXTEN, MISDN_CTYPE_BOOL, "yes", NONE },
 	{ "dynamic_crypt", MISDN_GEN_DYNAMIC_CRYPT, MISDN_CTYPE_BOOL, "no", NONE },
 	{ "crypt_prefix", MISDN_GEN_CRYPT_PREFIX, MISDN_CTYPE_STR, NO_DEFAULT, NONE },
-	{ "crypt_keys", MISDN_GEN_CRYPT_KEYS, MISDN_CTYPE_STR, NO_DEFAULT, NONE }
+	{ "crypt_keys", MISDN_GEN_CRYPT_KEYS, MISDN_CTYPE_STR, NO_DEFAULT, NONE },
+	{ "l1watcher_timeout", MISDN_GEN_L1_TIMEOUT, MISDN_CTYPE_INT, "0", NONE }
+	
 };
 
 /* array of port configs, default is at position 0. */

Modified: team/crichter/0.4.0/configs/misdn.conf.sample
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/configs/misdn.conf.sample?rev=29802&r1=29801&r2=29802&view=diff
==============================================================================
--- team/crichter/0.4.0/configs/misdn.conf.sample (original)
+++ team/crichter/0.4.0/configs/misdn.conf.sample Tue May 23 14:36:34 2006
@@ -36,6 +36,20 @@
 ; default value: yes
 ;
 bridging=no
+
+
+;
+; watches the L1s of every port. If one l1 is down it tries to 
+; get it up. The timeout is given in seconds. with 0 as value it
+; does not watch the l1 at all
+; 
+; default value: 0
+;
+; this option is only read at loading time of chan_misdn, 
+; which means you need to unload and load chan_misdn to change the 
+; value, an asterisk restart should do the trick
+; 
+l1watcher_timeout=0
 
 ; stops dialtone after getting first digit on nt Port
 ;



More information about the asterisk-commits mailing list