mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
🎨 Improve file read/write locking https://github.com/siyuan-note/siyuan/issues/9748
This commit is contained in:
parent
4347d12af0
commit
b1cea465ac
8 changed files with 31 additions and 35 deletions
|
|
@ -23,7 +23,6 @@ import (
|
|||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
|
@ -85,11 +84,6 @@ func logBootInfo() {
|
|||
Ver, runtime.GOARCH, plat, os.Getpid(), Mode, WorkingDir, ReadOnly, Container, DatabaseVer, WorkspaceDir)
|
||||
}
|
||||
|
||||
func IsMutexLocked(m *sync.Mutex) bool {
|
||||
state := reflect.ValueOf(m).Elem().FieldByName("state")
|
||||
return state.Int()&1 == 1
|
||||
}
|
||||
|
||||
func RandomSleep(minMills, maxMills int) {
|
||||
r := gulu.Rand.Int(minMills, maxMills)
|
||||
time.Sleep(time.Duration(r) * time.Millisecond)
|
||||
|
|
@ -177,7 +171,7 @@ func CheckFileSysStatus() {
|
|||
func checkFileSysStatus() {
|
||||
defer logging.Recover()
|
||||
|
||||
if IsMutexLocked(&checkFileSysStatusLock) {
|
||||
if gulu.IsMutexLocked(&checkFileSysStatusLock) {
|
||||
logging.LogWarnf("check file system status is locked, skip")
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue