[svn-commits] oej: branch oej/pgtips-srv-and-outbound-stuff-1.8 r421524 - in /team/oej/pgti...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Aug 20 04:03:52 CDT 2014
Author: oej
Date: Wed Aug 20 04:03:44 2014
New Revision: 421524
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=421524
Log:
Handling TTL properly
Modified:
team/oej/pgtips-srv-and-outbound-stuff-1.8/channels/chan_sip.c
team/oej/pgtips-srv-and-outbound-stuff-1.8/include/asterisk/srv.h
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=421524&r1=421523&r2=421524
==============================================================================
--- 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 Wed Aug 20 04:03:44 2014
@@ -29132,7 +29132,7 @@
unsigned short prio, weight;
const char *hostname;
- ast_debug(3, " ==> DNS SRV lookup of %s returned %d entries. \n", transport, ast_srv_get_record_count(peer->srvcontext));
+ ast_debug(3, " ==> DNS SRV lookup of %s returned %d entries. Next expiry in %d secs\n", transport, ast_srv_get_record_count(peer->srvcontext), (int) ast_tvdiff_sec(*(ast_srv_get_min_ttl(peer->srvcontext)),ast_tvnow()));
/* Try all candidates until we find one that fits our address family
* Note that the SRV code lists the candidates in order of weight and priority.
*/
@@ -29159,8 +29159,9 @@
/* Get host name */
res = ast_srv_get_nth_record(peer->srvcontext, rec, &hostname, &tportno, &prio, &weight);
if (!res) {
+ unsigned int ttl=0;
/* We need to test every address in the SRV record set. */
- res = ast_sockaddr_resolve_first_transport(&ip, hostname, 0, peer->socket.type);
+ res = ast_sockaddr_resolve_first_transport_ttl(&ip, &ttl, hostname, 0, peer->socket.type);
if (ast_sockaddr_isnull(&ip) || res ) {
ast_debug(3, " ==> Bad IP, could not resolve hostname %s to proper family. \n", hostname);
} else {
@@ -31257,7 +31258,7 @@
int addrs_cnt;
int i;
- addrs_cnt = ast_sockaddr_resolve(&addrs, name, flag, family);
+ addrs_cnt = ast_sockaddr_resolve_ttl(&addrs, name, flag, family);
if (addrs_cnt <= 0) {
return 1;
}
Modified: team/oej/pgtips-srv-and-outbound-stuff-1.8/include/asterisk/srv.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pgtips-srv-and-outbound-stuff-1.8/include/asterisk/srv.h?view=diff&rev=421524&r1=421523&r2=421524
==============================================================================
--- team/oej/pgtips-srv-and-outbound-stuff-1.8/include/asterisk/srv.h (original)
+++ team/oej/pgtips-srv-and-outbound-stuff-1.8/include/asterisk/srv.h Wed Aug 20 04:03:44 2014
@@ -133,6 +133,18 @@
unsigned short *port, unsigned short *priority, unsigned short *weight);
/*!
+ * \brief Get the minimum TTL for all records in an SRV record set
+ */
+struct timeval *ast_srv_get_min_ttl(struct srv_context *context);
+
+/*!
+ * \brief Check if a context is expired (DNS TTL exceeded)
+ * \retval 0 (FALSE) The context is expired and needs to be updated
+ * \retval 1 (TRUE) The context is still valid
+ */
+int ast_srv_context_valid(struct srv_context *context);
+
+/*!
* \brief Print out the complete data in the SRV list
*/
void ast_srv_debug_print(struct srv_context *context);
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=421524&r1=421523&r2=421524
==============================================================================
--- 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 Wed Aug 20 04:03:44 2014
@@ -52,6 +52,7 @@
#include "asterisk/srv.h"
#include "asterisk/dns.h"
#include "asterisk/utils.h"
+#include "asterisk/time.h"
#include "asterisk/linkedlists.h"
#ifdef __APPLE__
@@ -398,11 +399,26 @@
return res;
}
+struct timeval *ast_srv_get_min_ttl(struct srv_context *context)
+{
+ return &context->min_ttl_expire;
+}
+
unsigned int ast_srv_get_record_count(struct srv_context *context)
{
return context->num_records;
}
+
+int ast_srv_context_valid(struct srv_context *context)
+{
+ if (ast_tvcmp(ast_tvnow(), context->min_ttl_expire) > 0) {
+ return 1;
+ }
+
+ return 0;
+}
+
int ast_srv_get_next_record(struct srv_context *context, const char **host,
unsigned short *port, unsigned short *priority, unsigned short *weight)
More information about the svn-commits
mailing list