-
Notifications
You must be signed in to change notification settings - Fork 346
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one tiny comment
lgtm
pkg/worker/worker.go
Outdated
@@ -36,6 +36,7 @@ import ( | |||
func GatherResults(waitfile string, url string) error { | |||
var inputFileName []byte | |||
var err error | |||
var outfile * os.File |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gofmt this bad boy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, on save..
"go.formatOnSave": true,
"go.formatTool": "gofmt",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird!! When I save it it moves that * over to be var outfile *os.File
I literally don't care on this issue. Feel free to push.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know much about the history of DoRequest, but it looks like the API makes it hard to manage the lifetime of the io.Reader returned from the anon func.
pkg/worker/worker.go
Outdated
return outfile, errors.WithStack(err) | ||
err = DoRequest(url, func() (io.Reader, error) { | ||
outfile, e2 := os.Open(s) | ||
return outfile, errors.WithStack(e2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this; outfile on line 66 is in a different scope to line 39, so on line 70, outfile will always be nil.
I suggest
s/outfile/f here to make it clear that you're talking about a different variable.
@@ -36,6 +36,7 @@ import ( | |||
func GatherResults(waitfile string, url string) error { | |||
var inputFileName []byte | |||
var err error |
There was a problem hiding this comment.
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
Signed-off-by: Timothy St. Clair <[email protected]>
Thx for the quick review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor followups when you have a chance.
@@ -36,6 +36,7 @@ import ( | |||
func GatherResults(waitfile string, url string) error { | |||
var inputFileName []byte | |||
var err error | |||
var outfile *os.File | |||
|
|||
// just loop looking for a file. | |||
done := false |
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
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.
@@ -60,9 +61,16 @@ func GatherResults(waitfile string, url string) error { | |||
url += "." + filenameParts[1] |
There was a problem hiding this comment.
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.
Noted, I'll be the change I seek.
…On Tue, Oct 3, 2017 at 8:51 AM, Timothy St. Clair ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pkg/worker/worker.go
<#92 (comment)>:
> @@ -36,6 +36,7 @@ import (
func GatherResults(waitfile string, url string) error {
var inputFileName []byte
var err error
+ var outfile *os.File
// just loop looking for a file.
done := false
Patches welcome ;-)
fwiw I didn't write this part of the code, I'm just trying to throw some
fixes in before release.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#92 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA_PIQgBq192fldEvNca4S5jyJfu7ks5soZMZgaJpZM4PrSXs>
.
|
Fixes vmware-tanzu#75 - Cleanup stale file handle Signed-off-by: Jesse Hamilton [email protected]
Fixes vmware-tanzu#75 - Cleanup stale file handle Signed-off-by: Jesse Hamilton [email protected] Signed-off-by: Jesse Hamilton [email protected]
Fixes #75
Signed-off-by: Timothy St. Clair [email protected]