Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #75 - Cleanup stale file handle #92

Merged
merged 1 commit into from
Oct 3, 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
10 changes: 9 additions & 1 deletion pkg/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
func GatherResults(waitfile string, url string) error {
var inputFileName []byte
var err error

Choose a reason for hiding this comment

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

delete this line, use err := on line 65

var outfile *os.File

// just loop looking for a file.
done := false

Choose a reason for hiding this comment

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

I know this is out of scope, but what about

for {
// do work
if err == nil {
// success!!
break
}
// log and wait
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Patches welcome ;-)
fwiw I didn't write this part of the code, I'm just trying to throw some fixes in before release.

Expand All @@ -60,9 +61,16 @@ func GatherResults(waitfile string, url string) error {
url += "." + filenameParts[1]

Choose a reason for hiding this comment

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

line 45: inputFileName is misleading, it's not the name of a file, it's the contents of waitfile.

}

defer func() {
if outfile != nil {
outfile.Close()
}
}()

// transmit back the results file.
return DoRequest(url, func() (io.Reader, error) {
outfile, err := os.Open(s)
outfile, err = os.Open(s)
return outfile, errors.WithStack(err)
})

}