File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,14 +21,14 @@ func (e *LockError) Unwrap() error { return e.Err }
2121
2222// LockTimeout is how long Lock() will wait for the exclusive lock before
2323// giving up. With the lock held only during file writes (milliseconds),
24- // this timeout primarily guards against stuck or orphaned lock files .
24+ // this timeout primarily guards against a hung process holding the lock .
2525const LockTimeout = 5 * time .Second
2626
2727// lockRetryInterval is the sleep between non-blocking lock attempts.
2828const lockRetryInterval = 100 * time .Millisecond
2929
3030// FileLock provides an exclusive advisory lock on the stack file to prevent
31- // concurrent Load-Modify-Save races between multiple gh-stack processes.
31+ // concurrent writes between multiple gh-stack processes.
3232type FileLock struct {
3333 f * os.File
3434}
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ package stack
22
33import (
44 "fmt"
5+ "os"
6+ "path/filepath"
57 "sync"
68 "testing"
79 "time"
@@ -123,6 +125,9 @@ func TestLock_FileLeftOnDisk(t *testing.T) {
123125 lock .Unlock ()
124126
125127 // Lock file should still exist after unlock (no os.Remove race).
128+ _ , err = os .Stat (filepath .Join (dir , lockFileName ))
129+ require .NoError (t , err , "lock file should remain on disk after unlock" )
130+
126131 lock2 , err := Lock (dir )
127132 require .NoError (t , err , "should be able to re-lock after unlock" )
128133 lock2 .Unlock ()
You can’t perform that action at this time.
0 commit comments