Merge "main/pbx: Don't attempt to destroy a previously destroyed exten/priority tuple"
authorMatt Jordan <mjordan@digium.com>
Mon, 20 Apr 2015 11:30:03 +0000 (06:30 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Mon, 20 Apr 2015 11:30:03 +0000 (06:30 -0500)
include/asterisk/threadstorage.h
res/res_fax.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 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;
        }