提交 a7778dae 编写于 作者: R Rich Felker

handle pending cancellation when enabling async cancellation

this is not strictly required by the standard, but without it, there
is a race condition where cancellation arriving just before async
cancellation is enabled might not be acted upon. it is impossible for
a conforming application to work around this race condition since
calling pthread_testcancel after setting async cancellation mode is
not allowed (pthread_testcancel is not specified to be
async-cancel-safe). thus the implementation should be responsible for
eliminating the race, from a quality-of-implementation standpoint.
上级 22e45423
...@@ -6,5 +6,6 @@ int pthread_setcanceltype(int new, int *old) ...@@ -6,5 +6,6 @@ int pthread_setcanceltype(int new, int *old)
if (new > 1U) return EINVAL; if (new > 1U) return EINVAL;
if (old) *old = self->cancelasync; if (old) *old = self->cancelasync;
self->cancelasync = new; self->cancelasync = new;
if (new) pthread_testcancel();
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册