Skip to content

Commit

Permalink
spelling. cleanup logbuf locking
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasha committed Nov 30, 2017
1 parent cf2081d commit 03d40e5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions deadlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var Opts = struct {
// Waiting for a lock for longer than DeadlockTimeout is considered a deadlock.
// Ignored is DeadlockTimeout <= 0.
DeadlockTimeout time.Duration
// OnPotentialDeadlock is called each time a potential deadlock is deetcted -- either based on
// OnPotentialDeadlock is called each time a potential deadlock is detected -- either based on
// lock order or on lock wait time.
OnPotentialDeadlock func()
// Will keep MaxMapSize lock pairs (happens before // happens after) in the map.
Expand Down Expand Up @@ -51,7 +51,7 @@ type Mutex struct {
// If the lock is already in use, the calling goroutine
// blocks until the mutex is available.
//
// Unless deadlock detection is disabled, logs potential deadlocks to stderr,
// Unless deadlock detection is disabled, logs potential deadlocks to Opts.LogBuf,
// calling Opts.OnPotentialDeadlock on each occasion.
func (m *Mutex) Lock() {
lock(m.mu.Lock, m)
Expand Down Expand Up @@ -83,7 +83,7 @@ type RWMutex struct {
// a blocked Lock call excludes new readers from acquiring
// the lock.
//
// Unless deadlock detection is disabled, logs potential deadlocks to stderr,
// Unless deadlock detection is disabled, logs potential deadlocks to Opts.LogBuf,
// calling Opts.OnPotentialDeadlock on each occasion.
func (m *RWMutex) Lock() {
lock(m.mu.Lock, m)
Expand All @@ -104,7 +104,7 @@ func (m *RWMutex) Unlock() {

// RLock locks the mutex for reading.
//
// Unless deadlock detection is disabled, logs potential deadlocks to stderr,
// Unless deadlock detection is disabled, logs potential deadlocks to Opts.LogBuf,
// calling Opts.OnPotentialDeadlock on each occasion.
func (m *RWMutex) RLock() {
lock(m.mu.RLock, m)
Expand Down Expand Up @@ -185,12 +185,12 @@ func lock(lockFn func(), ptr interface{}) {
lo.other(ptr)
fmt.Fprintln(Opts.LogBuf, "All current goroutines:")
Opts.LogBuf.Write(stacks)
lo.mu.Unlock()
Opts.mu.Unlock()
fmt.Fprintln(Opts.LogBuf)
if buf, ok := Opts.LogBuf.(*bufio.Writer); ok {
buf.Flush()
}
lo.mu.Unlock()
Opts.mu.Unlock()
Opts.OnPotentialDeadlock()
<-ch
PostLock(4, ptr)
Expand Down

0 comments on commit 03d40e5

Please sign in to comment.