-
Notifications
You must be signed in to change notification settings - Fork 38.7k
[qa] util: Poll cookie file size before reading #11129
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
Conversation
| 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: |
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.
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.
|
Thinking about this some more, an even better option would be to use POSIX rename atomicity at the
See #11131. |
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.
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
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
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.
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
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.