[svn-commits] tilghman: trunk r277484 - in /trunk: include/asterisk/sched.h main/sched.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 16 15:35:31 CDT 2010


Author: tilghman
Date: Fri Jul 16 15:35:28 2010
New Revision: 277484

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=277484
Log:
Finally, a method that really fixes the assertions in chan_iax2.c related to cancelling lagid.

No, replacing usleep(1) with sched_yield() did not have an effect.

Modified:
    trunk/include/asterisk/sched.h
    trunk/main/sched.c

Modified: trunk/include/asterisk/sched.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/sched.h?view=diff&rev=277484&r1=277483&r2=277484
==============================================================================
--- trunk/include/asterisk/sched.h (original)
+++ trunk/include/asterisk/sched.h Fri Jul 16 15:35:28 2010
@@ -53,7 +53,7 @@
 		int _count = 0; \
 		int _sched_res = -1; \
 		while (id > -1 && (_sched_res = ast_sched_del(sched, id)) && ++_count < 10) \
-			usleep(1); \
+			usleep(1000); \
 		if (_count == 10 && option_debug > 2) { \
 			ast_log(LOG_DEBUG, "Unable to cancel schedule ID %d.\n", id); \
 		} \
@@ -70,7 +70,7 @@
 	do { \
 		int _count = 0; \
 		while (id > -1 && ast_sched_del(sched, id) && ++_count < 10) { \
-			usleep(1); \
+			usleep(1000); \
 		} \
 		if (_count == 10) \
 			ast_log(LOG_WARNING, "Unable to cancel schedule ID %d.  This is probably a bug (%s: %s, line %d).\n", id, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
@@ -89,7 +89,7 @@
 		int _sched_res = -1; \
 		while (id > -1 && (_sched_res = ast_sched_del(sched, id)) && ++_count < 10) { \
 			ast_mutex_unlock(lock); \
-			usleep(1); \
+			usleep(1000); \
 			ast_mutex_lock(lock); \
 		} \
 		if (_count == 10 && option_debug > 2) { \
@@ -103,7 +103,7 @@
 	do { \
 		int _count = 0; \
 		while (id > -1 && ast_sched_del(sched, id) && ++_count < 10) { \
-			usleep(1); \
+			usleep(1000); \
 		} \
 		if (_count == 10) \
 			ast_log(LOG_WARNING, "Unable to cancel schedule ID %d.  This is probably a bug (%s: %s, line %d).\n", id, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
@@ -122,7 +122,7 @@
 		int _count = 0, _res=1;											 \
 		void *_data = (void *)ast_sched_find_data(sched, id);			\
 		while (id > -1 && (_res = ast_sched_del(sched, id) && _count++ < 10)) { \
-			usleep(1); \
+			usleep(1000); \
 		} \
 		if (!_res && _data)							\
 			unrefcall;	/* should ref _data! */		\

Modified: trunk/main/sched.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/sched.c?view=diff&rev=277484&r1=277483&r2=277484
==============================================================================
--- trunk/main/sched.c (original)
+++ trunk/main/sched.c Fri Jul 16 15:35:28 2010
@@ -46,6 +46,9 @@
 #include "asterisk/dlinkedlists.h"
 #include "asterisk/hashtab.h"
 #include "asterisk/heap.h"
+#include "asterisk/threadstorage.h"
+
+AST_THREADSTORAGE(last_del_id);
 
 struct sched {
 	AST_LIST_ENTRY(sched) list;
@@ -450,7 +453,7 @@
 		return res->data;
 	return NULL;
 }
-	
+
 /*! \brief
  * Delete the schedule entry with number
  * "id".  It's nearly impossible that there
@@ -466,9 +469,14 @@
 	struct sched *s, tmp = {
 		.id = id,
 	};
+	int *last_id = ast_threadstorage_get(&last_del_id, sizeof(int *));
 
 	DEBUG(ast_debug(1, "ast_sched_del(%d)\n", id));
-	
+
+	if (id < 0) {
+		return 0;
+	}
+
 	ast_mutex_lock(&con->lock);
 	s = ast_hashtab_lookup(con->schedq_ht, &tmp);
 	if (s) {
@@ -484,7 +492,7 @@
 
 		sched_release(con, s);
 	}
-	
+
 #ifdef DUMP_SCHEDULER
 	/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
 	if (option_debug)
@@ -492,16 +500,23 @@
 #endif
 	ast_mutex_unlock(&con->lock);
 
-	if (!s) {
+	if (!s && *last_id != id) {
 		ast_debug(1, "Attempted to delete nonexistent schedule entry %d!\n", id);
 #ifndef AST_DEVMODE
 		ast_assert(s != NULL);
 #else
-		_ast_assert(0, "s != NULL", file, line, function);
-#endif
+		{
+		char buf[100];
+		snprintf(buf, sizeof(buf), "s != NULL, id=%d", id);
+		_ast_assert(0, buf, file, line, function);
+		}
+#endif
+		*last_id = id;
 		return -1;
-	}
-	
+	} else if (!s) {
+		return -1;
+	}
+
 	return 0;
 }
 




More information about the svn-commits mailing list