aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-09 22:17:39 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-09 22:17:39 +0000
commit9269b46da804da1972fd15ec830b79e43d34b12f (patch)
treef5d3c6c088ab2170c9ab2218ba589007a7a9729f
parent8fac3e83341e89faa77912bff43f002319f1c901 (diff)
Remove the test_for_thread_safety() function completely.
The test is not valid. Besides, if we actually suspected that recursive mutexes were not working, we would get a ton of LOG_ERROR messages when DEBUG_THREADS is turned on. (inspired by a discussion on the asterisk-dev list) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@162413 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--include/asterisk/utils.h2
-rw-r--r--main/asterisk.c4
-rw-r--r--main/utils.c62
3 files changed, 0 insertions, 68 deletions
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index 7b7378530..44da65e70 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -219,8 +219,6 @@ static force_inline void ast_slinear_saturated_divide(short *input, short *value
*input /= *value;
}
-int test_for_thread_safety(void);
-
/*!
* \brief thread-safe replacement for inet_ntoa().
*
diff --git a/main/asterisk.c b/main/asterisk.c
index d0f6e487b..230f9c830 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -2981,10 +2981,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_makesocket();
sigemptyset(&sigs);
sigaddset(&sigs, SIGHUP);
diff --git a/main/utils.c b/main/utils.c
index a802fd324..a8d15bba0 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -228,68 +228,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)
{