lib9/fmt: avoid racy access to installed fmt formats

This commit is contained in:
Russ Cox 2020-01-13 11:41:37 -05:00
parent d96e9e5dc3
commit 7ba9f9467d
4 changed files with 55 additions and 22 deletions

View file

@ -1,16 +1,28 @@
#include <u.h>
#include <libc.h>
static Lock fmtlock;
static RWLock fmtlock;
void
__fmtlock(void)
__fmtrlock(void)
{
lock(&fmtlock);
rlock(&fmtlock);
}
void
__fmtunlock(void)
__fmtrunlock(void)
{
unlock(&fmtlock);
runlock(&fmtlock);
}
void
__fmtwlock(void)
{
wlock(&fmtlock);
}
void
__fmtwunlock(void)
{
wunlock(&fmtlock);
}