[svn-commits] oej: branch oej/pgtips-srv-and-outbound-stuff-1.8 r421668 - in /team/oej/pgti...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Aug 21 06:52:59 CDT 2014
Author: oej
Date: Thu Aug 21 06:52:49 2014
New Revision: 421668
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=421668
Log:
Adding a touch of failover
Modified:
team/oej/pgtips-srv-and-outbound-stuff-1.8/channels/chan_sip.c
team/oej/pgtips-srv-and-outbound-stuff-1.8/main/srv.c
Modified: team/oej/pgtips-srv-and-outbound-stuff-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pgtips-srv-and-outbound-stuff-1.8/channels/chan_sip.c?view=diff&rev=421668&r1=421667&r2=421668
==============================================================================
--- team/oej/pgtips-srv-and-outbound-stuff-1.8/channels/chan_sip.c (original)
+++ team/oej/pgtips-srv-and-outbound-stuff-1.8/channels/chan_sip.c Thu Aug 21 06:52:49 2014
@@ -4445,7 +4445,6 @@
if (p->outboundproxy) {
p->sa = p->outboundproxy->ip;
/* We need the SRV context as well */
-
}
finalize_content(req);
@@ -4464,12 +4463,14 @@
deinit_req(&tmp);
}
if (p->srvcontext) {
+ int tryagain = TRUE;
/* We have an SRV record set. If we get transmit errors, retry on the next directly. */
- while (res != -1 && res != XMIT_ERROR) {
+ while (tryagain) {
res = (reliable) ?
__sip_reliable_xmit(p, seqno, 0, req->data, (reliable == XMIT_CRITICAL), req->method) :
__sip_xmit(p, req->data);
if (res == -1 || res == XMIT_ERROR) {
+ ast_debug(3, "====>> SRV failover loop. Looking for next host \n");
char hostname[MAXHOSTNAMELEN];
const char *host = &hostname[0];
unsigned short port, prio, weight;
@@ -4479,10 +4480,18 @@
ast_log(LOG_WARNING, "No more hosts: %s\n", p->srvdomain);
res = -1;
} else {
+ if (!ast_sockaddr_resolve_first_transport(&p->sa, hostname, 0, p->socket.type ? p->socket.type : SIP_TRANSPORT_UDP)) {
+ /* We found a host to try on */
+ break;
+ }
+ /* Make sure we set the port */
+ ast_sockaddr_set_port(&dialog->sa, port);
ast_debug(3, "====>> SRV failover. Changing to host %s port %d\n", hostname, port);
- /* Select IP address */
- /* Change IP in p */
+ res = 0; /* Fail over */
}
+ } else {
+ ast_debug(3, "====>> sip_xmit success \n");
+ tryagain = FALSE;
}
}
} else {
@@ -5756,6 +5765,7 @@
if (hostport.port) {
dialog->portinuri = TRUE;
}
+ ast_debug(4, "Going to find something with the name %s \n", peername);
dialog->timer_t1 = global_t1; /* Default SIP retransmission timer T1 (RFC 3261) */
dialog->timer_b = global_timer_b; /* Default SIP transaction timer B (RFC 3261) */
@@ -5824,9 +5834,9 @@
unsigned short port, prio, weight;
const char *srvhost;
- ast_debug(3, " ==> DNS lookup of %s returned %d entries. First %s \n", service, ast_srv_get_record_count(dialog->srvcontext), hostn);
+ ast_debug(3, " ==> DNS lookup of %s returned %d entries. \n", service, ast_srv_get_record_count(dialog->srvcontext));
hostn = host;
- for (rec = 0; rec < ast_srv_get_record_count(dialog->srvcontext); rec++) {
+ for (rec = 1; rec <= ast_srv_get_record_count(dialog->srvcontext); rec++) {
if(ast_srv_get_nth_record(dialog->srvcontext, rec, &srvhost, &port, &prio, &weight)) {
ast_log(LOG_WARNING, "No more SRV records for: %s\n", peername);
return -1;
@@ -5840,10 +5850,12 @@
/* We found a host to try on */
break;
}
+ /* Make sure we set the port */
+ ast_sockaddr_set_port(&dialog->sa, port);
}
- ast_debug(3, " ==> Settling with SRV entry %d: %s\n", rec, hostn);
+ ast_debug(3, " ==> Settling with SRV entry %d: %s Port %d\n", rec, hostn, port);
}
} else {
@@ -5851,10 +5863,6 @@
ast_log(LOG_WARNING, "No such host: %s\n", peername);
return -1;
}
- }
-
- if (srv_ret > 0) {
- ast_sockaddr_set_port(&dialog->sa, tportno);
}
}
Modified: team/oej/pgtips-srv-and-outbound-stuff-1.8/main/srv.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pgtips-srv-and-outbound-stuff-1.8/main/srv.c?view=diff&rev=421668&r1=421667&r2=421668
==============================================================================
--- team/oej/pgtips-srv-and-outbound-stuff-1.8/main/srv.c (original)
+++ team/oej/pgtips-srv-and-outbound-stuff-1.8/main/srv.c Thu Aug 21 06:52:49 2014
@@ -149,7 +149,9 @@
ast_debug(3, " ==> Callback received ttl= %u\n", ttl);
expiry.tv_sec = (long) ttl;
- expiry = ast_tvadd(expiry, ast_tvnow());
+ if (ttl > 0) {
+ expiry = ast_tvadd(expiry, ast_tvnow());
+ }
if (c == NULL) {
ast_debug(3, " ==> Callback with no context ?? \n");
More information about the svn-commits
mailing list