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

Commit 11758a7

Browse files
authored
Merge pull request #958 from matjam/matjam947
Added warning message to the lockfile waiting routine.
2 parents 52ed251 + 977e781 commit 11758a7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

internal/gps/source_manager.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,24 @@ func NewSourceManager(cachedir string) (*SourceMgr, error) {
188188
// If it's a TemporaryError, we retry every second. Otherwise, we fail
189189
// permanently.
190190
//
191-
// TODO: After some time, we should emit some kind of warning that we're waiting
192-
// for the lockfile to be released. #534 should be address before we will do that.
191+
// TODO: #534 needs to be implemented to provide a better way to log warnings,
192+
// but until then we will just use stderr.
193193

194+
// Implicit Time of 0.
195+
var lasttime time.Time
194196
err = lockfile.TryLock()
195197
for err != nil {
198+
nowtime := time.Now()
199+
duration := nowtime.Sub(lasttime)
200+
201+
// The first time this is evaluated, duration will be very large as lasttime is 0.
202+
// Unless time travel is invented and someone travels back to the year 1, we should
203+
// be ok.
204+
if duration > 15*time.Second {
205+
fmt.Fprintf(os.Stderr, "waiting for lockfile %s: %s\n", glpath, err.Error())
206+
lasttime = nowtime
207+
}
208+
196209
if _, ok := err.(interface {
197210
Temporary() bool
198211
}); ok {

0 commit comments

Comments
 (0)