Cygwin: pthread_timedjoin_np: return ETIMEDOUT, not EBUSY

pthread_timedjoin_np returns ETIMEDOUT if a thread is still running,
not EBUSY as pthread_tryjoin_np.

Also, clean up initializing timeout in pthread_tryjoin_np.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2018-06-27 18:13:38 +02:00
parent 732e0b395d
commit cb3ddf9e2a
1 changed files with 2 additions and 2 deletions

View File

@ -2472,7 +2472,7 @@ pthread::join (pthread_t *thread, void **return_val, PLARGE_INTEGER timeout)
// set joined thread back to joinable since we got canceled
(*thread)->joiner = NULL;
(*thread)->attr.joinable = PTHREAD_CREATE_JOINABLE;
return EBUSY;
return (timeout && timeout->QuadPart == 0LL) ? EBUSY : ETIMEDOUT;
default:
// should never happen
return EINVAL;
@ -2588,7 +2588,7 @@ pthread_join (pthread_t thread, void **return_val)
extern "C" int
pthread_tryjoin_np (pthread_t thread, void **return_val)
{
LARGE_INTEGER timeout = { 0, 0 };
LARGE_INTEGER timeout = { QuadPart:0LL };
return pthread::join (&thread, (void **) return_val, &timeout);
}