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) */
/*!
#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
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];
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);
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;
}