Skip to content
This repository was 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 1 commit
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
Prev Previous commit
Removed spurious comment.
Added spurious comment.
Modified logic to display warning initially, and then every 15 seconds, when lockfile busy.
  • Loading branch information
Nathan Ollerenshaw committed Aug 6, 2017
commit 977e7812464fcdb1f2afda6fc837574f0753d5aa
10 changes: 5 additions & 5 deletions internal/gps/source_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,17 @@ func NewSourceManager(cachedir string) (*SourceMgr, error) {
//
// TODO: #534 needs to be implemented to provide a better way to log warnings,
// but until then we will just use stderr.
//
// #947 appears to be caused by some locking issue; as this is the most likely
// culprit, we will add some warnings here, so every 15 seconds we will emit
// a warning to stderr that we're waiting for the lockfile.

lasttime := time.Now()
// 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like this will only print after each 15 second window, rather than printing once initially and then again once every 15 seconds, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the PR, as you're right.

fmt.Fprintf(os.Stderr, "waiting for lockfile %s: %s\n", glpath, err.Error())
lasttime = nowtime
Expand Down