aboutsummaryrefslogtreecommitdiffstats
path: root/utils.c
diff options
context:
space:
mode:
authorcitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-22 19:53:36 +0000
committercitats <citats@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-22 19:53:36 +0000
commit08d0c132c31ede086cc473d943aff80c76f47719 (patch)
tree85b4c43f9001389878f3e827802cfd46d9774ff0 /utils.c
parent31e064cf03900c2542a21fe40c70f4888bcd8d31 (diff)
Code formatting cleanups in utils.c and include/asterisk/lock.h
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3278 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils.c')
-rwxr-xr-xutils.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/utils.c b/utils.c
index 66ac2e247..f2a9b5bfd 100755
--- a/utils.c
+++ b/utils.c
@@ -158,46 +158,54 @@ static int test_errors = 0;
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;
+ 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;
- pthread_create(&test_thread, NULL, test_thread_body, NULL);
- pthread_yield();
- usleep(100);
- if(lock_count != 2) test_errors++;
- ast_mutex_unlock(&test_lock);
- lock_count -= 1;
- pthread_yield();
- 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);
- pthread_yield();
- usleep(100);
- if(lock_count != 0) test_errors++;
- pthread_join(test_thread, NULL);
- return(test_errors); /* return 0 on success. */
+ ast_mutex_lock(&test_lock2);
+ ast_mutex_lock(&test_lock);
+ lock_count += 1;
+ ast_mutex_lock(&test_lock);
+ lock_count += 1;
+ pthread_create(&test_thread, NULL, test_thread_body, NULL);
+ pthread_yield();
+ usleep(100);
+ if (lock_count != 2)
+ test_errors++;
+ ast_mutex_unlock(&test_lock);
+ lock_count -= 1;
+ pthread_yield();
+ 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);
+ pthread_yield();
+ usleep(100);
+ if (lock_count != 0)
+ test_errors++;
+ pthread_join(test_thread, NULL);
+ return(test_errors); /* return 0 on success. */
}