Skip to content

Commit

Permalink
Fix race condition
Browse files Browse the repository at this point in the history
I mean, it's still a non-atomic pointer being accessed from multiple thread,
but this must be better.
  • Loading branch information
foodelevator committed Feb 12, 2024
1 parent 1c29429 commit 472b4e0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions taitan.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,15 @@ func updateJumpFile(root string) {
if _, err := os.Stat(root + "/jumpfile.json"); err == nil {
buf, err := ioutil.ReadFile(root + "/jumpfile.json")
if err != nil {
log.Warningln("jumpfile readfile: unexpected error: %s", err)
log.Warningln("jumpfile readfile: unexpected error:", err)
}
err = json.Unmarshal(buf, &jumpfile)
var j map[string]interface{}
err = json.Unmarshal(buf, &j)
if err != nil {
log.Warningln("jumpfile unmarshal: unexpected error: %s", err)
log.Warningln("jumpfile unmarshal: unexpected error:", err)
}
log.Debugln(jumpfile)
log.Debugln(j)
jumpfile = j
} else {
log.Infoln("No jumpfile found")
}
Expand Down

0 comments on commit 472b4e0

Please sign in to comment.