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
refactor: replace goto with for #85
Changes from 3 commits
48b22d9
7478999
0cb9994
cfb465d
2157dfa
ab441c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,15 +90,14 @@ func NewS3(c S3Config, logfn Logf) (*S3, error) { | |
|
||
// Lock S3 has no compare-and-swap so this is no bulletproof solution, but should be good enough. | ||
func (l *S3) Lock() error { | ||
var tries uint | ||
retry: | ||
if (l.conf.MaxRetries - tries) > 0 { | ||
tries++ | ||
for tries := 0; tries < int(l.conf.MaxRetries); tries++ { | ||
l.logF("%s attempt %d", l.conf.Owner, tries) | ||
if l.isBusyDeletingExpired() { | ||
if tries >= int(l.conf.MaxRetries) { | ||
break | ||
} | ||
l.logF("%s failed, waiting %s", l.conf.Owner, l.conf.RetryBackoff.String()) | ||
time.Sleep(l.conf.RetryBackoff) | ||
goto retry | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something to escape the loop is needed if not busy , could be a else+break or something similar There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you mean? the for condition will exit the loop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. true! otherwise in case of long busy it will wait an extra time in the end before exiting
varas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
|
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 think this could be removed , the for condition prevents this case