[qa] util: Poll cookie file size before reading#11129
Closed
maflcko wants to merge 1 commit intobitcoin:masterfrom
Closed
[qa] util: Poll cookie file size before reading#11129maflcko wants to merge 1 commit intobitcoin:masterfrom
maflcko wants to merge 1 commit intobitcoin:masterfrom
Conversation
laanwj
reviewed
Aug 25, 2017
| while os.path.getsize(file_cookie) != len('__cookie__:') + 64: | ||
| # Wait for the file to be flushed | ||
| time.sleep(0.05) | ||
| with open(file_cookie, 'r') as f: |
Member
There was a problem hiding this comment.
Concept ACK, though I don't like doing this polling in get_auth_cookie itself - my preference would be to throw a AuthCookieIncomplete error or such, catch that in wait_for_rpc_connection and keep the polling restricted to there.
Edit: it could even just raise ValueError("No RPC credentials") - that's already checked for in that loop.
Member
|
Thinking about this some more, an even better option would be to use POSIX rename atomicity at the
See #11131. |
laanwj
added a commit
to laanwj/bitcoin
that referenced
this pull request
Aug 25, 2017
Use POSIX rename atomicity at the `bitcoind` side to create a working cookie atomically: - Write `.cookie.tmp`, close file - Rename `.cookie.tmp` to `.cookie` This avoids clients reading invalid/partial cookies as in bitcoin#11129.
laanwj
added a commit
that referenced
this pull request
Aug 28, 2017
82dd719 rpc: Write authcookie atomically (Wladimir J. van der Laan) Pull request description: Use POSIX rename atomicity at the `bitcoind` side to create a working cookie atomically: - Write `.cookie.tmp`, close file - Rename `.cookie.tmp` to `.cookie` This avoids clients reading invalid/partial cookies as in #11129. As such, this is an alternative to that PR. Tree-SHA512: 47fcc1ed2ff3d8fed4b7441e4939f29cc99b57b7a035673c3b55a124a2e49c8a904637a6ff700dd13a184be8c0255707d74781f8e626314916418954e2467e03
maflcko
pushed a commit
to maflcko/bitcoin-core
that referenced
this pull request
Oct 3, 2017
Use POSIX rename atomicity at the `bitcoind` side to create a working cookie atomically: - Write `.cookie.tmp`, close file - Rename `.cookie.tmp` to `.cookie` This avoids clients reading invalid/partial cookies as in bitcoin#11129. Github-Pull: bitcoin#11131 Rebased-From: 82dd719
HashUnlimited
pushed a commit
to chaincoin/chaincoin
that referenced
this pull request
Mar 9, 2018
Use POSIX rename atomicity at the `bitcoind` side to create a working cookie atomically: - Write `.cookie.tmp`, close file - Rename `.cookie.tmp` to `.cookie` This avoids clients reading invalid/partial cookies as in bitcoin#11129.
codablock
pushed a commit
to codablock/dash
that referenced
this pull request
Sep 25, 2019
82dd719 rpc: Write authcookie atomically (Wladimir J. van der Laan) Pull request description: Use POSIX rename atomicity at the `bitcoind` side to create a working cookie atomically: - Write `.cookie.tmp`, close file - Rename `.cookie.tmp` to `.cookie` This avoids clients reading invalid/partial cookies as in bitcoin#11129. As such, this is an alternative to that PR. Tree-SHA512: 47fcc1ed2ff3d8fed4b7441e4939f29cc99b57b7a035673c3b55a124a2e49c8a904637a6ff700dd13a184be8c0255707d74781f8e626314916418954e2467e03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have been seeing empty cookie files on travis infrastructure, but couldn't reproduce the issue locally. I assume it takes a bit longer to flush the file on travis. Thus, a sleep should work around that.