[asterisk-commits] file: trunk r48565 - in /trunk: ./
channels/chan_iax2.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Dec 18 10:18:19 MST 2006
Author: file
Date: Mon Dec 18 11:18:18 2006
New Revision: 48565
URL: http://svn.digium.com/view/asterisk?view=rev&rev=48565
Log:
Merged revisions 48564 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r48564 | file | 2006-12-18 12:15:49 -0500 (Mon, 18 Dec 2006) | 2 lines
Put thread into proper list if we abort handling due to an error, and also hold the lock while putting it back into the proper idle list so we don't prematurely get a signal. (issue #8604 reported by arkadia)
........
Modified:
trunk/ (props changed)
trunk/channels/chan_iax2.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=48565&r1=48564&r2=48565
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Mon Dec 18 11:18:18 2006
@@ -870,6 +870,21 @@
.transfer = iax2_transfer,
.fixup = iax2_fixup,
};
+
+static void insert_idle_thread(struct iax2_thread *thread)
+{
+ if (thread->type == IAX_THREAD_TYPE_DYNAMIC) {
+ AST_LIST_LOCK(&dynamic_list);
+ AST_LIST_INSERT_TAIL(&dynamic_list, thread, list);
+ AST_LIST_UNLOCK(&dynamic_list);
+ } else {
+ AST_LIST_LOCK(&idle_list);
+ AST_LIST_INSERT_TAIL(&idle_list, thread, list);
+ AST_LIST_UNLOCK(&idle_list);
+ }
+
+ return;
+}
static struct iax2_thread *find_idle_thread(void)
{
@@ -6261,15 +6276,11 @@
if (errno != ECONNREFUSED && errno != EAGAIN)
ast_log(LOG_WARNING, "Error: %s\n", strerror(errno));
handle_error();
- AST_LIST_LOCK(&idle_list);
- AST_LIST_INSERT_TAIL(&idle_list, thread, list);
- AST_LIST_UNLOCK(&idle_list);
+ insert_idle_thread(thread);
return 1;
}
if (test_losspct && ((100.0 * ast_random() / (RAND_MAX + 1.0)) < test_losspct)) { /* simulate random loss condition */
- AST_LIST_LOCK(&idle_list);
- AST_LIST_INSERT_TAIL(&idle_list, thread, list);
- AST_LIST_UNLOCK(&idle_list);
+ insert_idle_thread(thread);
return 1;
}
/* Mark as ready and send on its way */
@@ -7666,10 +7677,16 @@
struct iax2_thread *thread = data;
struct timeval tv;
struct timespec ts;
+ int put_into_idle = 0;
for(;;) {
/* Wait for something to signal us to be awake */
ast_mutex_lock(&thread->lock);
+
+ /* Put into idle list if applicable */
+ if (put_into_idle)
+ insert_idle_thread(thread);
+
if (thread->type == IAX_THREAD_TYPE_DYNAMIC) {
/* Wait to be signalled or time out */
tv = ast_tvadd(ast_tvnow(), ast_samp2tv(30000, 1000));
@@ -7720,16 +7737,7 @@
AST_LIST_REMOVE(&active_list, thread, list);
AST_LIST_UNLOCK(&active_list);
- /* Go back into our respective list */
- if (thread->type == IAX_THREAD_TYPE_DYNAMIC) {
- AST_LIST_LOCK(&dynamic_list);
- AST_LIST_INSERT_TAIL(&dynamic_list, thread, list);
- AST_LIST_UNLOCK(&dynamic_list);
- } else {
- AST_LIST_LOCK(&idle_list);
- AST_LIST_INSERT_TAIL(&idle_list, thread, list);
- AST_LIST_UNLOCK(&idle_list);
- }
+ put_into_idle = 1;
}
return NULL;
More information about the asterisk-commits
mailing list