Merge "pjsip_options: Fix non-qualified contacts showing as unavailable"
authorJoshua Colp <jcolp@digium.com>
Mon, 20 Apr 2015 22:24:04 +0000 (17:24 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Mon, 20 Apr 2015 22:24:04 +0000 (17:24 -0500)
include/asterisk/threadstorage.h
main/pbx.c
res/res_fax.c
res/res_pjsip/pjsip_options.c

index 4d587a5..4e61f42 100644 (file)
@@ -64,6 +64,9 @@ struct ast_threadstorage {
 void __ast_threadstorage_object_add(void *key, size_t len, const char *file, const char *function, unsigned int line);
 void __ast_threadstorage_object_remove(void *key);
 void __ast_threadstorage_object_replace(void *key_old, void *key_new, size_t len);
+#define THREADSTORAGE_RAW_CLEANUP(v) {}
+#else
+#define THREADSTORAGE_RAW_CLEANUP NULL
 #endif /* defined(DEBUG_THREADLOCALS) */
 
 /*!
@@ -85,7 +88,7 @@ void __ast_threadstorage_object_replace(void *key_old, void *key_new, size_t len
 #define AST_THREADSTORAGE_EXTERNAL(name) \
        extern struct ast_threadstorage name
 #define AST_THREADSTORAGE_RAW(name) \
-       AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, NULL,)
+       AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, THREADSTORAGE_RAW_CLEANUP,)
 
 /*!
  * \brief Define a thread storage variable, with custom initialization and cleanup
index 209de66..fee4191 100644 (file)
@@ -10735,6 +10735,16 @@ void __ast_context_destroy(struct ast_context *list, struct ast_hashtab *context
                                exten_iter = ast_hashtab_start_traversal(tmp->root_table);
                                while ((exten_item=ast_hashtab_next(exten_iter))) {
                                        int end_traversal = 1;
+
+                                       /*
+                                        * If the extension could not be removed from the root_table due to
+                                        * a loaded PBX app, it can exist here but have its peer_table be
+                                        * destroyed due to a previous pass through this function.
+                                        */
+                                       if (!exten_item->peer_table) {
+                                               continue;
+                                       }
+
                                        prio_iter = ast_hashtab_start_traversal(exten_item->peer_table);
                                        while ((prio_item=ast_hashtab_next(prio_iter))) {
                                                char extension[AST_MAX_EXTENSION];
index c57f446..39cb3b3 100644 (file)
@@ -3291,13 +3291,13 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct
 
                if (gateway->bridged) {
                        ast_set_read_format(chan, gateway->chan_read_format);
-                       ast_set_read_format(chan, gateway->chan_write_format);
+                       ast_set_write_format(chan, gateway->chan_write_format);
 
                        ast_channel_unlock(chan);
                        peer = ast_channel_bridge_peer(chan);
                        if (peer) {
                                ast_set_read_format(peer, gateway->peer_read_format);
-                               ast_set_read_format(peer, gateway->peer_write_format);
+                               ast_set_write_format(peer, gateway->peer_write_format);
                                ast_channel_make_compatible(chan, peer);
                        }
                        ast_channel_lock(chan);
@@ -3340,23 +3340,25 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct
                        gateway->timeout_start = ast_tvnow();
                }
 
+               ast_channel_unlock(chan);
+               ast_channel_lock_both(chan, peer);
+
                /* we are bridged, change r/w formats to SLIN for v21 preamble
                 * detection and T.30 */
                ao2_replace(gateway->chan_read_format, ast_channel_readformat(chan));
-               ao2_replace(gateway->chan_write_format, ast_channel_readformat(chan));
+               ao2_replace(gateway->chan_write_format, ast_channel_writeformat(chan));
 
                ao2_replace(gateway->peer_read_format, ast_channel_readformat(peer));
-               ao2_replace(gateway->peer_write_format, ast_channel_readformat(peer));
+               ao2_replace(gateway->peer_write_format, ast_channel_writeformat(peer));
 
                ast_set_read_format(chan, ast_format_slin);
                ast_set_write_format(chan, ast_format_slin);
 
-               ast_channel_unlock(chan);
                ast_set_read_format(peer, ast_format_slin);
                ast_set_write_format(peer, ast_format_slin);
 
-               ast_channel_make_compatible(chan, peer);
-               ast_channel_lock(chan);
+               ast_channel_unlock(peer);
+
                gateway->bridged = 1;
        }
 
index 692cbdb..40b6f7b 100644 (file)
@@ -148,7 +148,7 @@ static void update_contact_status(const struct ast_sip_contact *contact,
        ast_test_suite_event_notify("AOR_CONTACT_QUALIFY_RESULT",
                "Contact: %s\r\n"
                        "Status: %s\r\n"
-                       "RTT: %ld",
+                       "RTT: %" PRId64,
                ast_sorcery_object_get_id(update),
                ast_sip_get_contact_status_label(update->status),
                update->rtt);