[asterisk-commits] mattf: branch mattf/bug13495 r235653 - /team/mattf/bug13495/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 18 16:39:41 CST 2009


Author: mattf
Date: Fri Dec 18 16:39:39 2009
New Revision: 235653

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=235653
Log:
Add some fixes for reestablishing client and server connections

Modified:
    team/mattf/bug13495/channels/chan_dahdi.c

Modified: team/mattf/bug13495/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/mattf/bug13495/channels/chan_dahdi.c?view=diff&rev=235653&r1=235652&r2=235653
==============================================================================
--- team/mattf/bug13495/channels/chan_dahdi.c (original)
+++ team/mattf/bug13495/channels/chan_dahdi.c Fri Dec 18 16:39:39 2009
@@ -1024,21 +1024,33 @@
 	int slave_sock;
 	int i;
 	unsigned int len;
+	int reuse = 1;
+
 
 	if ((slave_chan_server.fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
 		ast_log(LOG_ERROR, "Unable to open socket for SS7 slave server\n");
 		return NULL;
 	}
+
+#if 0
+	setsockopt(slave_chan_server.fd, SOL_SOCKET, SO_REUSEADDR,
+		   (const char*)&reuse,
+		   sizeof reuse);
+#endif
 
 	memset(&my_addr, 0, sizeof(my_addr));
 	my_addr.sin_family = AF_INET;
 	my_addr.sin_port = htons(SS7_SLAVE_SERVER_PORT);
 	my_addr.sin_addr.s_addr = htons(INADDR_ANY);
 
+rebind:
+
 	if (bind(slave_chan_server.fd, (struct sockaddr *) &my_addr, sizeof(my_addr))) {
-		ast_log(LOG_ERROR, "Unable to bind to port %d in SS7 slave server\n", 7777);
-		close(slave_chan_server.fd);
-		return NULL;
+		ast_log(LOG_ERROR, "Unable to bind to port %d in SS7 slave server retrying in 5 seconds\n", 7777);
+		sleep(5);
+		goto rebind;
+		//close(slave_chan_server.fd);
+		//return NULL;
 	}
 
 	if (listen(slave_chan_server.fd, SS7_MAX_SLAVES) == -1) {
@@ -1059,6 +1071,7 @@
 			if (!strcasecmp(ast_inet_ntoa(slave_addr.sin_addr), slave_chan_server.slave_channel[i].addr)) {
 				int flags;
 				struct dahdi_ss7 *ss7 = ss7_resolve_linkset(slave_chan_server.slave_channel[i].linksetnum);
+				int j;
 
 				ast_log(LOG_NOTICE, "Accepting SS7 slave connection from host %s fd %d\n", ast_inet_ntoa(slave_addr.sin_addr), slave_sock);
 
@@ -1075,14 +1088,14 @@
 
 				ast_mutex_lock(&ss7->lock);
 
-				for (i = 0; i < ss7->numsigchans; i++) {
-					if (!strcasecmp(ss7->sigchans[i], "slave") && (ss7->fds[i] == -1)) {
+				for (j = 0; j < ss7->numsigchans; j++) {
+					if (!strcasecmp(ss7->sigchans[j], "slave") && (ss7->fds[j] == -1)) {
 						isup_masquerade_set_route_fd(ss7->ss7, slave_sock,
 								slave_chan_server.slave_channel[i].startcic,
 								slave_chan_server.slave_channel[i].endcic,
 								slave_chan_server.slave_channel[i].opc);
 
-						ss7->fds[i] = slave_sock;
+						ss7->fds[j] = slave_sock;
 						/* XXX */
 						if (ss7->master != AST_PTHREADT_NULL)
 							pthread_kill(ss7->master, SIGURG);
@@ -10918,7 +10931,8 @@
 					p->called_complete = 1; /* If COT succesful start call! */
 					/* Set DNID */						
 					strncpy(p->dnid, p->exten, sizeof(p->dnid));
-					if ((e->e == ISUP_EVENT_IAM) ? !(e->iam.cot_check_required || e->iam.cot_performed_on_previous_cic) : (!(e->sam.cot_check_required | e->sam.cot_performed_on_previous_cic) || e->sam.cot_check_passed))
+					//if ((e->e == ISUP_EVENT_IAM) ? !(e->iam.cot_check_required || e->iam.cot_performed_on_previous_cic) : (!(e->sam.cot_check_required | e->sam.cot_performed_on_previous_cic) || e->sam.cot_check_passed))
+					if (e->e == ISUP_EVENT_IAM)
 						ss7_start_call(p, linkset);
 				} else if (!ast_matchmore_extension(NULL, p->context, p->exten, 1, p->cid_num) || p->called_complete) {
 					ast_debug(1, "Call on CIC for unconfigured extension %s\n", p->exten);
@@ -10926,7 +10940,8 @@
 				}
 				ast_mutex_unlock(&p->lock);
 
-				if (e->iam.cot_performed_on_previous_cic) {
+				//if (e->iam.cot_performed_on_previous_cic) {
+				if (0) {
 					chanpos = ss7_find_cic(linkset, (e->iam.cic - 1), e->iam.opc);
 					if (chanpos < 0) {
 						/* some stupid switch do this */
@@ -10944,7 +10959,8 @@
 				}
 				break;
 			case ISUP_EVENT_COT:
-				if (e->cot.cot_performed_on_previous_cic) {
+				//if (e->cot.cot_performed_on_previous_cic) {
+				if (0) {
 					chanpos = ss7_find_cic(linkset, (e->cot.cic - 1), e->cot.opc);
 					/* some stupid switches do this!!! */
 					if (chanpos > 0) {
@@ -16654,10 +16670,12 @@
 					ast_log(LOG_ERROR, "Invalid linkset number.  Must be between 1 and %d\n", NUM_SPANS + 1);
 					return -1;
 				}
+#if 0
 				if(!link->ss7)
 					ast_log(LOG_ERROR, "Please specify non_isdn_access after sigchan!\n");
 				else if (ast_true(v->value))
 					ss7_clear_flags(link->ss7, SS7_ISDN_ACCESS_INDICATOR);
+#endif
 			} else if (!strcasecmp(v->name, "sls_shift")) {
 				struct dahdi_ss7 *link;
 				link = ss7_resolve_linkset(cur_linkset);




More information about the asterisk-commits mailing list