Skip to content

Commit

Permalink
Fixed attempt to join detached threads
Browse files Browse the repository at this point in the history
  • Loading branch information
pchk committed Dec 11, 2016
1 parent d8ae726 commit 2c1f3ac
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions auto_tests/toxav_many_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ START_TEST(test_AV_three_calls)
uint32_t index[] = { 1, 2, 3, 4, 5 };
Tox *Alice, *bootstrap, *Bobs[3];
ToxAV *AliceAV, *BobsAV[3];
void *retval;

CallControl AliceCC[3], BobsCC[3];

Expand Down Expand Up @@ -300,10 +301,6 @@ START_TEST(test_AV_three_calls)
(void) pthread_create(tids + 1, NULL, call_thread, tds + 1);
(void) pthread_create(tids + 2, NULL, call_thread, tds + 2);

(void) pthread_detach(tids[0]);
(void) pthread_detach(tids[1]);
(void) pthread_detach(tids[2]);

time_t start_time = time(NULL);

while (time(NULL) - start_time < 5) {
Expand All @@ -314,9 +311,14 @@ START_TEST(test_AV_three_calls)
c_sleep(20);
}

(void) pthread_join(tids[0], NULL);
(void) pthread_join(tids[1], NULL);
(void) pthread_join(tids[2], NULL);
ck_assert(pthread_join(tids[0], &retval) == 0);
ck_assert(retval == NULL);

ck_assert(pthread_join(tids[1], &retval) == 0);
ck_assert(retval == NULL);

ck_assert(pthread_join(tids[2], &retval) == 0);
ck_assert(retval == NULL);

printf("Killing all instances\n");
toxav_kill(BobsAV[0]);
Expand Down

0 comments on commit 2c1f3ac

Please sign in to comment.