Author: kmoore
Date: Fri Aug  2 13:56:16 2013
New Revision: 396151

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396151
Log:
Resolve merge conflict

Added:
    
team/kmoore/res_sip_threadpool_options/rest-api-templates/param_cleanup.mustache
      - copied unchanged from r396145, 
trunk/rest-api-templates/param_cleanup.mustache
Modified:
    team/kmoore/res_sip_threadpool_options/   (props changed)
    team/kmoore/res_sip_threadpool_options/apps/app_chanspy.c
    team/kmoore/res_sip_threadpool_options/channels/chan_dahdi.c
    team/kmoore/res_sip_threadpool_options/channels/chan_iax2.c
    team/kmoore/res_sip_threadpool_options/channels/chan_mgcp.c
    team/kmoore/res_sip_threadpool_options/channels/chan_misdn.c
    team/kmoore/res_sip_threadpool_options/channels/chan_oss.c
    team/kmoore/res_sip_threadpool_options/channels/chan_sip.c
    team/kmoore/res_sip_threadpool_options/channels/chan_skinny.c
    team/kmoore/res_sip_threadpool_options/channels/sig_pri.c
    team/kmoore/res_sip_threadpool_options/funcs/func_channel.c
    team/kmoore/res_sip_threadpool_options/include/asterisk/astobj2.h
    team/kmoore/res_sip_threadpool_options/include/asterisk/channel.h
    team/kmoore/res_sip_threadpool_options/include/asterisk/json.h
    team/kmoore/res_sip_threadpool_options/include/asterisk/parking.h
    team/kmoore/res_sip_threadpool_options/include/asterisk/pickup.h
    team/kmoore/res_sip_threadpool_options/include/asterisk/stasis_bridges.h
    team/kmoore/res_sip_threadpool_options/include/asterisk/strings.h
    team/kmoore/res_sip_threadpool_options/main/astobj2.c
    team/kmoore/res_sip_threadpool_options/main/bridge_channel.c
    team/kmoore/res_sip_threadpool_options/main/cel.c
    team/kmoore/res_sip_threadpool_options/main/channel.c
    team/kmoore/res_sip_threadpool_options/main/channel_internal_api.c
    team/kmoore/res_sip_threadpool_options/main/json.c
    team/kmoore/res_sip_threadpool_options/main/manager_bridges.c
    team/kmoore/res_sip_threadpool_options/main/pickup.c
    team/kmoore/res_sip_threadpool_options/main/rtp_engine.c
    team/kmoore/res_sip_threadpool_options/main/stasis_bridges.c
    team/kmoore/res_sip_threadpool_options/main/strings.c
    team/kmoore/res_sip_threadpool_options/res/ari/ari_model_validators.c
    team/kmoore/res_sip_threadpool_options/res/ari/ari_model_validators.h
    team/kmoore/res_sip_threadpool_options/res/ari/ari_websockets.c
    team/kmoore/res_sip_threadpool_options/res/ari/resource_asterisk.c
    team/kmoore/res_sip_threadpool_options/res/ari/resource_asterisk.h
    team/kmoore/res_sip_threadpool_options/res/ari/resource_bridges.c
    team/kmoore/res_sip_threadpool_options/res/ari/resource_bridges.h
    team/kmoore/res_sip_threadpool_options/res/ari/resource_events.c
    team/kmoore/res_sip_threadpool_options/res/ari/resource_events.h
    team/kmoore/res_sip_threadpool_options/res/ari/resource_sounds.h
    team/kmoore/res_sip_threadpool_options/res/parking/parking_bridge.c
    team/kmoore/res_sip_threadpool_options/res/parking/parking_manager.c
    team/kmoore/res_sip_threadpool_options/res/res_ari_asterisk.c
    team/kmoore/res_sip_threadpool_options/res/res_ari_bridges.c
    team/kmoore/res_sip_threadpool_options/res/res_ari_channels.c
    team/kmoore/res_sip_threadpool_options/res/res_ari_endpoints.c
    team/kmoore/res_sip_threadpool_options/res/res_ari_events.c
    team/kmoore/res_sip_threadpool_options/res/res_ari_playback.c
    team/kmoore/res_sip_threadpool_options/res/res_ari_recordings.c
    team/kmoore/res_sip_threadpool_options/res/res_ari_sounds.c
    team/kmoore/res_sip_threadpool_options/res/res_pjsip.c
    
team/kmoore/res_sip_threadpool_options/res/res_pjsip/include/res_pjsip_private.h
    team/kmoore/res_sip_threadpool_options/res/res_pjsip/pjsip_options.c
    team/kmoore/res_sip_threadpool_options/res/res_pjsip_notify.c
    team/kmoore/res_sip_threadpool_options/res/res_pjsip_outbound_registration.c
    team/kmoore/res_sip_threadpool_options/res/res_sorcery_astdb.c
    team/kmoore/res_sip_threadpool_options/res/snmp/agent.c
    
team/kmoore/res_sip_threadpool_options/rest-api-templates/ari_resource.h.mustache
    
team/kmoore/res_sip_threadpool_options/rest-api-templates/param_parsing.mustache
    
team/kmoore/res_sip_threadpool_options/rest-api-templates/res_ari_resource.c.mustache
    team/kmoore/res_sip_threadpool_options/rest-api/api-docs/asterisk.json
    team/kmoore/res_sip_threadpool_options/rest-api/api-docs/bridges.json
    team/kmoore/res_sip_threadpool_options/rest-api/api-docs/channels.json
    team/kmoore/res_sip_threadpool_options/rest-api/api-docs/events.json
    team/kmoore/res_sip_threadpool_options/rest-api/api-docs/sounds.json
    team/kmoore/res_sip_threadpool_options/tests/test_json.c
    team/kmoore/res_sip_threadpool_options/utils/Makefile
    team/kmoore/res_sip_threadpool_options/utils/refcounter.c

Propchange: team/kmoore/res_sip_threadpool_options/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/kmoore/res_sip_threadpool_options/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Aug  2 13:56:16 2013
@@ -1,1 +1,1 @@
-/trunk:1-396077
+/trunk:1-396150

Modified: team/kmoore/res_sip_threadpool_options/apps/app_chanspy.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/apps/app_chanspy.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/apps/app_chanspy.c (original)
+++ team/kmoore/res_sip_threadpool_options/apps/app_chanspy.c Fri Aug  2 
13:56:16 2013
@@ -637,12 +637,14 @@
        }
 
        if (ast_test_flag(flags, OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
+               RAII_VAR(struct ast_channel *, bridged, 
ast_channel_bridge_peer(spyee_autochan->chan), ast_channel_cleanup);
+
                /* And this hook lets us inject audio into the channel that the 
spied on
                   channel is currently bridged with.
                */
                ast_audiohook_init(&csth.bridge_whisper_audiohook, 
AST_AUDIOHOOK_TYPE_WHISPER, "Chanspy", 0);
 
-               if ((spyee_bridge_autochan = 
ast_autochan_setup(ast_bridged_channel(spyee_autochan->chan)))) {
+               if ((spyee_bridge_autochan = ast_autochan_setup(bridged))) {
                        ast_channel_lock(spyee_bridge_autochan->chan);
                        if (start_spying(spyee_bridge_autochan, spyer_name, 
&csth.bridge_whisper_audiohook)) {
                                ast_log(LOG_WARNING, "Unable to attach barge 
audiohook on spyee %s. Barge mode disabled!\n", name);
@@ -935,7 +937,7 @@
                                break;
                        }
 
-                       if (ast_test_flag(flags, OPTION_BRIDGED) && 
!ast_bridged_channel(autochan->chan)) {
+                       if (ast_test_flag(flags, OPTION_BRIDGED) && 
!ast_channel_is_bridged(autochan->chan)) {
                                continue;
                        }
 

Modified: team/kmoore/res_sip_threadpool_options/channels/chan_dahdi.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/channels/chan_dahdi.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/channels/chan_dahdi.c (original)
+++ team/kmoore/res_sip_threadpool_options/channels/chan_dahdi.c Fri Aug  2 
13:56:16 2013
@@ -1742,7 +1742,7 @@
 
 static void *my_get_sigpvt_bridged_channel(struct ast_channel *chan)
 {
-       struct ast_channel *bridged = ast_bridged_channel(chan);
+       RAII_VAR(struct ast_channel *, bridged, ast_channel_bridge_peer(chan), 
ast_channel_cleanup);
 
        if (bridged && ast_channel_tech(bridged) == &dahdi_tech) {
                struct dahdi_pvt *p = ast_channel_tech_pvt(bridged);
@@ -9737,12 +9737,15 @@
                                struct ast_channel *nbridge =
                                        p->subs[SUB_THREEWAY].owner;
                                struct dahdi_pvt *pbridge = NULL;
+                               RAII_VAR(struct ast_channel *, bridged, nbridge 
? ast_channel_bridge_peer(nbridge) : NULL, ast_channel_cleanup);
+
                                /* set up the private struct of the bridged 
one, if any */
-                               if (nbridge && ast_bridged_channel(nbridge))
-                                       pbridge = 
ast_channel_tech_pvt(ast_bridged_channel(nbridge));
+                               if (nbridge && bridged) {
+                                       pbridge = ast_channel_tech_pvt(bridged);
+                               }
                                if (nbridge && pbridge &&
                                        (ast_channel_tech(nbridge) == 
&dahdi_tech) &&
-                                       
(ast_channel_tech(ast_bridged_channel(nbridge)) == &dahdi_tech) &&
+                                       (ast_channel_tech(bridged) == 
&dahdi_tech) &&
                                        ISTRUNK(pbridge)) {
                                        int func = DAHDI_FLASH;
                                        /* Clear out the dial buffer */

Modified: team/kmoore/res_sip_threadpool_options/channels/chan_iax2.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/channels/chan_iax2.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/channels/chan_iax2.c (original)
+++ team/kmoore/res_sip_threadpool_options/channels/chan_iax2.c Fri Aug  2 
13:56:16 2013
@@ -4049,7 +4049,7 @@
        int ret;
        int needfree = 0;
        struct ast_channel *owner = NULL;
-       struct ast_channel *bridge = NULL;
+       RAII_VAR(struct ast_channel *, bridge, NULL, ast_channel_cleanup);
 
        /*
         * Clear fr->af.data if there is no data in the buffer.  Things
@@ -4096,8 +4096,9 @@
                iax2_frame_free(fr);
                return -1;
        }
-       if ((owner = iaxs[fr->callno]->owner))
-               bridge = ast_bridged_channel(owner);
+       if ((owner = iaxs[fr->callno]->owner)) {
+               bridge = ast_channel_bridge_peer(owner);
+       }
 
        /* if the user hasn't requested we force the use of the jitterbuffer, 
and we're bridged to
         * a channel that can accept jitter, then flush and suspend the jb, and 
send this frame straight through */

Modified: team/kmoore/res_sip_threadpool_options/channels/chan_mgcp.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/channels/chan_mgcp.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/channels/chan_mgcp.c (original)
+++ team/kmoore/res_sip_threadpool_options/channels/chan_mgcp.c Fri Aug  2 
13:56:16 2013
@@ -922,7 +922,6 @@
 {
        struct mgcp_subchannel *sub = ast_channel_tech_pvt(ast);
        struct mgcp_endpoint *p = sub->parent;
-       struct ast_channel *bridged;
 
        ast_debug(1, "mgcp_hangup(%s)\n", ast_channel_name(ast));
        if (!ast_channel_tech_pvt(ast)) {
@@ -969,10 +968,11 @@
        }
        sub->cxident[0] = '\0';
        if ((sub == p->sub) && sub->next->owner) {
+               RAII_VAR(struct ast_channel *, bridged, 
ast_channel_bridge_peer(sub->next->owner), ast_channel_cleanup);
+
                if (p->hookstate == MGCP_OFFHOOK) {
-                       if (sub->next->owner && 
ast_bridged_channel(sub->next->owner)) {
+                       if (sub->next->owner && bridged) {
                                /* ncs fix! */
-                               bridged = ast_bridged_channel(sub->next->owner);
                                transmit_notify_request_with_callerid(p->sub, 
(p->ncs ? "L/wt1" : "L/wt"),
                                        
S_COR(ast_channel_caller(bridged)->id.number.valid, 
ast_channel_caller(bridged)->id.number.str, ""),
                                        
S_COR(ast_channel_caller(bridged)->id.name.valid, 
ast_channel_caller(bridged)->id.name.str, ""));
@@ -982,8 +982,7 @@
                        p->sub = sub->next;
                        p->sub->cxmode = MGCP_CX_RECVONLY;
                        transmit_modify_request(p->sub);
-                       if (sub->next->owner && 
ast_bridged_channel(sub->next->owner)) {
-                               bridged = ast_bridged_channel(sub->next->owner);
+                       if (sub->next->owner && bridged) {
                                transmit_notify_request_with_callerid(p->sub, 
"L/rg",
                                        
S_COR(ast_channel_caller(bridged)->id.number.valid, 
ast_channel_caller(bridged)->id.number.str, ""),
                                        
S_COR(ast_channel_caller(bridged)->id.name.valid, 
ast_channel_caller(bridged)->id.name.str, ""));

Modified: team/kmoore/res_sip_threadpool_options/channels/chan_misdn.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/channels/chan_misdn.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/channels/chan_misdn.c (original)
+++ team/kmoore/res_sip_threadpool_options/channels/chan_misdn.c Fri Aug  2 
13:56:16 2013
@@ -104,6 +104,7 @@
 #include "asterisk/format_cap.h"
 #include "asterisk/features_config.h"
 #include "asterisk/bridge.h"
+#include "asterisk/pickup.h"
 
 #include "chan_misdn_config.h"
 #include "isdn_lib.h"
@@ -3442,6 +3443,7 @@
 
 static void export_aoc_vars(int originator, struct ast_channel *ast, struct 
misdn_bchannel *bc)
 {
+       RAII_VAR(struct ast_channel *, chan, NULL, ast_channel_cleanup);
        char buf[128];
 
        if (!bc->AOCD_need_export || !ast) {
@@ -3449,46 +3451,48 @@
        }
 
        if (originator == ORG_AST) {
-               ast = ast_bridged_channel(ast);
-               if (!ast) {
+               chan = ast_channel_bridge_peer(ast);
+               if (!chan) {
                        return;
                }
+       } else {
+               chan = ast_channel_ref(ast);
        }
 
        switch (bc->AOCDtype) {
        case Fac_AOCDCurrency:
-               pbx_builtin_setvar_helper(ast, "AOCD_Type", "currency");
+               pbx_builtin_setvar_helper(chan, "AOCD_Type", "currency");
                if (bc->AOCD.currency.chargeNotAvailable) {
-                       pbx_builtin_setvar_helper(ast, "AOCD_ChargeAvailable", 
"no");
+                       pbx_builtin_setvar_helper(chan, "AOCD_ChargeAvailable", 
"no");
                } else {
-                       pbx_builtin_setvar_helper(ast, "AOCD_ChargeAvailable", 
"yes");
+                       pbx_builtin_setvar_helper(chan, "AOCD_ChargeAvailable", 
"yes");
                        if (bc->AOCD.currency.freeOfCharge) {
-                               pbx_builtin_setvar_helper(ast, 
"AOCD_FreeOfCharge", "yes");
+                               pbx_builtin_setvar_helper(chan, 
"AOCD_FreeOfCharge", "yes");
                        } else {
-                               pbx_builtin_setvar_helper(ast, 
"AOCD_FreeOfCharge", "no");
+                               pbx_builtin_setvar_helper(chan, 
"AOCD_FreeOfCharge", "no");
                                if (snprintf(buf, sizeof(buf), "%d %s", 
bc->AOCD.currency.currencyAmount * bc->AOCD.currency.multiplier, 
bc->AOCD.currency.currency) < sizeof(buf)) {
-                                       pbx_builtin_setvar_helper(ast, 
"AOCD_Amount", buf);
+                                       pbx_builtin_setvar_helper(chan, 
"AOCD_Amount", buf);
                                        if (bc->AOCD.currency.billingId >= 0 && 
snprintf(buf, sizeof(buf), "%d", bc->AOCD.currency.billingId) < sizeof(buf)) {
-                                               pbx_builtin_setvar_helper(ast, 
"AOCD_BillingId", buf);
+                                               pbx_builtin_setvar_helper(chan, 
"AOCD_BillingId", buf);
                                        }
                                }
                        }
                }
                break;
        case Fac_AOCDChargingUnit:
-               pbx_builtin_setvar_helper(ast, "AOCD_Type", "charging_unit");
+               pbx_builtin_setvar_helper(chan, "AOCD_Type", "charging_unit");
                if (bc->AOCD.chargingUnit.chargeNotAvailable) {
-                       pbx_builtin_setvar_helper(ast, "AOCD_ChargeAvailable", 
"no");
+                       pbx_builtin_setvar_helper(chan, "AOCD_ChargeAvailable", 
"no");
                } else {
-                       pbx_builtin_setvar_helper(ast, "AOCD_ChargeAvailable", 
"yes");
+                       pbx_builtin_setvar_helper(chan, "AOCD_ChargeAvailable", 
"yes");
                        if (bc->AOCD.chargingUnit.freeOfCharge) {
-                               pbx_builtin_setvar_helper(ast, 
"AOCD_FreeOfCharge", "yes");
+                               pbx_builtin_setvar_helper(chan, 
"AOCD_FreeOfCharge", "yes");
                        } else {
-                               pbx_builtin_setvar_helper(ast, 
"AOCD_FreeOfCharge", "no");
+                               pbx_builtin_setvar_helper(chan, 
"AOCD_FreeOfCharge", "no");
                                if (snprintf(buf, sizeof(buf), "%d", 
bc->AOCD.chargingUnit.recordedUnits) < sizeof(buf)) {
-                                       pbx_builtin_setvar_helper(ast, 
"AOCD_RecordedUnits", buf);
+                                       pbx_builtin_setvar_helper(chan, 
"AOCD_RecordedUnits", buf);
                                        if (bc->AOCD.chargingUnit.billingId >= 
0 && snprintf(buf, sizeof(buf), "%d", bc->AOCD.chargingUnit.billingId) < 
sizeof(buf)) {
-                                               pbx_builtin_setvar_helper(ast, 
"AOCD_BillingId", buf);
+                                               pbx_builtin_setvar_helper(chan, 
"AOCD_BillingId", buf);
                                        }
                                }
                        }
@@ -10943,7 +10947,7 @@
        case EVENT_HOLD:
        {
                int hold_allowed;
-               struct ast_channel *bridged;
+               RAII_VAR(struct ast_channel *, bridged, NULL, 
ast_channel_cleanup);
 
                misdn_cfg_get(bc->port, MISDN_CFG_HOLD_ALLOWED, &hold_allowed, 
sizeof(hold_allowed));
                if (!hold_allowed) {
@@ -10952,7 +10956,7 @@
                        break;
                }
 
-               bridged = ast_bridged_channel(ch->ast);
+               bridged = ast_channel_bridge_peer(ch->ast);
                if (bridged) {
                        chan_misdn_log(2, bc->port, "Bridge Partner is of type: 
%s\n", ast_channel_tech(bridged)->type);
                        ch->l3id = bc->l3_id;

Modified: team/kmoore/res_sip_threadpool_options/channels/chan_oss.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/channels/chan_oss.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/channels/chan_oss.c (original)
+++ team/kmoore/res_sip_threadpool_options/channels/chan_oss.c Fri Aug  2 
13:56:16 2013
@@ -68,6 +68,7 @@
 #include "asterisk/causes.h"
 #include "asterisk/musiconhold.h"
 #include "asterisk/app.h"
+#include "asterisk/bridge.h"
 
 #include "console_video.h"
 
@@ -1173,7 +1174,7 @@
 static char *console_transfer(struct ast_cli_entry *e, int cmd, struct 
ast_cli_args *a)
 {
        struct chan_oss_pvt *o = find_desc(oss_active);
-       struct ast_channel *b = NULL;
+       RAII_VAR(struct ast_channel *, b, NULL, ast_channel_cleanup);
        char *tmp, *ext, *ctx;
 
        switch (cmd) {
@@ -1192,24 +1193,19 @@
                return CLI_SHOWUSAGE;
        if (o == NULL)
                return CLI_FAILURE;
-       if (o->owner == NULL || (b = ast_bridged_channel(o->owner)) == NULL) {
+       if (o->owner == NULL || !ast_channel_is_bridged(o->owner)) {
                ast_cli(a->fd, "There is no call to transfer\n");
                return CLI_SUCCESS;
        }
 
        tmp = ast_ext_ctx(a->argv[2], &ext, &ctx);
-       if (ctx == NULL)                        /* supply default context if 
needed */
+       if (ctx == NULL) {                      /* supply default context if 
needed */
                ctx = ast_strdupa(ast_channel_context(o->owner));
-       if (!ast_exists_extension(b, ctx, ext, 1,
-               S_COR(ast_channel_caller(b)->id.number.valid, 
ast_channel_caller(b)->id.number.str, NULL))) {
-               ast_cli(a->fd, "No such extension exists\n");
-       } else {
-               ast_cli(a->fd, "Whee, transferring %s to %s@%s.\n", 
ast_channel_name(b), ext, ctx);
-               if (ast_async_goto(b, ctx, ext, 1))
-                       ast_cli(a->fd, "Failed to transfer :(\n");
-       }
-       if (tmp)
-               ast_free(tmp);
+       }
+       if (ast_bridge_transfer_blind(1, o->owner, ext, ctx, NULL, NULL) != 
AST_BRIDGE_TRANSFER_SUCCESS) {
+               ast_log(LOG_WARNING, "Unable to transfer call from channel 
%s\n", ast_channel_name(o->owner));
+       }
+       ast_free(tmp);
        return CLI_SUCCESS;
 }
 

Modified: team/kmoore/res_sip_threadpool_options/channels/chan_sip.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/channels/chan_sip.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/channels/chan_sip.c (original)
+++ team/kmoore/res_sip_threadpool_options/channels/chan_sip.c Fri Aug  2 
13:56:16 2013
@@ -7271,7 +7271,7 @@
                        }
 
                        if (!p->pendinginvite) {
-                               struct ast_channel *bridge = 
ast_bridged_channel(oldowner);
+                               RAII_VAR(struct ast_channel *, bridge, 
ast_channel_bridge_peer(oldowner), ast_channel_cleanup);
                                char quality_buf[AST_MAX_USER_FIELD], *quality;
 
                                /* We need to get the lock on bridge because 
ast_rtp_instance_set_stats_vars will attempt
@@ -7282,7 +7282,6 @@
                                        do {
                                                
CHANNEL_DEADLOCK_AVOIDANCE(oldowner);
                                        } while (sip_pvt_trylock(p));
-                                       bridge = ast_bridged_channel(oldowner);
                                }
 
                                if (p->rtp) {
@@ -18007,10 +18006,22 @@
 
        /* Give useful transfer information to the dialplan */
        if (transferer->owner) {
-               struct ast_channel *peer = 
ast_bridged_channel(transferer->owner);
+               RAII_VAR(struct ast_channel *, peer, 
ast_channel_bridge_peer(transferer->owner), ast_channel_cleanup);
+
+               /*! pbx_builtin_setvar_helper will attempt to lock the channel. 
We need
+                * to be sure it's already locked here so we don't deadlock.
+                */
+               while (peer && ast_channel_trylock(peer)) {
+                       sip_pvt_unlock(transferer);
+                       do {
+                               CHANNEL_DEADLOCK_AVOIDANCE(transferer->owner);
+                       } while (sip_pvt_trylock(transferer));
+               }
+
                if (peer) {
                        pbx_builtin_setvar_helper(peer, "SIPREFERRINGCONTEXT", 
transferer->context);
                        pbx_builtin_setvar_helper(peer, "SIPREFERREDBYHDR", 
p_referred_by);
+                       ast_channel_unlock(peer);
                }
        }
 
@@ -26354,7 +26365,6 @@
 {
        struct ast_channel *c=NULL;
        int res;
-       struct ast_channel *bridged_to;
        const char *required;
 
        /* If we have an INCOMING invite that we haven't answered, terminate 
that transaction */
@@ -26375,7 +26385,7 @@
        /* Get RTCP quality before end of call */
        if (p->do_history || p->owner) {
                char quality_buf[AST_MAX_USER_FIELD], *quality;
-               struct ast_channel *bridge = p->owner ? 
ast_bridged_channel(p->owner) : NULL;
+               RAII_VAR(struct ast_channel *, bridge, p->owner ? 
ast_channel_bridge_peer(p->owner) : NULL, ast_channel_cleanup);
 
                /* We need to get the lock on bridge because 
ast_rtp_instance_set_stats_vars will attempt
                 * to lock the bridge. This may get hairy...
@@ -26388,7 +26398,6 @@
                                usleep(1);
                                sip_pvt_lock(p);
                        } while (p->owner && ast_channel_trylock(p->owner));
-                       bridge = p->owner ? ast_bridged_channel(p->owner) : 
NULL;
                }
 
 
@@ -26452,7 +26461,7 @@
                if (!res) {
                        c = p->owner;
                        if (c) {
-                               bridged_to = ast_bridged_channel(c);
+                               RAII_VAR(struct ast_channel *, bridged_to, 
ast_channel_bridge_peer(c), ast_channel_cleanup);
                                if (bridged_to) {
                                        /* Don't actually hangup here... */
                                        ast_queue_unhold(c);

Modified: team/kmoore/res_sip_threadpool_options/channels/chan_skinny.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/channels/chan_skinny.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/channels/chan_skinny.c (original)
+++ team/kmoore/res_sip_threadpool_options/channels/chan_skinny.c Fri Aug  2 
13:56:16 2013
@@ -4357,10 +4357,12 @@
                                l->label);
                        if (verbose) {
                                AST_LIST_TRAVERSE(&l->sub, sub, list) {
+                                       RAII_VAR(struct ast_channel *, bridged, 
ast_channel_bridge_peer(sub->owner), ao2_cleanup);
+
                                        ast_cli(fd, "  %s> %s to %s\n",
                                                (sub == l->activesub?"Active  
":"Inactive"),
                                                ast_channel_name(sub->owner),
-                                               
(ast_bridged_channel(sub->owner)?ast_channel_name(ast_bridged_channel(sub->owner)):"")
+                                               bridged ? 
ast_channel_name(bridged) : ""
                                        );
                                }
                        }
@@ -7170,6 +7172,8 @@
                }
 
                if ((sub && sub->owner) && (ast_channel_state(sub->owner) ==  
AST_STATE_UP)) {
+                       RAII_VAR(struct ast_channel *, bridged, NULL, 
ast_channel_cleanup);
+
                        c = sub->owner;
                        ast_channel_lock(c);
                        bridge_channel = ast_channel_get_bridge_channel(c);

Modified: team/kmoore/res_sip_threadpool_options/channels/sig_pri.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/channels/sig_pri.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/channels/sig_pri.c (original)
+++ team/kmoore/res_sip_threadpool_options/channels/sig_pri.c Fri Aug  2 
13:56:16 2013
@@ -7292,7 +7292,7 @@
 #if defined(HAVE_PRI_AOC_EVENTS)
                                                if 
(!pri->pvts[chanpos]->holding_aoce
                                                        && pri->aoce_delayhangup
-                                                       && 
ast_bridged_channel(pri->pvts[chanpos]->owner)) {
+                                                       && 
ast_channel_is_bridged(pri->pvts[chanpos]->owner)) {
                                                        
sig_pri_send_aoce_termination_request(pri, chanpos,
                                                                
pri_get_timer(pri->pri, PRI_TIMER_T305) / 2);
                                                } else if 
(detect_aoc_e_subcmd(e->hangup.subcmds)) {

Modified: team/kmoore/res_sip_threadpool_options/funcs/func_channel.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/funcs/func_channel.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/funcs/func_channel.c (original)
+++ team/kmoore/res_sip_threadpool_options/funcs/func_channel.c Fri Aug  2 
13:56:16 2013
@@ -495,10 +495,10 @@
                }
                ast_channel_unlock(chan);
        } else if (!strcasecmp(data, "peer")) {
-               struct ast_channel *p;
-
-               ast_channel_lock(chan);
-               p = ast_bridged_channel(chan);
+               RAII_VAR(struct ast_channel *, p, NULL, ast_channel_cleanup);
+
+               ast_channel_lock(chan);
+               p = ast_channel_bridge_peer(chan);
                if (p || ast_channel_tech(chan)) /* dummy channel? if so, we 
hid the peer name in the language */
                        ast_copy_string(buf, (p ? ast_channel_name(p) : ""), 
len);
                else {

Modified: team/kmoore/res_sip_threadpool_options/include/asterisk/astobj2.h
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/include/asterisk/astobj2.h?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/include/asterisk/astobj2.h (original)
+++ team/kmoore/res_sip_threadpool_options/include/asterisk/astobj2.h Fri Aug  
2 13:56:16 2013
@@ -1938,54 +1938,4 @@
 #endif
 void ao2_iterator_cleanup(struct ao2_iterator *iter);
 
-
-/* XXX TODO BUGBUG and all the other things...
- * These functions should eventually be moved elsewhere, but the utils folder
- * won't compile with them in strings.h
- */
-
-/*!
- * \since 12
- * \brief Allocates a hash container for bare strings
- *
- * \param buckets The number of buckets to use for the hash container
- *
- * \retval AO2 container for strings
- * \retval NULL if allocation failed
- */
-#define ast_str_container_alloc(buckets) 
ast_str_container_alloc_options(AO2_ALLOC_OPT_LOCK_MUTEX, buckets)
-
-/*!
- * \since 12
- * \brief Allocates a hash container for bare strings
- *
- * \param opts Options to be provided to the container
- * \param buckets The number of buckets to use for the hash container
- *
- * \retval AO2 container for strings
- * \retval NULL if allocation failed
- */
-struct ao2_container *ast_str_container_alloc_options(enum ao2_container_opts 
opts, int buckets);
-
-/*!
- * \since 12
- * \brief Adds a string to a string container allocated by 
ast_str_container_alloc
- *
- * \param str_container The container to which to add a string
- * \param add The string to add to the container
- *
- * \retval zero on success
- * \retval non-zero if the operation failed
- */
-int ast_str_container_add(struct ao2_container *str_container, const char 
*add);
-
-/*!
- * \since 12
- * \brief Removes a string from a string container allocated by 
ast_str_container_alloc
- *
- * \param str_container The container from which to remove a string
- * \param remove The string to remove from the container
- */
-void ast_str_container_remove(struct ao2_container *str_container, const char 
*remove);
-
 #endif /* _ASTERISK_ASTOBJ2_H */

Modified: team/kmoore/res_sip_threadpool_options/include/asterisk/channel.h
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/include/asterisk/channel.h?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/include/asterisk/channel.h (original)
+++ team/kmoore/res_sip_threadpool_options/include/asterisk/channel.h Fri Aug  
2 13:56:16 2013
@@ -2328,26 +2328,6 @@
  * \param chan Channel to masquerade
  */
 void ast_do_masquerade(struct ast_channel *chan);
-
-/*!
- * \brief Find bridged channel
- *
- * \note This function does _not_ return a reference to the bridged channel.
- * The reason for this is mostly historical.  It _should_ return a reference,
- * but it will take a lot of work to make the code base account for that.
- * So, for now, the old rules still apply for how to handle this function.
- * If this function is being used from the channel thread that owns the 
channel,
- * then a reference is already held, and channel locking is not required to
- * guarantee that the channel will stay around.  If this function is used
- * outside of the associated channel thread, the channel parameter 'chan'
- * MUST be locked before calling this function.  Also, 'chan' must remain 
locked
- * for the entire time that the result of this function is being used.
- *
- * \param chan Current channel
- *
- * \return A pointer to the bridged channel
-*/
-struct ast_channel *ast_bridged_channel(struct ast_channel *chan);
 
 /*!
  * \brief Inherits channel variable from parent to child channel

Modified: team/kmoore/res_sip_threadpool_options/include/asterisk/json.h
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/include/asterisk/json.h?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/include/asterisk/json.h (original)
+++ team/kmoore/res_sip_threadpool_options/include/asterisk/json.h Fri Aug  2 
13:56:16 2013
@@ -42,6 +42,37 @@
  * In the cases where you have a need to introduce intermediate objects, just
  * wrap them with json_ref() when passing them to other \c ast_json_*()
  * functions.
+ *
+ * \par Thread Safety
+ *
+ * Jansson (as of 2.4) provides fairly weak thread safety guarantees. The
+ * Asterisk wrapper improves upon that slightly. The remaining refcounting
+ * problems are issues when slicing/sharing/mixing instances between JSON
+ * objects and arrays, which we avoid.
+ *
+ * The \c ast_json_dump_* functions are thread safe for multiple concurrent
+ * dumps of the same object, so long as the concurrent dumps start from the 
same
+ * \c root object. But if an object is shared by other JSON objects/arrays, 
then
+ * concurrent dumps of the outer objects/arrays are not thread safe. This can 
be
+ * avoided by using ast_json_deep_copy() when sharing JSON instances between
+ * objects.
+ *
+ * The ast_json_ref() and ast_json_unref() functions are thread safe. Since the
+ * Asterisk wrapper exclusively uses the reference stealing API, Jansson won't
+ * be performing many refcount modifications behind our backs. There are a few
+ * exceptions.
+ *
+ * The first is the transitive json_decref() that occurs when \ref
+ * AST_JSON_OBJECT and \ref AST_JSON_ARRAY instances are deleted. This can be
+ * avoided by using ast_json_deep_copy() when sharing JSON instances between
+ * objects.
+ *
+ * The second is when using the reference borrowing specifier in
+ * ast_json_pack() (capital \c O). This can be avoided by using the reference
+ * stealing specifier (lowercase \c o) and wrapping the JSON object parameter
+ * with ast_json_ref() for an explicit ref-bump.
+ *
+ * \par Example code
  *
  * \code
  *     // Example of how to use the Asterisk JSON API
@@ -105,6 +136,20 @@
  * ast_free().
  */
 void ast_json_reset_alloc_funcs(void);
+
+/*!
+ * \brief Asterisk's custom JSON allocator. Exposed for use by unit tests.
+ * \since 12.0.0
+ * \internal
+ */
+void *ast_json_malloc(size_t size);
+
+/*!
+ * \brief Asterisk's custom JSON allocator. Exposed for use by unit tests.
+ * \since 12.0.0
+ * \internal
+ */
+void ast_json_free(void *p);
 
 /*!
  * \struct ast_json
@@ -683,13 +728,23 @@
        AST_JSON_PRETTY,
 };
 
+/*!
+ * \brief Encode a JSON value to a compact string.
+ * \since 12.0.0
+ *
+ * Returned string must be freed by calling ast_json_free().
+ *
+ * \param root JSON value.
+ * \return String encoding of \a root.
+ * \return \c NULL on error.
+ */
 #define ast_json_dump_string(root) ast_json_dump_string_format(root, 
AST_JSON_COMPACT)
 
 /*!
  * \brief Encode a JSON value to a string.
  * \since 12.0.0
  *
- * Returned string must be freed by calling ast_free().
+ * Returned string must be freed by calling ast_json_free().
  *
  * \param root JSON value.
  * \param format encoding format type.

Modified: team/kmoore/res_sip_threadpool_options/include/asterisk/parking.h
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/include/asterisk/parking.h?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/include/asterisk/parking.h (original)
+++ team/kmoore/res_sip_threadpool_options/include/asterisk/parking.h Fri Aug  
2 13:56:16 2013
@@ -45,6 +45,7 @@
        PARKED_CALL_GIVEUP,
        PARKED_CALL_UNPARKED,
        PARKED_CALL_FAILED,
+       PARKED_CALL_SWAP,
 };
 
 /*!

Modified: team/kmoore/res_sip_threadpool_options/include/asterisk/pickup.h
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/include/asterisk/pickup.h?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/include/asterisk/pickup.h (original)
+++ team/kmoore/res_sip_threadpool_options/include/asterisk/pickup.h Fri Aug  2 
13:56:16 2013
@@ -24,8 +24,8 @@
  *
  */
 
-#ifndef _AST_FEATURES_H
-#define _AST_FEATURES_H
+#ifndef _AST_PICKUP_H
+#define _AST_PICKUP_H
 
 /*!
  * \brief Test if a channel can be picked up.
@@ -88,4 +88,4 @@
  */
 int ast_pickup_init(void);
 
-#endif /* _AST_FEATURES_H */
+#endif /* _AST_PICKUP_H */

Modified: 
team/kmoore/res_sip_threadpool_options/include/asterisk/stasis_bridges.h
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/include/asterisk/stasis_bridges.h?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/include/asterisk/stasis_bridges.h 
(original)
+++ team/kmoore/res_sip_threadpool_options/include/asterisk/stasis_bridges.h 
Fri Aug  2 13:56:16 2013
@@ -215,8 +215,10 @@
  *
  * \param bridge The bridge a channel entered
  * \param chan The channel that entered the bridge
- */
-void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel 
*chan);
+ * \param swap The channel being swapped out of the bridge
+ */
+void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel 
*chan,
+               struct ast_channel *swap);
 
 /*!
  * \since 12

Modified: team/kmoore/res_sip_threadpool_options/include/asterisk/strings.h
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/include/asterisk/strings.h?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/include/asterisk/strings.h (original)
+++ team/kmoore/res_sip_threadpool_options/include/asterisk/strings.h Fri Aug  
2 13:56:16 2013
@@ -29,6 +29,7 @@
 
 #include "asterisk/utils.h"
 #include "asterisk/threadstorage.h"
+#include "asterisk/astobj2.h"
 
 #if defined(DEBUG_OPAQUE)
 #define __AST_STR_USED used2
@@ -1109,4 +1110,48 @@
        return str_orig;
 }
 
+/*!
+ * \since 12
+ * \brief Allocates a hash container for bare strings
+ *
+ * \param buckets The number of buckets to use for the hash container
+ *
+ * \retval AO2 container for strings
+ * \retval NULL if allocation failed
+ */
+#define ast_str_container_alloc(buckets) 
ast_str_container_alloc_options(AO2_ALLOC_OPT_LOCK_MUTEX, buckets)
+
+/*!
+ * \since 12
+ * \brief Allocates a hash container for bare strings
+ *
+ * \param opts Options to be provided to the container
+ * \param buckets The number of buckets to use for the hash container
+ *
+ * \retval AO2 container for strings
+ * \retval NULL if allocation failed
+ */
+struct ao2_container *ast_str_container_alloc_options(enum ao2_container_opts 
opts, int buckets);
+
+/*!
+ * \since 12
+ * \brief Adds a string to a string container allocated by 
ast_str_container_alloc
+ *
+ * \param str_container The container to which to add a string
+ * \param add The string to add to the container
+ *
+ * \retval zero on success
+ * \retval non-zero if the operation failed
+ */
+int ast_str_container_add(struct ao2_container *str_container, const char 
*add);
+
+/*!
+ * \since 12
+ * \brief Removes a string from a string container allocated by 
ast_str_container_alloc
+ *
+ * \param str_container The container from which to remove a string
+ * \param remove The string to remove from the container
+ */
+void ast_str_container_remove(struct ao2_container *str_container, const char 
*remove);
+
 #endif /* _ASTERISK_STRINGS_H */

Modified: team/kmoore/res_sip_threadpool_options/main/astobj2.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/main/astobj2.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/main/astobj2.c (original)
+++ team/kmoore/res_sip_threadpool_options/main/astobj2.c Fri Aug  2 13:56:16 
2013
@@ -5797,40 +5797,3 @@
        return 0;
 }
 
-/* XXX TODO BUGBUG and all the other things...
- * These functions should eventually be moved elsewhere, but the utils folder
- * won't compile with them in strings.h
- */
-static int str_hash(const void *obj, const int flags)
-{
-       return ast_str_hash(obj);
-}
-
-static int str_cmp(void *lhs, void *rhs, int flags)
-{
-       return strcmp(lhs, rhs) ? 0 : CMP_MATCH;
-}
-
-struct ao2_container *ast_str_container_alloc_options(enum ao2_container_opts 
opts, int buckets)
-{
-       return ao2_container_alloc_options(opts, buckets, str_hash, str_cmp);
-}
-
-int ast_str_container_add(struct ao2_container *str_container, const char *add)
-{
-       RAII_VAR(char *, ao2_add, ao2_alloc(strlen(add) + 1, NULL), 
ao2_cleanup);
-
-       if (!ao2_add) {
-               return -1;
-       }
-
-       /* safe strcpy */
-       strcpy(ao2_add, add);
-       ao2_link(str_container, ao2_add);
-       return 0;
-}
-
-void ast_str_container_remove(struct ao2_container *str_container, const char 
*remove)
-{
-       ao2_find(str_container, remove, OBJ_KEY | OBJ_NODATA | OBJ_UNLINK);
-}

Modified: team/kmoore/res_sip_threadpool_options/main/bridge_channel.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/main/bridge_channel.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/main/bridge_channel.c (original)
+++ team/kmoore/res_sip_threadpool_options/main/bridge_channel.c Fri Aug  2 
13:56:16 2013
@@ -1429,7 +1429,7 @@
                bridge->v_table->name,
                bridge->uniqueid);
 
-       ast_bridge_publish_enter(bridge, bridge_channel->chan);
+       ast_bridge_publish_enter(bridge, bridge_channel->chan, swap ? 
swap->chan : NULL);
        if (swap) {
                ast_bridge_channel_leave_bridge(swap, 
BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
                bridge_channel_internal_pull(swap);

Modified: team/kmoore/res_sip_threadpool_options/main/cel.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/main/cel.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/main/cel.c (original)
+++ team/kmoore/res_sip_threadpool_options/main/cel.c Fri Aug  2 13:56:16 2013
@@ -638,7 +638,7 @@
                struct ast_json *extra, const char *peer_name)
 {
        struct timeval eventtime = ast_tvnow();
-       RAII_VAR(char *, extra_txt, NULL, ast_free);
+       RAII_VAR(char *, extra_txt, NULL, ast_json_free);
        if (extra) {
                extra_txt = ast_json_dump_string(extra);
        }
@@ -1304,6 +1304,9 @@
        case PARKED_CALL_FAILED:
                reason = "ParkedCallFailed";
                break;
+       case PARKED_CALL_SWAP:
+               reason = "ParkedCallSwap";
+               break;
        }
 
        extra = ast_json_pack("{s: s}", "reason", reason);

Modified: team/kmoore/res_sip_threadpool_options/main/channel.c
URL: 
http://svnview.digium.com/svn/asterisk/team/kmoore/res_sip_threadpool_options/main/channel.c?view=diff&rev=396151&r1=396150&r2=396151
==============================================================================
--- team/kmoore/res_sip_threadpool_options/main/channel.c (original)
+++ team/kmoore/res_sip_threadpool_options/main/channel.c Fri Aug  2 13:56:16 
2013
@@ -2606,15 +2606,11 @@
 
 void ast_set_hangupsource(struct ast_channel *chan, const char *source, int 
force)
 {
-       struct ast_channel *bridge;
+       RAII_VAR(struct ast_channel *, bridge, ast_channel_bridge_peer(chan), 
ast_channel_cleanup);
 
        ast_channel_lock(chan);
        if (force || ast_strlen_zero(ast_channel_hangupsource(chan))) {

[... 4336 lines stripped ...]

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits

Reply via email to