mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-128277: make globals variables thread safe in socket module (#128286)
This commit is contained in:
parent
b2ac70a62a
commit
e389d6c650
3 changed files with 28 additions and 36 deletions
|
@ -1468,14 +1468,14 @@ set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works)
|
|||
assert(!(atomic_flag_works != NULL && inheritable));
|
||||
|
||||
if (atomic_flag_works != NULL && !inheritable) {
|
||||
if (*atomic_flag_works == -1) {
|
||||
if (_Py_atomic_load_int_relaxed(atomic_flag_works) == -1) {
|
||||
int isInheritable = get_inheritable(fd, raise);
|
||||
if (isInheritable == -1)
|
||||
return -1;
|
||||
*atomic_flag_works = !isInheritable;
|
||||
_Py_atomic_store_int_relaxed(atomic_flag_works, !isInheritable);
|
||||
}
|
||||
|
||||
if (*atomic_flag_works)
|
||||
if (_Py_atomic_load_int_relaxed(atomic_flag_works))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue