diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index 3737ef9c27..1c676b8ee4 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -307,8 +307,6 @@ static force_inline void ast_slinear_saturated_divide(short *input, short *value *input /= *value; } -int test_for_thread_safety(void); - #ifdef localtime_r #undef localtime_r #endif diff --git a/main/asterisk.c b/main/asterisk.c index 250b55271a..e82a8d87e4 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -3297,10 +3297,6 @@ int main(int argc, char *argv[]) } #endif - /* Test recursive mutex locking. */ - if (test_for_thread_safety()) - ast_verbose("Warning! Asterisk is not thread safe.\n"); - ast_event_init(); ast_makesocket(); diff --git a/main/utils.c b/main/utils.c index 424504588e..71a4dcc004 100644 --- a/main/utils.c +++ b/main/utils.c @@ -226,68 +226,6 @@ struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp) return &hp->hp; } - - -AST_MUTEX_DEFINE_STATIC(test_lock); -AST_MUTEX_DEFINE_STATIC(test_lock2); -static pthread_t test_thread; -static int lock_count = 0; -static int test_errors = 0; - -/*! \brief This is a regression test for recursive mutexes. - test_for_thread_safety() will return 0 if recursive mutex locks are - working properly, and non-zero if they are not working properly. */ -static void *test_thread_body(void *data) -{ - ast_mutex_lock(&test_lock); - lock_count += 10; - if (lock_count != 10) - test_errors++; - ast_mutex_lock(&test_lock); - lock_count += 10; - if (lock_count != 20) - test_errors++; - ast_mutex_lock(&test_lock2); - ast_mutex_unlock(&test_lock); - lock_count -= 10; - if (lock_count != 10) - test_errors++; - ast_mutex_unlock(&test_lock); - lock_count -= 10; - ast_mutex_unlock(&test_lock2); - if (lock_count != 0) - test_errors++; - return NULL; -} - -int test_for_thread_safety(void) -{ - ast_mutex_lock(&test_lock2); - ast_mutex_lock(&test_lock); - lock_count += 1; - ast_mutex_lock(&test_lock); - lock_count += 1; - ast_pthread_create(&test_thread, NULL, test_thread_body, NULL); - usleep(100); - if (lock_count != 2) - test_errors++; - ast_mutex_unlock(&test_lock); - lock_count -= 1; - usleep(100); - if (lock_count != 1) - test_errors++; - ast_mutex_unlock(&test_lock); - lock_count -= 1; - if (lock_count != 0) - test_errors++; - ast_mutex_unlock(&test_lock2); - usleep(100); - if (lock_count != 0) - test_errors++; - pthread_join(test_thread, NULL); - return(test_errors); /* return 0 on success. */ -} - /*! \brief Produce 32 char MD5 hash of value. */ void ast_md5_hash(char *output, char *input) {