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

chanbackup: always close SCB file after reading #4456

Merged
merged 1 commit into from
Jul 13, 2020

Conversation

Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented Jul 9, 2020

In this commit, we fix a bug introduced with the recent bug fix for SCB
state+fail combination. On windwos a rename operation will fail is the
fail one is attempting to rename is still open. Therefore we need to
close the file after we read the contents, to ensure the follow up
rename operations once the channel state changes will succeed.

Fixes #4450.

@Roasbeef Roasbeef added this to the 0.11.0 milestone Jul 9, 2020
@Roasbeef Roasbeef requested a review from wpaulino July 9, 2020 00:39
@@ -161,6 +161,9 @@ func (b *MultiFile) ExtractMulti(keyChain keychain.KeyRing) (*Multi, error) {
if err != nil {
return nil, err
}
if err := b.mainFile.Close(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be deferred?

Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to not use ioutil.ReadFile?

Copy link
Member Author

Choose a reason for hiding this comment

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

Switched to use ioutil.ReadFile confirmed that it uses a defer close internally.

@cfromknecht cfromknecht added v0.11 SCB Related to static channel backup bug fix labels Jul 9, 2020
@wpaulino wpaulino removed their request for review July 9, 2020 16:56
@Roasbeef Roasbeef requested a review from cfromknecht July 10, 2020 23:19
@Roasbeef Roasbeef force-pushed the windows-scb-close branch from 95f8dfb to fdd74e7 Compare July 10, 2020 23:19
@Roasbeef Roasbeef requested a review from wpaulino July 10, 2020 23:19
In this commit, we fix a bug introduced with the recent bug fix for SCB
state+fail combination. On windwos a rename operation will fail is the
fail one is attempting to rename is still open. Therefore we need to
close the file after we read the contents, to ensure the follow up
rename operations once the channel state changes will succeed. We do
this by using `ioutil.ReadFile`, which will always clsoe the file after
reading.

Fixes lightningnetwork#4450.
@Roasbeef Roasbeef force-pushed the windows-scb-close branch from fdd74e7 to c58be56 Compare July 10, 2020 23:21
Copy link
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix SCB Related to static channel backup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

windows incompatibility with new SCB logic
3 participants