Author: rizzo
Date: Sat Jul 28 11:20:44 2007
New Revision: 77646

URL: http://svn.digium.com/view/asterisk?view=rev&rev=77646
Log:
diff reduction wrt trunk

Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: 
http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=77646&r1=77645&r2=77646
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Sat Jul 28 11:20:44 2007
@@ -1190,6 +1190,7 @@
 /*!
  * when we create or delete references, make sure to use these
  * functions so we keep track of the refcounts.
+ * To simplify the code, we allow a NULL to be passed to dialog_unref().
  */
 static struct sip_pvt *dialog_ref(struct sip_pvt *p)
 {
@@ -1199,7 +1200,8 @@
 
 static struct sip_pvt *dialog_unref(struct sip_pvt *p)
 {
-       ao2_ref(p, -1);
+       if (p)
+               ao2_ref(p, -1);
        return NULL;
 }
 
@@ -3959,8 +3961,7 @@
                ast_clear_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER);        
/* Really hang up next time */
                p->needdestroy = 0;
                /* XXX assert(p->owner == ast); */
-               if (p->owner->tech_pvt) /* i believe that's always */
-                       p->owner->tech_pvt = dialog_unref(p->owner->tech_pvt);
+               p->owner->tech_pvt = dialog_unref(p->owner->tech_pvt);
                p->owner = NULL;  /* Owner will be gone after we return, so 
take it away */
                return 0;
        }
@@ -3997,8 +3998,7 @@
                ast_dsp_free(p->vad);
 
        p->owner = NULL;
-       if (ast->tech_pvt)
-               ast->tech_pvt = dialog_unref(ast->tech_pvt);
+       ast->tech_pvt = dialog_unref(ast->tech_pvt);
 
        ast_module_unref(ast_module_info->self);
        /* Do not destroy this pvt until we have timeout or
@@ -5044,14 +5044,13 @@
        }
        ast_string_field_set(p, context, default_context);
 
-       dialog_ref(p);  /* prepare to return a reference */
        /* Add to active dialog list */
 #ifdef USE_AO2
-       ao2_link(dialogs, p);
+       ao2_link(dialogs, dialog_ref(p));
 #else
        dialoglist_lock();
        p->next = dialoglist;
-       dialoglist = p;
+       dialoglist = dialog_ref(p);
        dialoglist_unlock();
 #endif
        ast_debug(1, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? 
callid : "(No Call-ID)", sip_methods[intended_method].text, p->rtp ? "With RTP" 
: "No RTP");
@@ -8378,8 +8377,7 @@
 {
        if (!p->refer)
                return;
-       if (p->refer->refer_call)
-               p->refer->refer_call = dialog_unref(p->refer->refer_call);
+       p->refer->refer_call = dialog_unref(p->refer->refer_call);
        ast_free(p->refer);
        p->refer = NULL;
 }
@@ -9900,8 +9898,7 @@
                ast_copy_string(referdata->refer_to, c, 
sizeof(referdata->refer_to));
                ast_copy_string(referdata->referred_by, "", 
sizeof(referdata->referred_by));
                ast_copy_string(referdata->refer_contact, "", 
sizeof(referdata->refer_contact));
-               if (referdata->refer_call)
-                       referdata->refer_call = 
dialog_unref(referdata->refer_call);
+               referdata->refer_call = dialog_unref(referdata->refer_call);
                /* Set new context */
                ast_string_field_set(p, context, transfer_context);
                return 0;
@@ -13580,8 +13577,7 @@
 
        peer->lastms = pingtime;
        /* XXX do we need to unlink too ? */
-       if (peer->call)
-               peer->call = dialog_unref(peer->call);
+       peer->call = dialog_unref(peer->call);
        if (statechanged) {
                const char *s = is_reachable ? "Reachable" : "Lagged";
 
@@ -14588,8 +14584,7 @@
         * do we need to destroy it or what ?
         * And why do we reset it before calling hangup ?
         */
-       if (c->tech_pvt)
-               c->tech_pvt = dialog_unref(c->tech_pvt);
+       c->tech_pvt = dialog_unref(c->tech_pvt);
        ast_hangup(c);
        return 0;
 }


_______________________________________________
--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