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

Added warning message to the lockfile waiting routine. #958

Merged
merged 2 commits into from
Aug 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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