Merge "configure: Fix check for libunbound to require v1.5.0 as minimum."
authorJoshua Colp <jcolp@digium.com>
Fri, 9 Oct 2015 17:08:29 +0000 (12:08 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Fri, 9 Oct 2015 17:08:29 +0000 (12:08 -0500)
channels/chan_pjsip.c
res/res_pjsip.c
res/res_pjsip_caller_id.c

index 523a015..d72a25b 100644 (file)
@@ -2134,7 +2134,8 @@ static int chan_pjsip_incoming_request(struct ast_sip_session *session, struct p
                return 0;
        }
 
-       if (session->inv_session->state >= PJSIP_INV_STATE_CONFIRMED) {
+       /* Check for a to-tag to determine if this is a reinvite */
+       if (rdata->msg_info.to->tag.slen) {
                /* Weird case. We've received a reinvite but we don't have a channel. The most
                 * typical case for this happening is that a blind transfer fails, and so the
                 * transferer attempts to reinvite himself back into the call. We already got
@@ -2181,8 +2182,9 @@ static int call_pickup_incoming_request(struct ast_sip_session *session, pjsip_r
        struct ast_features_pickup_config *pickup_cfg;
        struct ast_channel *chan;
 
-       /* We don't care about reinvites */
-       if (session->inv_session->state >= PJSIP_INV_STATE_CONFIRMED) {
+       /* Check for a to-tag to determine if this is a reinvite */
+       if (rdata->msg_info.to->tag.slen) {
+               /* We don't care about reinvites */
                return 0;
        }
 
@@ -2229,8 +2231,9 @@ static int pbx_start_incoming_request(struct ast_sip_session *session, pjsip_rx_
 {
        int res;
 
-       /* We don't care about reinvites */
-       if (session->inv_session->state >= PJSIP_INV_STATE_CONFIRMED) {
+       /* Check for a to-tag to determine if this is a reinvite */
+       if (rdata->msg_info.to->tag.slen) {
+               /* We don't care about reinvites */
                return 0;
        }
 
index 3e93b6f..5fc5990 100644 (file)
@@ -2958,8 +2958,6 @@ struct send_request_wrapper {
        pj_timer_entry *timeout_timer;
        /*! Original timeout. */
        pj_int32_t timeout;
-       /*! Timeout/cleanup lock. */
-       pj_mutex_t *lock;
        /*! The transmit data. */
        pjsip_tx_data *tdata;
 };
@@ -2985,7 +2983,7 @@ static void endpt_send_request_cb(void *token, pjsip_event *e)
                ast_debug(2, "%p: PJSIP tsx response received\n", req_wrapper);
        }
 
-       pj_mutex_lock(req_wrapper->lock);
+       ao2_lock(req_wrapper);
 
        /* It's possible that our own timer was already processing while
         * we were waiting on the lock so check the timer id.  If it's
@@ -3026,7 +3024,7 @@ static void endpt_send_request_cb(void *token, pjsip_event *e)
                req_wrapper->cb_called = 1;
                ast_debug(2, "%p: Callbacks executed\n", req_wrapper);
        }
-       pj_mutex_unlock(req_wrapper->lock);
+       ao2_unlock(req_wrapper);
        ao2_ref(req_wrapper, -1);
 }
 
@@ -3043,12 +3041,12 @@ static void send_request_timer_callback(pj_timer_heap_t *theap, pj_timer_entry *
        ast_debug(2, "%p: Internal tsx timer expired after %d msec\n",
                req_wrapper, req_wrapper->timeout);
 
-       pj_mutex_lock(req_wrapper->lock);
+       ao2_lock(req_wrapper);
        /* If the id is not TIMEOUT_TIMER2 then the timer was cancelled above
         * while the lock was being held so just clean up.
         */
        if (entry->id != TIMEOUT_TIMER2) {
-               pj_mutex_unlock(req_wrapper->lock);
+               ao2_unlock(req_wrapper);
                ast_debug(3, "%p: Timeout already handled\n", req_wrapper);
                ao2_ref(req_wrapper, -1);
                return;
@@ -3066,7 +3064,7 @@ static void send_request_timer_callback(pj_timer_heap_t *theap, pj_timer_entry *
                ast_debug(2, "%p: Callbacks executed\n", req_wrapper);
        }
 
-       pj_mutex_unlock(req_wrapper->lock);
+       ao2_unlock(req_wrapper);
        ao2_ref(req_wrapper, -1);
 }
 
@@ -3074,7 +3072,6 @@ static void send_request_wrapper_destructor(void *obj)
 {
        struct send_request_wrapper *req_wrapper = obj;
 
-       pj_mutex_destroy(req_wrapper->lock);
        pjsip_tx_data_dec_ref(req_wrapper->tdata);
        ast_debug(2, "%p: wrapper destroyed\n", req_wrapper);
 }
@@ -3087,8 +3084,7 @@ static pj_status_t endpt_send_request(struct ast_sip_endpoint *endpoint,
        pjsip_endpoint *endpt = ast_sip_get_pjsip_endpoint();
 
        /* Create wrapper to detect if the callback was actually called on an error. */
-       req_wrapper = ao2_alloc_options(sizeof(*req_wrapper), send_request_wrapper_destructor,
-               AO2_ALLOC_OPT_LOCK_NOLOCK);
+       req_wrapper = ao2_alloc(sizeof(*req_wrapper), send_request_wrapper_destructor);
        if (!req_wrapper) {
                pjsip_tx_data_dec_ref(tdata);
                return PJ_ENOMEM;
@@ -3100,25 +3096,11 @@ static pj_status_t endpt_send_request(struct ast_sip_endpoint *endpoint,
        req_wrapper->callback = cb;
        req_wrapper->timeout = timeout;
        req_wrapper->timeout_timer = NULL;
-       req_wrapper->lock = NULL;
        req_wrapper->tdata = tdata;
        /* Add a reference to tdata.  The wrapper destructor cleans it up. */
        pjsip_tx_data_add_ref(tdata);
 
-       ret_val = pj_mutex_create_simple(tdata->pool, "tsx_timeout", &req_wrapper->lock);
-       if (ret_val != PJ_SUCCESS) {
-               char errmsg[PJ_ERR_MSG_SIZE];
-               pj_strerror(ret_val, errmsg, sizeof(errmsg));
-               ast_log(LOG_ERROR, "Error %d '%s' sending %.*s request to endpoint %s\n",
-                       (int) ret_val, errmsg, (int) pj_strlen(&tdata->msg->line.req.method.name),
-                       pj_strbuf(&tdata->msg->line.req.method.name),
-                       endpoint ? ast_sorcery_object_get_id(endpoint) : "<unknown>");
-               pjsip_tx_data_dec_ref(tdata);
-               ao2_ref(req_wrapper, -1);
-               return PJ_ENOMEM;
-       }
-
-       pj_mutex_lock(req_wrapper->lock);
+       ao2_lock(req_wrapper);
 
        if (timeout > 0) {
                pj_time_val timeout_timer_val = { timeout / 1000, timeout % 1000 };
@@ -3180,7 +3162,7 @@ static pj_status_t endpt_send_request(struct ast_sip_endpoint *endpoint,
                        ao2_ref(req_wrapper, -1);
                }
        }
-       pj_mutex_unlock(req_wrapper->lock);
+       ao2_unlock(req_wrapper);
        ao2_ref(req_wrapper, -1);
        return ret_val;
 }
index c084a81..07b1266 100644 (file)
@@ -351,10 +351,11 @@ static void update_incoming_connected_line(struct ast_sip_session *session, pjsi
  */
 static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
 {
-       if (session->inv_session->state < PJSIP_INV_STATE_CONFIRMED) {
+       if (!session->channel) {
                /*
-                * Initial inbound INVITE.  Set the session ID directly
-                * because the channel has not been created yet.
+                * Since we have no channel this must be the initial inbound
+                * INVITE.  Set the session ID directly because the channel
+                * has not been created yet.
                 */
                if (session->endpoint->id.trust_inbound
                        && (!set_id_from_pai(rdata, &session->id)
@@ -367,9 +368,10 @@ static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_
                if (!session->endpoint->id.self.number.valid) {
                        set_id_from_from(rdata, &session->id);
                }
-       } else if (session->channel) {
-               /* Reinvite. Check for changes to the ID and queue a connected line
-                * update if necessary
+       } else {
+               /*
+                * ReINVITE or UPDATE.  Check for changes to the ID and queue
+                * a connected line update if necessary.
                 */
                update_incoming_connected_line(session, rdata);
        }