Merge branch 'rpc_async'
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 18 Sep 2009 11:16:26 +0000 (13:16 +0200)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 18 Sep 2009 11:16:26 +0000 (13:16 +0200)
* rpc_async:
  tm: async t_uac (t_uac_wait) support
  xmlrpc(s): basic support for delayed replies
  core: rpc capabilities and delayed reply api
  core+tm: moved sip msg clone functions to the core

1  2 
modules/tm/h_table.c
modules/tm/t_fwd.c

diff --combined modules/tm/h_table.c
@@@ -63,7 -63,7 +63,7 @@@
  #include "t_cancel.h"
  #include "t_stats.h"
  #include "h_table.h"
- #include "fix_lumps.h" /* free_via_clen_lump */
+ #include "../../fix_lumps.h" /* free_via_clen_lump */
  #include "timer.h"
  #include "uac.h" /* free_local_ack */
  
@@@ -142,13 -142,7 +142,13 @@@ void free_cell( struct cell* dead_cell 
                cbs_tmp = cbs;
                cbs = cbs->next;
                if (cbs_tmp->release) {
 +                      /* It is safer to release the shm memory lock
 +                       * otherwise the release function must to be aware of
 +                       * the lock state (Miklos)
 +                       */
 +                      shm_unlock();
                        cbs_tmp->release(cbs_tmp->param);
 +                      shm_lock();
                }
                shm_free_unsafe( cbs_tmp );
        }
@@@ -272,7 -266,6 +272,7 @@@ struct cell*  build_cell( struct sip_ms
        struct cell* new_cell;
        int          sip_msg_len;
        avp_list_t* old;
 +      struct tm_callback *cbs, *cbs_tmp;
  
        /* allocs a new cell */
        /* if syn_branch==0 add space for md5 (MD5_LEN -sizeof(struct cell.md5)) */
        return new_cell;
  
  error:
 +      /* Other modules may have already registered some
 +       * transaction callbacks and may also allocated
 +       * additional memory for their parameters,
 +       * hence TMCB_DESTROY needs to be called. (Miklos)
 +       */
 +      if (unlikely(has_tran_tmcbs(new_cell, TMCB_DESTROY)))
 +              run_trans_callbacks(TMCB_DESTROY, new_cell, 0, 0, 0);
 +
 +      /* free the callback list */
 +      for( cbs=(struct tm_callback*)new_cell->tmcb_hl.first ; cbs ; ) {
 +              cbs_tmp = cbs;
 +              cbs = cbs->next;
 +              if (cbs_tmp->release) {
 +                      cbs_tmp->release(cbs_tmp->param);
 +              }
 +              shm_free( cbs_tmp );
 +      }
 +      
        destroy_avp_list(&new_cell->user_avps_from);
        destroy_avp_list(&new_cell->user_avps_to);
        destroy_avp_list(&new_cell->uri_avps_from);
diff --combined modules/tm/t_fwd.c
  #include "t_cancel.h"
  #include "t_lookup.h"
  #include "t_fwd.h"
- #include "fix_lumps.h"
+ #include "../../fix_lumps.h"
  #include "config.h"
  #ifdef USE_DNS_FAILOVER
  #include "../../dns_cache.h"
@@@ -413,8 -413,6 +413,8 @@@ int add_uac( struct cell *t, struct sip
                t->uac[branch].request.dst.send_sock =
                get_send_socket( request, &t->uac[branch].request.dst.to,
                                                                t->uac[branch].request.dst.proto);
 +              t->uac[branch].request.dst.send_flags=request?
 +                                                                                              request->fwd_send_flags:0;
        }else {
  #ifdef USE_DNS_FAILOVER
                if (uri2dst(&t->uac[branch].dns_h, &t->uac[branch].request.dst,
@@@ -1085,16 -1083,15 +1085,16 @@@ int t_forward_nonack( struct cell *t, s
        } else try_new=0;
  
        init_branch_iterator();
 -      while((current_uri.s=next_branch( &current_uri.len, &q, &dst_uri.s, &dst_uri.len, &si))) {
 +      while((current_uri.s=next_branch( &current_uri.len, &q, &dst_uri.s,
 +                                                                              &dst_uri.len, &si))) {
                try_new++;
                p_msg->force_send_socket = si;
                getbflagsval(get_branch_iterator(), &bflags);
                setbflagsval(0, bflags);
  
                branch_ret=add_uac( t, p_msg, &current_uri, 
 -                                  (dst_uri.len) ? (&dst_uri) : &current_uri, 
 -                                  proxy, proto);
 +                                                      (dst_uri.len) ? (&dst_uri) : &current_uri, 
 +                                                      proxy, proto);
                /* pick some of the errors in case things go wrong;
                   note that picking lowest error is just as good as
                   any other algorithm which picks any other negative