Skip to content

Commit 772298e

Browse files
author
Aaron Schlesinger
committed
fix(pkg/cleaner,pkg/sshd): remove the RLock, go back to the simple mutex
1 parent 5b8d884 commit 772298e

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

pkg/cleaner/cleaner.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,11 @@ const (
2121
)
2222

2323
type Ref struct {
24-
mut *sync.RWMutex
24+
mut *sync.Mutex
2525
}
2626

2727
func NewRef() Ref {
28-
return Ref{mut: new(sync.RWMutex)}
29-
}
30-
31-
func (c Ref) RLock() {
32-
c.mut.RLock()
33-
}
34-
35-
func (c Ref) RUnlock() {
36-
c.mut.RUnlock()
28+
return Ref{mut: new(sync.Mutex)}
3729
}
3830

3931
func (c Ref) Lock() {

pkg/sshd/server.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ func sendExitStatus(status uint32, channel ssh.Channel) error {
180180
return err
181181
}
182182

183-
func (s *server) withCleanerRLock(f func() error) error {
184-
s.cleanerRef.RLock()
185-
defer s.cleanerRef.RUnlock()
183+
func (s *server) withCleanerLock(f func() error) error {
184+
s.cleanerRef.Lock()
185+
defer s.cleanerRef.Unlock()
186186
return f()
187187
}
188188

@@ -240,7 +240,7 @@ func (s *server) answer(channel ssh.Channel, requests <-chan *ssh.Request, sshCo
240240

241241
repoName := parts[1]
242242
errConcurrentPush := errors.New("concurrent push")
243-
err := s.withCleanerRLock(func() error {
243+
err := s.withCleanerLock(func() error {
244244
if err := s.pushLock.Lock(repoName, time.Duration(0)); err != nil {
245245
return errConcurrentPush
246246
}

0 commit comments

Comments
 (0)