[asterisk-commits] oej: branch oej/peerfailover r101147 - in /team/oej/peerfailover: channels/ c...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jan 30 02:01:07 CST 2008
Author: oej
Date: Wed Jan 30 02:01:06 2008
New Revision: 101147
URL: http://svn.digium.com/view/asterisk?view=rev&rev=101147
Log:
Add failover of calls when host gets unreachable.
Modified:
team/oej/peerfailover/channels/chan_sip.c
team/oej/peerfailover/configs/sip.conf.sample
Modified: team/oej/peerfailover/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/channels/chan_sip.c?view=diff&rev=101147&r1=101146&r2=101147
==============================================================================
--- team/oej/peerfailover/channels/chan_sip.c (original)
+++ team/oej/peerfailover/channels/chan_sip.c Wed Jan 30 02:01:06 2008
@@ -15801,24 +15801,57 @@
return 0;
}
+/*! \brief Activate failover state for all calls
+ when peer becomes unreachable
+
+ This is advisory only, so if we can't lock a dialog, let's
+ just skip it and move on. The dialog will failover when xmit fails.
+*/
+static void device_failover_calls(struct sip_peer *device)
+{
+ struct sip_pvt *dialog;
+ int dialogs = 0;
+
+ ast_mutex_lock(&iflock);
+ for (dialog = iflist; dialog; dialog = dialog->next) {
+ if (strcmp(device->tohost, dialog->tohost))
+ continue;
+ /* If dialog is locked for some reason, don't deadlock, just continue */
+ if (ast_mutex_trylock(&dialog->lock))
+ continue;
+ dialogs++;
+ dialog->failoverstate = ACTIVE;
+ append_history(dialog, "FailOver", "Activated failover peer for unreachable peer %s :: %s", device->name, device->tohost);
+ ast_mutex_unlock(&dialog->lock);
+ if (dialogs == device->inUse)
+ break; /* We've found all, let's release the iflock quickly */
+ }
+ if (option_debug > 2)
+ ast_log(LOG_DEBUG, "FAILOVER :: Activated failover for %d dialogs. Unreachable peer has %d active calls\n", dialogs, device->inUse);
+ ast_mutex_unlock(&iflock);
+}
+
/*! \brief React to lack of answer to Qualify poke */
static int sip_poke_noanswer(const void *data)
{
struct sip_peer *peer = (struct sip_peer *)data;
+ AST_SCHED_DEL(sched, peer->pokeexpire);
peer->pokeexpire = -1;
if (peer->lastms > -1) {
ast_log(LOG_NOTICE, "Peer '%s' is now UNREACHABLE! Last qualify: %d\n", peer->name, peer->lastms);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Unreachable\r\nTime: %d\r\n", peer->name, -1);
}
- if (peer->call)
+ if (peer->call) /* Delete the NOTIFY operation */
sip_destroy(peer->call);
peer->call = NULL;
peer->lastms = -1;
ast_device_state_changed("SIP/%s", peer->name);
/* Try again quickly */
- AST_SCHED_DEL(sched, peer->pokeexpire);
peer->pokeexpire = ast_sched_add(sched, DEFAULT_FREQ_NOTOK, sip_poke_peer_s, peer);
+ if (!ast_strlen_zero(peer->failoverhostname) && peer->inUse)
+ /* We have a failover solution and active calls for this peer */
+ device_failover_calls(peer);
return 0;
}
Modified: team/oej/peerfailover/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/configs/sip.conf.sample?view=diff&rev=101147&r1=101146&r2=101147
==============================================================================
--- team/oej/peerfailover/configs/sip.conf.sample (original)
+++ team/oej/peerfailover/configs/sip.conf.sample Wed Jan 30 02:01:06 2008
@@ -498,7 +498,8 @@
; sendrpid
; outboundproxy
; rfc2833compensate
-; failoverpeer
+; failoverhost
+; failoverhostport
;[sip_proxy]
; For incoming calls only. Example: FWD (Free World Dialup)
@@ -522,8 +523,9 @@
; since they are not stored in-memory
;port=80 ; The port number we want to connect to on the remote side
; Also used as "defaultport" in combination with "defaultip" settings
-;failoverpeer:proxy2.provider.domain ; In case the first proxy fails, use proxy2 for SIP signalling. Media will
+;failoverhost=proxy2.provider.domain ; In case the first proxy fails, use proxy2 for SIP signalling. Media will
; not be affected. Also, NAT support won't affect failoverproxy at all.
+ ; This only works with non-dynamic peers, peers that does not register.
;------------------------------------------------------------------------------
; Definitions of locally connected SIP devices
More information about the asterisk-commits
mailing list