Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #958 from matjam/matjam947
Browse files Browse the repository at this point in the history
Added warning message to the lockfile waiting routine.
  • Loading branch information
sdboyer authored Aug 7, 2017
2 parents 52ed251 + 977e781 commit 11758a7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions internal/gps/source_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,24 @@ func NewSourceManager(cachedir string) (*SourceMgr, error) {
// If it's a TemporaryError, we retry every second. Otherwise, we fail
// permanently.
//
// TODO: After some time, we should emit some kind of warning that we're waiting
// for the lockfile to be released. #534 should be address before we will do that.
// TODO: #534 needs to be implemented to provide a better way to log warnings,
// but until then we will just use stderr.

// Implicit Time of 0.
var lasttime time.Time
err = lockfile.TryLock()
for err != nil {
nowtime := time.Now()
duration := nowtime.Sub(lasttime)

// The first time this is evaluated, duration will be very large as lasttime is 0.
// Unless time travel is invented and someone travels back to the year 1, we should
// be ok.
if duration > 15*time.Second {
fmt.Fprintf(os.Stderr, "waiting for lockfile %s: %s\n", glpath, err.Error())
lasttime = nowtime
}

if _, ok := err.(interface {
Temporary() bool
}); ok {
Expand Down

0 comments on commit 11758a7

Please sign in to comment.