Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Aug 24, 2017

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.

@maflcko maflcko added the Tests label Aug 24, 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:
Copy link
Member

@laanwj laanwj Aug 25, 2017

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.

@laanwj
Copy link
Member

laanwj commented Aug 25, 2017

Thinking about this some more, an even better option would be to use POSIX rename atomicity at the bitcoind side to create a working cookie atomically:

  • Write .cookie.tmp, close file
  • Rename .cookie.tmp to .cookie

See #11131.

@maflcko maflcko closed this Aug 25, 2017
@maflcko maflcko deleted the Mf1708-qaPollCookie branch August 25, 2017 13:01
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants