Skip to content

Commit

Permalink
Use new Idempotent() function in go-util.
Browse files Browse the repository at this point in the history
  • Loading branch information
zenhack committed Jan 22, 2023
1 parent 33aac35 commit 42755b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/ulikunitz/xz v0.5.10
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
golang.org/x/sys v0.1.0
zenhack.net/go/util v0.0.0-20221212041830-211f2079c6f5
zenhack.net/go/util v0.0.0-20230122201906-2fd576937fdf
zenhack.net/go/vdom v0.0.0-20221212051524-f5d445b862c0
zenhack.net/go/websocket-capnp v0.0.0-20230122013820-cb32f4dfbb0b
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
zenhack.net/go/util v0.0.0-20221212041830-211f2079c6f5 h1:u/+juAxlCMpZHhD93kmqc4Dcq9zf6NAtUS1mqTJnBw0=
zenhack.net/go/util v0.0.0-20221212041830-211f2079c6f5/go.mod h1:0lafdGg7tDb7RcXASgmJmRbLFLkAxu328+KGIs7icDE=
zenhack.net/go/util v0.0.0-20230122201906-2fd576937fdf h1:8v7nt32qlnI1KljVE0bA9I8kOCIXTpA9BvmST2fb4TU=
zenhack.net/go/util v0.0.0-20230122201906-2fd576937fdf/go.mod h1:0lafdGg7tDb7RcXASgmJmRbLFLkAxu328+KGIs7icDE=
zenhack.net/go/vdom v0.0.0-20221212051524-f5d445b862c0 h1:b47/PxX40kcz1D2glkLjSAfDAISRpytnMqOpdsAe4Rk=
zenhack.net/go/vdom v0.0.0-20221212051524-f5d445b862c0/go.mod h1:6WIfdsOxSlWalwz8i+nMyKDjinQKQFVLDhEJGvI1dWU=
zenhack.net/go/websocket-capnp v0.0.0-20230122013820-cb32f4dfbb0b h1:+PQzrE1bNfgTZ7fsZfA6FetPRqkTS+q99NbKjI8//t8=
Expand Down
9 changes: 2 additions & 7 deletions go/internal/server/main/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"zenhack.net/go/tempest/go/internal/server/container"
"zenhack.net/go/tempest/go/internal/server/embed"
"zenhack.net/go/tempest/go/internal/server/session"
"zenhack.net/go/util"
websocketcapnp "zenhack.net/go/websocket-capnp"
)

Expand Down Expand Up @@ -146,13 +147,7 @@ func (s *server) Handler() http.Handler {
}).Debug("Access to grain UI denied")
default:
s.lk.Lock()
var unlocked bool
unlock := func() { // idempotent wrapper around s.lk.Unlock
if !unlocked {
s.lk.Unlock()
unlocked = true
}
}
unlock := util.Idempotent(s.lk.Unlock)
defer unlock()

var wsp webSessionParams
Expand Down

0 comments on commit 42755b8

Please sign in to comment.