summaryrefslogtreecommitdiff
path: root/auto_tests/toxav_many_test.c
diff options
context:
space:
mode:
authornotsecure <notsecure@marek.ca>2014-07-07 18:47:49 -0400
committernotsecure <notsecure@marek.ca>2014-07-07 18:47:49 -0400
commitb90ecb377d59384770a594abc5c5e3022e99adc8 (patch)
tree9bde1aeead04563b27338a108ea99ee7ed54443d /auto_tests/toxav_many_test.c
parentc527979daa5b65ec9a838c1b3fe998af6375953a (diff)
locks in test
Diffstat (limited to 'auto_tests/toxav_many_test.c')
-rw-r--r--auto_tests/toxav_many_test.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c
index 106d2f32..3195d1ed 100644
--- a/auto_tests/toxav_many_test.c
+++ b/auto_tests/toxav_many_test.c
@@ -24,6 +24,7 @@
24#define c_sleep(x) usleep(1000*x) 24#define c_sleep(x) usleep(1000*x)
25#endif 25#endif
26 26
27pthread_mutex_t muhmutex;
27 28
28typedef enum _CallStatus { 29typedef enum _CallStatus {
29 none, 30 none,
@@ -223,8 +224,10 @@ void *in_thread_call (void *arg)
223 224
224 step++; /* This terminates the loop */ 225 step++; /* This terminates the loop */
225 226
227 pthread_mutex_lock(&muhmutex);
226 toxav_kill_transmission(this_call->Callee.av, 0); 228 toxav_kill_transmission(this_call->Callee.av, 0);
227 toxav_kill_transmission(this_call->Caller.av, call_idx); 229 toxav_kill_transmission(this_call->Caller.av, call_idx);
230 pthread_mutex_unlock(&muhmutex);
228 231
229 /* Call over CALLER hangs up */ 232 /* Call over CALLER hangs up */
230 toxav_hangup(this_call->Caller.av, call_idx); 233 toxav_hangup(this_call->Caller.av, call_idx);
@@ -348,6 +351,9 @@ START_TEST(test_AV_three_calls)
348 toxav_register_callstate_callback(callback_requ_timeout, av_OnRequestTimeout, &status_control); 351 toxav_register_callstate_callback(callback_requ_timeout, av_OnRequestTimeout, &status_control);
349 352
350 353
354 pthread_mutex_init(&muhmutex, NULL);
355
356
351 for ( i = 0; i < 3; i++ ) 357 for ( i = 0; i < 3; i++ )
352 pthread_create(&status_control.calls[i].tid, NULL, in_thread_call, &status_control.calls[i]); 358 pthread_create(&status_control.calls[i].tid, NULL, in_thread_call, &status_control.calls[i]);
353 359
@@ -362,11 +368,15 @@ START_TEST(test_AV_three_calls)
362 status_control.calls[1].Callee.status != Ended && status_control.calls[1].Caller.status != Ended && 368 status_control.calls[1].Callee.status != Ended && status_control.calls[1].Caller.status != Ended &&
363 status_control.calls[2].Callee.status != Ended && status_control.calls[2].Caller.status != Ended 369 status_control.calls[2].Callee.status != Ended && status_control.calls[2].Caller.status != Ended
364 ) { 370 ) {
371 pthread_mutex_lock(&muhmutex);
372
365 tox_do(bootstrap_node); 373 tox_do(bootstrap_node);
366 tox_do(caller); 374 tox_do(caller);
367 tox_do(callees[0]); 375 tox_do(callees[0]);
368 tox_do(callees[1]); 376 tox_do(callees[1]);
369 tox_do(callees[2]); 377 tox_do(callees[2]);
378
379 pthread_mutex_unlock(&muhmutex);
370 c_sleep(20); 380 c_sleep(20);
371 } 381 }
372 382