mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Fix recursive locks when tid is huge
It turns out Linux may assign thread ids that are much larger than previously thought. We now have fewer bits of depth so we can have bigger tids.
This commit is contained in:
parent
9c72fef086
commit
a4b6803556
3 changed files with 4 additions and 4 deletions
|
@ -89,7 +89,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex) {
|
|||
t = gettid();
|
||||
if (mutex->_owner == t) {
|
||||
if (mutex->_type != PTHREAD_MUTEX_ERRORCHECK) {
|
||||
if (mutex->_depth < 255) {
|
||||
if (mutex->_depth < 63) {
|
||||
++mutex->_depth;
|
||||
return 0;
|
||||
} else {
|
||||
|
|
|
@ -59,7 +59,7 @@ errno_t pthread_mutex_trylock(pthread_mutex_t *mutex) {
|
|||
t = gettid();
|
||||
if (mutex->_owner == t) {
|
||||
if (mutex->_type != PTHREAD_MUTEX_ERRORCHECK) {
|
||||
if (mutex->_depth < 255) {
|
||||
if (mutex->_depth < 63) {
|
||||
++mutex->_depth;
|
||||
return 0;
|
||||
} else {
|
||||
|
|
|
@ -67,8 +67,8 @@ typedef struct pthread_mutex_s {
|
|||
_Atomic(int32_t) _lock;
|
||||
unsigned _type : 2;
|
||||
unsigned _pshared : 1;
|
||||
unsigned _depth : 8;
|
||||
unsigned _owner : 21;
|
||||
unsigned _depth : 6;
|
||||
unsigned _owner : 23;
|
||||
long _pid;
|
||||
} pthread_mutex_t;
|
||||
|
||||
|
|
Loading…
Reference in a new issue