[svn-commits] tilghman: branch tilghman/issue18194 r303458 - in /team/tilghman/issue18194: ...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jan 24 02:09:10 CST 2011
Author: tilghman
Date: Mon Jan 24 02:09:07 2011
New Revision: 303458
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=303458
Log:
Initial change
Modified:
team/tilghman/issue18194/include/asterisk/lock.h
team/tilghman/issue18194/main/lock.c
Modified: team/tilghman/issue18194/include/asterisk/lock.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/issue18194/include/asterisk/lock.h?view=diff&rev=303458&r1=303457&r2=303458
==============================================================================
--- team/tilghman/issue18194/include/asterisk/lock.h (original)
+++ team/tilghman/issue18194/include/asterisk/lock.h Mon Jan 24 02:09:07 2011
@@ -91,11 +91,11 @@
#define AST_LOCK_TRACK_INIT_VALUE { { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INIT_VALUE }
#endif
-#define AST_MUTEX_INIT_VALUE { AST_LOCK_TRACK_INIT_VALUE, 1, PTHREAD_MUTEX_INIT_VALUE }
-#define AST_MUTEX_INIT_VALUE_NOTRACKING { AST_LOCK_TRACK_INIT_VALUE, 0, PTHREAD_MUTEX_INIT_VALUE }
-
-#define AST_RWLOCK_INIT_VALUE { AST_LOCK_TRACK_INIT_VALUE, 1, __AST_RWLOCK_INIT_VALUE }
-#define AST_RWLOCK_INIT_VALUE_NOTRACKING { AST_LOCK_TRACK_INIT_VALUE, 0, __AST_RWLOCK_INIT_VALUE }
+#define AST_MUTEX_INIT_VALUE { PTHREAD_MUTEX_INIT_VALUE, NULL, 1 }
+#define AST_MUTEX_INIT_VALUE_NOTRACKING { PTHREAD_MUTEX_INIT_VALUE, NULL, 0 }
+
+#define AST_RWLOCK_INIT_VALUE { __AST_RWLOCK_INIT_VALUE, NULL, 1 }
+#define AST_RWLOCK_INIT_VALUE_NOTRACKING { __AST_RWLOCK_INIT_VALUE, NULL, 0 }
#define AST_MAX_REENTRANCY 10
@@ -119,10 +119,10 @@
* The information will just be ignored in the core if a module does not request it..
*/
struct ast_mutex_info {
+ pthread_mutex_t mutex;
/*! Track which thread holds this mutex */
- struct ast_lock_track track;
+ struct ast_lock_track *track;
unsigned int tracking:1;
- pthread_mutex_t mutex;
};
/*! \brief Structure for rwlock and tracking information.
@@ -131,10 +131,10 @@
* The information will just be ignored in the core if a module does not request it..
*/
struct ast_rwlock_info {
+ pthread_rwlock_t lock;
/*! Track which thread holds this lock */
- struct ast_lock_track track;
+ struct ast_lock_track *track;
unsigned int tracking:1;
- pthread_rwlock_t lock;
};
typedef struct ast_mutex_info ast_mutex_t;
Modified: team/tilghman/issue18194/main/lock.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/issue18194/main/lock.c?view=diff&rev=303458&r1=303457&r2=303458
==============================================================================
--- team/tilghman/issue18194/main/lock.c (original)
+++ team/tilghman/issue18194/main/lock.c Mon Jan 24 02:09:07 2011
@@ -61,8 +61,8 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
- ast_reentrancy_init(&t->track);
- t->tracking = tracking;
+ ast_reentrancy_init(t->track);
+ t->track = (t->tracking = tracking) ? ast_calloc(1, sizeof(*(t->track))) : NULL;
#endif /* DEBUG_THREADS */
pthread_mutexattr_init(&attr);
@@ -96,7 +96,7 @@
}
#endif
- lt = &t->track;
+ lt = t->track;
res = pthread_mutex_trylock(&t->mutex);
switch (res) {
@@ -139,6 +139,8 @@
#endif
ast_reentrancy_unlock(lt);
delete_reentrancy_cs(lt);
+ ast_free(t->track);
+ t->track = NULL;
#endif /* DEBUG_THREADS */
return res;
@@ -150,7 +152,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt = &t->track;
+ struct ast_lock_track *lt = t->track;
int canlog = strcmp(filename, "logger.c") & t->tracking;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
@@ -279,7 +281,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt= &t->track;
+ struct ast_lock_track *lt = t->track;
int canlog = strcmp(filename, "logger.c") & t->tracking;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
@@ -348,7 +350,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt = &t->track;
+ struct ast_lock_track *lt = t->track;
int canlog = strcmp(filename, "logger.c") & t->tracking;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
@@ -453,7 +455,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt= &t->track;
+ struct ast_lock_track *lt = t->track;
int canlog = strcmp(filename, "logger.c") & t->tracking;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
@@ -558,7 +560,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt = &t->track;
+ struct ast_lock_track *lt = t->track;
int canlog = strcmp(filename, "logger.c") & t->tracking;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
@@ -661,7 +663,7 @@
pthread_rwlockattr_t attr;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt= &t->track;
+ struct ast_lock_track *lt = t->track;
#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
int canlog = strcmp(filename, "logger.c") & t->tracking;
@@ -674,7 +676,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
ast_reentrancy_init(lt);
- t->tracking = tracking;
+ t->track = (t->tracking = tracking) ? ast_calloc(1, sizeof(*(t->track))) : NULL;
#endif /* DEBUG_THREADS */
pthread_rwlockattr_init(&attr);
@@ -693,7 +695,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt = &t->track;
+ struct ast_lock_track *lt = t->track;
int canlog = strcmp(filename, "logger.c") & t->tracking;
#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
@@ -735,7 +737,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt = &t->track;
+ struct ast_lock_track *lt = t->track;
int canlog = strcmp(filename, "logger.c") & t->tracking;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
@@ -817,7 +819,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt = &t->track;
+ struct ast_lock_track *lt = t->track;
int canlog = strcmp(filename, "logger.c") & t->tracking;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
@@ -931,7 +933,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt = &t->track;
+ struct ast_lock_track *lt = t->track;
int canlog = strcmp(filename, "logger.c") & t->tracking;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
@@ -1045,7 +1047,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt = &t->track;
+ struct ast_lock_track *lt = t->track;
int canlog = strcmp(filename, "logger.c") & t->tracking;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
@@ -1145,7 +1147,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt = &t->track;
+ struct ast_lock_track *lt = t->track;
int canlog = strcmp(filename, "logger.c") & t->tracking;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
@@ -1245,7 +1247,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt = &t->track;
+ struct ast_lock_track *lt = t->track;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
@@ -1311,7 +1313,7 @@
int res;
#ifdef DEBUG_THREADS
- struct ast_lock_track *lt= &t->track;
+ struct ast_lock_track *lt = t->track;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
More information about the svn-commits
mailing list