mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Improve kernel stability by eliminating some data races https://github.com/siyuan-note/siyuan/issues/9842
This commit is contained in:
parent
8c4adbc48a
commit
dbd52231e9
3 changed files with 10 additions and 10 deletions
|
|
@ -163,11 +163,11 @@ func SyncData(byHand bool) {
|
|||
|
||||
func lockSync() {
|
||||
syncLock.Lock()
|
||||
isSyncing = true
|
||||
isSyncing.Store(true)
|
||||
}
|
||||
|
||||
func unlockSync() {
|
||||
isSyncing = false
|
||||
isSyncing.Store(false)
|
||||
syncLock.Unlock()
|
||||
}
|
||||
|
||||
|
|
@ -178,15 +178,15 @@ func syncData(exit, byHand bool) {
|
|||
return
|
||||
}
|
||||
|
||||
lockSync()
|
||||
defer unlockSync()
|
||||
|
||||
util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil)
|
||||
if !exit && !isProviderOnline(byHand) { // 这个操作比较耗时,所以要先推送 syncing 事件后再判断网络,这样才能给用户更即时的反馈
|
||||
util.BroadcastByType("main", "syncing", 2, Conf.Language(28), nil)
|
||||
return
|
||||
}
|
||||
|
||||
lockSync()
|
||||
defer unlockSync()
|
||||
|
||||
if exit {
|
||||
ExitSyncSucc = 0
|
||||
logging.LogInfof("sync before exit")
|
||||
|
|
@ -256,7 +256,7 @@ func checkSync(boot, exit, byHand bool) bool {
|
|||
}
|
||||
}
|
||||
|
||||
if isSyncing {
|
||||
if isSyncing.Load() {
|
||||
logging.LogWarnf("sync is in progress")
|
||||
planSyncAfter(fixSyncInterval)
|
||||
return false
|
||||
|
|
@ -431,7 +431,7 @@ func SetSyncProviderWebDAV(webdav *conf.WebDAV) (err error) {
|
|||
|
||||
var (
|
||||
syncLock = sync.Mutex{}
|
||||
isSyncing bool
|
||||
isSyncing = atomic.Bool{}
|
||||
)
|
||||
|
||||
func CreateCloudSyncDir(name string) (err error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue