[asterisk-commits] jpeeler: branch jpeeler/dahdi-restart r132241 - in /team/jpeeler/dahdi-restar...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 18 16:56:22 CDT 2008


Author: jpeeler
Date: Fri Jul 18 16:56:22 2008
New Revision: 132241

URL: http://svn.digium.com/view/asterisk?view=rev&rev=132241
Log:
This fixes the undesired behavior when restarting an analog channel in congestion. Also, important bug fix of closing all the open file descriptors used with d-channels allowing the module to be unloaded and then loaded.


Modified:
    team/jpeeler/dahdi-restart/channels/chan_dahdi.c
    team/jpeeler/dahdi-restart/main/callerid.c

Modified: team/jpeeler/dahdi-restart/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/dahdi-restart/channels/chan_dahdi.c?view=diff&rev=132241&r1=132240&r2=132241
==============================================================================
--- team/jpeeler/dahdi-restart/channels/chan_dahdi.c (original)
+++ team/jpeeler/dahdi-restart/channels/chan_dahdi.c Fri Jul 18 16:56:22 2008
@@ -719,6 +719,7 @@
 	int muting;
 } *iflist = NULL, *ifend = NULL;
 
+
 /*! \brief Channel configuration from chan_dahdi.conf .
  * This struct is used for parsing the [channels] section of chan_dahdi.conf.
  * Generally there is a field here for every possible configuration item.
@@ -1118,6 +1119,7 @@
 			x = errno;
 			close(fd);
 			errno = x;
+			ast_log(LOG_WARNING, "Failed to specify channel %d: %s\n", chan, strerror(errno));
 			return -1;
 		}
 	}
@@ -1853,8 +1855,8 @@
 	if (res < 0) {
 		if (errno == EINPROGRESS)
 			return 0;
-		ast_log(LOG_WARNING, "DAHDI hook failed returned %d (trying %d): %s with restart_pending=%d\n", res, hs, strerror(errno), restart_pending);
-/* jpeeler: perhaps it's fair for set_hook to fail when off hook */
+		ast_log(LOG_WARNING, "DAHDI hook failed returned %d (trying %d): %s\n", res, hs, strerror(errno));
+		/* will expectedly fail if phone is off hook during operation, such as during a restart */
 	}
 
 	return res;
@@ -2787,7 +2789,7 @@
 	ast_mutex_destroy(&p->lock);
 	if (p->owner)
 		p->owner->tech_pvt = NULL;
-	memset(p, 0, sizeof(*p));
+	//memset(p, 0, sizeof(*p));
 	ast_free(p);
 	*pvt = NULL;
 }
@@ -5539,6 +5541,10 @@
 	struct dahdi_pvt *p = ast->tech_pvt;
 	int res;
 	int index;
+
+	if (restart_pending == 1)
+		return -1;
+
 	index = dahdi_get_index(ast, p, 0);
 	if (index < 0) {
 		ast_log(LOG_WARNING, "%s doesn't really exist?\n", ast->name);
@@ -7492,19 +7498,8 @@
 	if (!mtd->pvt->cidspill) {
 		mtd->pvt->mwisendactive = 0;
 		ast_free(mtd);
-		printf("Something messed up\n"); /* jpeeler: cidspill debug */
 		return NULL;
 	}
-
-	/* jpeeler: debugging problem for cidspill spill pointer changing via another thread */
-	if (mtd->pvt->cidspill == NULL) {
-		printf("Something messed up2\n");
-	} else {
-		printf("address of cidspill %p address of pvt:%p\n", mtd->pvt->cidspill, mtd->pvt);
-	}
-
-
-	
 	x = DAHDI_FLUSH_BOTH;
 	res = ioctl(mtd->pvt->subs[SUB_REAL].zfd, DAHDI_FLUSH, &x);
 	x = 3000;
@@ -7639,8 +7634,8 @@
 	tmp = iflist;
 	while (tmp) {
 		if (tmp->channel == channel) {
-			int x = DAHDI_ONHOOK;
-			ioctl(iflist->subs[SUB_REAL].zfd, DAHDI_HOOK, &x); /* important to create an event for dahdi_wait_event to register so that all ss_threads terminate */
+			int x = DAHDI_FLASH;
+			ioctl(tmp->subs[SUB_REAL].zfd, DAHDI_HOOK, &x); /* important to create an event for dahdi_wait_event to register so that all ss_threads terminate */
 			destroy_channel(prev, tmp, 1);
 			return RESULT_SUCCESS;
 		}
@@ -7678,7 +7673,6 @@
 			if (i->cidspill) {
 				/* Cancel VMWI spill */
 				ast_free(i->cidspill);
-				printf("about to possibly make your life suck\n"); /* jpeeler: remove later, see main/callerid.c  */
 				i->cidspill = NULL;
 			}
 			if (i->immediate) {
@@ -8313,7 +8307,8 @@
 
 	if (!here && reloading != 1) {
 		if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
-			destroy_dahdi_pvt(&tmp); /* jpeeler: alloc fails, nothing to destroy? */
+			if (tmp)
+				ast_free(tmp);
 			return NULL;
 		}
 		ast_mutex_init(&tmp->lock);
@@ -11981,7 +11976,6 @@
 static int setup_dahdi(int reload);
 static int dahdi_restart(void)
 {
-	void *status;
 	ast_verb(1, "Destroying channels and reloading DAHDI configuration.\n");
 
     ast_mutex_lock(&monlock);
@@ -11989,7 +11983,7 @@
 		int retval;
         retval = pthread_cancel(monitor_thread);
         retval = pthread_kill(monitor_thread, SIGURG);
-        retval = pthread_join(monitor_thread, &status);
+        retval = pthread_join(monitor_thread, NULL);
     }
 	monitor_thread = AST_PTHREADT_NULL; /* restart thread */
 
@@ -12001,20 +11995,19 @@
 	ast_mutex_unlock(&mwi_thread_lock);
 	restart_pending = 1;
 	while (iflist) {
-		int x = DAHDI_ONHOOK;
+		int x = DAHDI_FLASH;
 		ioctl(iflist->subs[SUB_REAL].zfd, DAHDI_HOOK, &x); /* important to create an event for dahdi_wait_event to register so that all ss_threads terminate */		
 		ast_debug(1, "Destroying DAHDI channel no. %d\n", iflist->channel);
 		/* Also updates iflist: */
 		destroy_channel(NULL, iflist, 1);
 	}
 	ast_debug(1, "Channels destroyed. Now re-reading config.\n");
-	//sleep(1); /* jpeeler: either this works or waiting for hangup works */
 
     ast_mutex_unlock(&monlock);
 
 	ast_mutex_lock(&ss_thread_lock);
 	while (ss_thread_count > 0) {
-		ast_log(LOG_WARNING, "Waiting on ss_thread to finish\n");
+		ast_debug(2, "Waiting on ss_thread to finish\n");
 		ast_cond_wait(&ss_thread_complete, &ss_thread_lock);
 	}
 	if (setup_dahdi(2) != 0) {
@@ -13155,10 +13148,9 @@
 
 static int __unload_module(void)
 {
-	int x;
 	struct dahdi_pvt *p, *pl;
 #if defined(HAVE_PRI) || defined(HAVE_SS7)
-	int i;
+	int i, j, x;
 #endif
 
 #if defined(HAVE_PRI)
@@ -13223,7 +13215,9 @@
 	for (i = 0; i < NUM_SPANS; i++) {
 		if (pris[i].master && (pris[i].master != AST_PTHREADT_NULL))
 			pthread_join(pris[i].master, NULL);
-		dahdi_close(pris[i].fds[i]);
+		for (j = 0; j < NUM_DCHANS; j++) {
+			dahdi_close(pris[i].fds[j]);
+		}
 	}
 #endif /* HAVE_PRI */
 

Modified: team/jpeeler/dahdi-restart/main/callerid.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/dahdi-restart/main/callerid.c?view=diff&rev=132241&r1=132240&r2=132241
==============================================================================
--- team/jpeeler/dahdi-restart/main/callerid.c (original)
+++ team/jpeeler/dahdi-restart/main/callerid.c Fri Jul 18 16:56:22 2008
@@ -782,7 +782,6 @@
 	float scont = 0.0;
 
 	if (!buf) {
-		ast_log(LOG_WARNING, "You just got saved from your life possibly sucking\n"); /* jpeeler: just FYI */
 		return 0; /* if another thread canceled the VMWI request */ 
 	}
 	




More information about the asterisk-commits mailing list