Skip to content

Commit b754673

Browse files
committed
Address Sam's review
1 parent dc3581e commit b754673

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

Python/thread.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,7 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
122122
flags |= _PY_LOCK_HANDLE_SIGNALS;
123123
}
124124

125-
if (timeout < 0) {
126-
PyMutex_Lock((PyMutex *)lock);
127-
return PY_LOCK_ACQUIRED;
128-
}
129-
else {
130-
return _PyMutex_LockTimed((PyMutex *)lock, timeout, flags);
131-
}
125+
return _PyMutex_LockTimed((PyMutex *)lock, timeout, flags);
132126
}
133127

134128
void
@@ -140,20 +134,7 @@ PyThread_release_lock(PyThread_type_lock lock)
140134
int
141135
_PyThread_at_fork_reinit(PyThread_type_lock *lock)
142136
{
143-
PyThread_type_lock new_lock = PyThread_allocate_lock();
144-
if (new_lock == NULL) {
145-
return -1;
146-
}
147-
148-
/* bpo-6721, bpo-40089: The old lock can be in an inconsistent state.
149-
fork() can be called in the middle of an operation on the lock done by
150-
another thread. So don't call PyThread_free_lock(*lock).
151-
152-
Leak memory on purpose. Don't release the memory either since the
153-
address of a mutex is relevant. Putting two mutexes at the same address
154-
can lead to problems. */
155-
156-
*lock = new_lock;
137+
_PyMutex_at_fork_reinit((PyMutex *)lock);
157138
return 0;
158139
}
159140

0 commit comments

Comments
 (0)