mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20: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
|
|
@ -50,7 +50,7 @@ require (
|
||||||
github.com/rqlite/sql v0.0.0-20221103124402-8f9ff0ceb8f0
|
github.com/rqlite/sql v0.0.0-20221103124402-8f9ff0ceb8f0
|
||||||
github.com/sashabaranov/go-openai v1.17.9
|
github.com/sashabaranov/go-openai v1.17.9
|
||||||
github.com/shirou/gopsutil/v3 v3.23.11
|
github.com/shirou/gopsutil/v3 v3.23.11
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20231208043525-6211184a4438
|
github.com/siyuan-note/dejavu v0.0.0-20231208085113-c89895f2a075
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
||||||
github.com/siyuan-note/eventbus v0.0.0-20230804030110-cf250f838c80
|
github.com/siyuan-note/eventbus v0.0.0-20230804030110-cf250f838c80
|
||||||
github.com/siyuan-note/filelock v0.0.0-20231206081043-b75b363ddb1b
|
github.com/siyuan-note/filelock v0.0.0-20231206081043-b75b363ddb1b
|
||||||
|
|
|
||||||
|
|
@ -356,8 +356,8 @@ github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR
|
||||||
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d h1:lvCTyBbr36+tqMccdGMwuEU+hjux/zL6xSmf5S9ITaA=
|
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d h1:lvCTyBbr36+tqMccdGMwuEU+hjux/zL6xSmf5S9ITaA=
|
||||||
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw=
|
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw=
|
||||||
github.com/simplereach/timeutils v1.2.0/go.mod h1:VVbQDfN/FHRZa1LSqcwo4kNZ62OOyqLLGQKYB3pB0Q8=
|
github.com/simplereach/timeutils v1.2.0/go.mod h1:VVbQDfN/FHRZa1LSqcwo4kNZ62OOyqLLGQKYB3pB0Q8=
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20231208043525-6211184a4438 h1:MMQYT1Kbrr2kgmwSwJXseCM+CUg5QmWMgFz3xseQIBk=
|
github.com/siyuan-note/dejavu v0.0.0-20231208085113-c89895f2a075 h1:AS4npSJSgBXGMR09USiPgdXmeaIJ02p5xFmPZjMNSTs=
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20231208043525-6211184a4438/go.mod h1:JFtbncCYIJft4Krp7U8wdxfqmV7DzpVpfBwz/KGUjX4=
|
github.com/siyuan-note/dejavu v0.0.0-20231208085113-c89895f2a075/go.mod h1:JFtbncCYIJft4Krp7U8wdxfqmV7DzpVpfBwz/KGUjX4=
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||||
github.com/siyuan-note/eventbus v0.0.0-20230804030110-cf250f838c80 h1:XghjHKJd+SiL0DkGYFVC+UGUDFtnR4v9gkAbPeh9Eq8=
|
github.com/siyuan-note/eventbus v0.0.0-20230804030110-cf250f838c80 h1:XghjHKJd+SiL0DkGYFVC+UGUDFtnR4v9gkAbPeh9Eq8=
|
||||||
|
|
|
||||||
|
|
@ -163,11 +163,11 @@ func SyncData(byHand bool) {
|
||||||
|
|
||||||
func lockSync() {
|
func lockSync() {
|
||||||
syncLock.Lock()
|
syncLock.Lock()
|
||||||
isSyncing = true
|
isSyncing.Store(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func unlockSync() {
|
func unlockSync() {
|
||||||
isSyncing = false
|
isSyncing.Store(false)
|
||||||
syncLock.Unlock()
|
syncLock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -178,15 +178,15 @@ func syncData(exit, byHand bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lockSync()
|
||||||
|
defer unlockSync()
|
||||||
|
|
||||||
util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil)
|
util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil)
|
||||||
if !exit && !isProviderOnline(byHand) { // 这个操作比较耗时,所以要先推送 syncing 事件后再判断网络,这样才能给用户更即时的反馈
|
if !exit && !isProviderOnline(byHand) { // 这个操作比较耗时,所以要先推送 syncing 事件后再判断网络,这样才能给用户更即时的反馈
|
||||||
util.BroadcastByType("main", "syncing", 2, Conf.Language(28), nil)
|
util.BroadcastByType("main", "syncing", 2, Conf.Language(28), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
lockSync()
|
|
||||||
defer unlockSync()
|
|
||||||
|
|
||||||
if exit {
|
if exit {
|
||||||
ExitSyncSucc = 0
|
ExitSyncSucc = 0
|
||||||
logging.LogInfof("sync before exit")
|
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")
|
logging.LogWarnf("sync is in progress")
|
||||||
planSyncAfter(fixSyncInterval)
|
planSyncAfter(fixSyncInterval)
|
||||||
return false
|
return false
|
||||||
|
|
@ -431,7 +431,7 @@ func SetSyncProviderWebDAV(webdav *conf.WebDAV) (err error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
syncLock = sync.Mutex{}
|
syncLock = sync.Mutex{}
|
||||||
isSyncing bool
|
isSyncing = atomic.Bool{}
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateCloudSyncDir(name string) (err error) {
|
func CreateCloudSyncDir(name string) (err error) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue