Skip to content

Commit

Permalink
storage/spanlatch: pass snapshot by reference to wait
Browse files Browse the repository at this point in the history
This does not escape.

Release note: None
  • Loading branch information
nvanbenschoten committed Dec 26, 2018
1 parent c7e0fef commit d1dfefc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/storage/spanlatch/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (m *Manager) Acquire(
lg, snap := m.sequence(spans, ts)
defer snap.close()

err := m.wait(ctx, lg, snap)
err := m.wait(ctx, lg, &snap)
if err != nil {
m.Release(lg)
return nil, err
Expand Down Expand Up @@ -335,7 +335,7 @@ func ifGlobal(ts hlc.Timestamp, s spanset.SpanScope) hlc.Timestamp {

// wait waits for all interfering latches in the provided snapshot to complete
// before returning.
func (m *Manager) wait(ctx context.Context, lg *Guard, snap snapshot) error {
func (m *Manager) wait(ctx context.Context, lg *Guard, snap *snapshot) error {
timer := timeutil.NewTimer()
timer.Reset(base.SlowRequestThreshold)
defer timer.Stop()
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/spanlatch/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (m *Manager) MustAcquireChCtx(
ch := make(chan *Guard)
lg, snap := m.sequence(spans, ts)
go func() {
err := m.wait(ctx, lg, snap)
err := m.wait(ctx, lg, &snap)
if err != nil {
m.Release(lg)
lg = nil
Expand Down

0 comments on commit d1dfefc

Please sign in to comment.