am 2e7617f2: am 4149dc94: Merge "Return EINVAL when calling pthread_detach for joined thread."

* commit '2e7617f2a0a703ae8dd0ba1b090464279482f893':
  Return EINVAL when calling pthread_detach for joined thread.
This commit is contained in:
Yabin Cui 2015-03-20 00:21:22 +00:00 committed by Android Git Automerger
commit 23c719f940
2 changed files with 5 additions and 2 deletions

View File

@ -44,7 +44,7 @@ int pthread_detach(pthread_t t) {
}
switch (old_state) {
case THREAD_NOT_JOINED: return 0;
case THREAD_JOINED: return 0; // Already being joined; silently do nothing, like glibc.
case THREAD_JOINED: return EINVAL;
case THREAD_DETACHED: return EINVAL;
case THREAD_EXITED_NOT_JOINED: break; // Call pthread_join out of scope of pthread_accessor.
}

View File

@ -271,8 +271,11 @@ TEST(pthread, pthread_no_op_detach_after_join) {
sleep(1); // (Give t2 a chance to call pthread_join.)
// ...a call to pthread_detach on thread 1 will "succeed" (silently fail)...
#if defined(__BIONIC__)
ASSERT_EQ(EINVAL, pthread_detach(t1));
#else
ASSERT_EQ(0, pthread_detach(t1));
#endif
AssertDetached(t1, false);
spinhelper.UnSpin();