mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Make locks more reliable
This change switches most of the core locks to be re-entrant, in order to reduce the chance of deadlocking code that does, clever things with asynchronous signal handlers. This change implements it it in pthreads so we're one step closer to having a standardized threading primitives
This commit is contained in:
parent
5ea618f0af
commit
c260345e06
35 changed files with 369 additions and 258 deletions
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/pthread.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/stdio/fflush.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
@ -28,7 +29,7 @@
|
|||
void _flushlbf(void) {
|
||||
int i;
|
||||
FILE *f;
|
||||
_spinlock(&__fflush.lock);
|
||||
pthread_mutex_lock(&__fflush.lock);
|
||||
for (i = 0; i < __fflush.handles.i; ++i) {
|
||||
if ((f = __fflush.handles.p[i])) {
|
||||
flockfile(f);
|
||||
|
@ -38,5 +39,5 @@ void _flushlbf(void) {
|
|||
funlockfile(f);
|
||||
}
|
||||
}
|
||||
_spunlock(&__fflush.lock);
|
||||
pthread_mutex_unlock(&__fflush.lock);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue