Merged revisions 318917 via svnmerge from
authorBrett Bryant <bbryant@digium.com>
Fri, 13 May 2011 17:58:53 +0000 (17:58 +0000)
committerBrett Bryant <bbryant@digium.com>
Fri, 13 May 2011 17:58:53 +0000 (17:58 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r318917 | bbryant | 2011-05-13 13:56:04 -0400 (Fri, 13 May 2011) | 11 lines

  This patch allows TCP peers into the ast_db where they were previously
  restricted.

  (closes issue #18882)
  Reported by: cmaj
  Patches:
        patch-chan_sip-1.8.3-rc2-allow-tcp-peer-store-db-and-readonly-rt-backend.diff.txt
        uploaded by cmaj (license 830)
  Tested by: cmaj
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318918 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 6c35275..fa525a5 100644 (file)
@@ -13445,7 +13445,8 @@ static void reg_source_db(struct sip_peer *peer)
                AST_APP_ARG(contact);
        );
 
-       if (peer->rt_fromcontact) {
+       /* If read-only RT backend, then refresh from local DB cache */
+       if (peer->rt_fromcontact && sip_cfg.peer_rtupdate) {
                return;
        }
        if (ast_db_get("SIP/Registry", peer->name, data, sizeof(data))) {
@@ -13764,11 +13765,8 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
        pvt->expiry = expire;
        snprintf(data, sizeof(data), "%s:%d:%s:%s", ast_sockaddr_stringify(&peer->addr),
                 expire, peer->username, peer->fullcontact);
-       /* Saving TCP connections is useless, we won't be able to reconnect
-               XXX WHY???? XXX
-               \todo Fix this immediately.
-       */
-       if (!peer->rt_fromcontact && (peer->socket.type & SIP_TRANSPORT_UDP))
+       /* We might not immediately be able to reconnect via TCP, but try caching it anyhow */
+       if (!peer->rt_fromcontact || !sip_cfg.peer_rtupdate)
                ast_db_put("SIP/Registry", peer->name, data);
        manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: Registered\r\nAddress: %s\r\n", peer->name,  ast_sockaddr_stringify(&peer->addr));
 
@@ -27080,7 +27078,8 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
        if (ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)) {
                sip_cfg.allowsubscribe = TRUE;  /* No global ban any more */
        }
-       if (peer->host_dynamic && !peer->is_realtime) {
+       /* If read-only RT backend, then refresh from local DB cache */
+       if (peer->host_dynamic && !sip_cfg.peer_rtupdate) {
                reg_source_db(peer);
        }