Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor gui cache #273

Merged
merged 3 commits into from
Jun 12, 2021
Merged

Refactor gui cache #273

merged 3 commits into from
Jun 12, 2021

Conversation

jholdstock
Copy link
Member

Remove static cfg values from GUI cache.

Theres no need for these values to be copied into the cache when templates could simply access the config struct directly.

This also changes the cache accessor so it returns a copy of the cache rather than a pointer, which removes a potential race.

Rename and move cache.

Cache code was previous in homepage.go, but its used in multiple places and not just on the homepage. Its enough code to go into its own dedicated cache.go.

Theres no need for these values to be copied into the cache when templates could simply access the config struct directly.

This also changes the cache accessor so it returns a copy of the cache rather than a pointer, which removes a potential race.
@jholdstock jholdstock force-pushed the refactor-gui-cache branch from ca2b686 to 14e75d7 Compare June 11, 2021 06:45
@jholdstock
Copy link
Member Author

Still seeing races from the cache:

==================
WARNING: DATA RACE
Write at 0x00c0001143e0 by goroutine 43:
  github.com/decred/vspd/webapi.Start.func3()
      /home/jholdstock/code/jholdstock/vspd/webapi/webapi.go:160 +0x1cb

Previous write at 0x00c0001143e0 by goroutine 42:
  github.com/decred/vspd/webapi.Start.func2()
      /home/jholdstock/code/jholdstock/vspd/webapi/webapi.go:133 +0x75

Goroutine 43 (running) created at:
  github.com/decred/vspd/webapi.Start()
      /home/jholdstock/code/jholdstock/vspd/webapi/webapi.go:151 +0x1144
  main.run()
      /home/jholdstock/code/jholdstock/vspd/vspd.go:100 +0xed7
  main.main()
      /home/jholdstock/code/jholdstock/vspd/vspd.go:35 +0x9e

Goroutine 42 (finished) created at:
  github.com/decred/vspd/webapi.Start()
      /home/jholdstock/code/jholdstock/vspd/webapi/webapi.go:132 +0x1071
  main.run()
      /home/jholdstock/code/jholdstock/vspd/vspd.go:100 +0xed7
  main.main()
      /home/jholdstock/code/jholdstock/vspd/vspd.go:35 +0x9e
==================

@jholdstock jholdstock force-pushed the refactor-gui-cache branch 2 times, most recently from 316091b to 5a8fa73 Compare June 11, 2021 10:39
@jholdstock
Copy link
Member Author

Fixed the race, ready to review

Cache code was previous in `homepage.go`, but its used in multiple places and not just on the homepage. Its enough code to go into its own dedicated `cache.go`.
@jholdstock jholdstock force-pushed the refactor-gui-cache branch from 5a8fa73 to 61b3a6b Compare June 11, 2021 10:47
@jholdstock jholdstock merged commit fc131e9 into decred:master Jun 12, 2021
@jholdstock jholdstock deleted the refactor-gui-cache branch January 25, 2022 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants