gh-128277: make globals variables thread safe in socket module (#128286) · python/cpython@e389d6c · GitHub
Skip to content

Commit e389d6c

Browse files
gh-128277: make globals variables thread safe in socket module (#128286)
1 parent b2ac70a commit e389d6c

3 files changed

Lines changed: 28 additions & 36 deletions

File tree

Modules/socketmodule.c

Lines changed: 23 additions & 33 deletions

Python/fileutils.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,14 +1468,14 @@ set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works)
14681468
assert(!(atomic_flag_works != NULL && inheritable));
14691469

14701470
if (atomic_flag_works != NULL && !inheritable) {
1471-
if (*atomic_flag_works == -1) {
1471+
if (_Py_atomic_load_int_relaxed(atomic_flag_works) == -1) {
14721472
int isInheritable = get_inheritable(fd, raise);
14731473
if (isInheritable == -1)
14741474
return -1;
1475-
*atomic_flag_works = !isInheritable;
1475+
_Py_atomic_store_int_relaxed(atomic_flag_works, !isInheritable);
14761476
}
14771477

1478-
if (*atomic_flag_works)
1478+
if (_Py_atomic_load_int_relaxed(atomic_flag_works))
14791479
return 0;
14801480
}
14811481

Tools/c-analyzer/cpython/globals-to-fix.tsv

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)