mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 08:30:42 +02:00
🎨 Improve kernel stability by eliminating some data races https://github.com/siyuan-note/siyuan/issues/9842
This commit is contained in:
parent
bea32e96d5
commit
26e3f6807b
2 changed files with 10 additions and 6 deletions
|
@ -676,7 +676,7 @@ func GetOnlineKernels() (ret []*OnlineKernel) {
|
|||
return
|
||||
}
|
||||
|
||||
var closedSyncWebSocket = false
|
||||
var closedSyncWebSocket = atomic.Bool{}
|
||||
|
||||
func closeSyncWebSocket() {
|
||||
defer logging.Recover()
|
||||
|
@ -687,7 +687,7 @@ func closeSyncWebSocket() {
|
|||
if nil != webSocketConn {
|
||||
webSocketConn.Close()
|
||||
webSocketConn = nil
|
||||
closedSyncWebSocket = true
|
||||
closedSyncWebSocket.Store(true)
|
||||
}
|
||||
|
||||
logging.LogInfof("sync websocket closed")
|
||||
|
@ -732,7 +732,7 @@ func connectSyncWebSocket() {
|
|||
result := gulu.Ret.NewResult()
|
||||
if readErr := webSocketConn.ReadJSON(&result); nil != readErr {
|
||||
time.Sleep(1 * time.Second)
|
||||
if closedSyncWebSocket {
|
||||
if closedSyncWebSocket.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -803,7 +803,7 @@ func dialSyncWebSocket() (c *websocket.Conn, err error) {
|
|||
}
|
||||
c, _, err = websocket.DefaultDialer.Dial(endpoint, header)
|
||||
if nil == err {
|
||||
closedSyncWebSocket = false
|
||||
closedSyncWebSocket.Store(false)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -174,8 +174,12 @@ func IsBooted() bool {
|
|||
return 100 <= bootProgress.Load()
|
||||
}
|
||||
|
||||
func GetBootProgressDetails() (int32, string) {
|
||||
return bootProgress.Load(), bootDetails
|
||||
func GetBootProgressDetails() (progress int32, details string) {
|
||||
progress = bootProgress.Load()
|
||||
bootDetailsLock.Lock()
|
||||
details = bootDetails
|
||||
bootDetailsLock.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func GetBootProgress() int32 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue