RPC-related hangs on shutdown #2739

issue jeremysawicki opened this issue on June 5, 2013
  1. jeremysawicki commented at 1:14 AM on June 5, 2013: none

    I have been debugging some RPC-related shutdown hangs in bitcoin-qt on windows. The behavior is worse in 0.8.2, but there were problems before 0.8.2 as well.

    1. In ServiceConnection, there is a loop that processes multiple requests from the same connection as long as "Connection: close" is not specified in the request. During application shutdown, nothing stops that processing, so a client can continue to make requests indefinitely using an already established connection. This is new in 0.8.2 -- in 0.8.1 there was a check for fShutdown before processing each request.
    2. If an RPC connection is blocked, for example in ReadHTTPRequestLine, shutdown can be delayed indefinitely while waiting for input from the client. That can happen due to a misbehaving client, but it can also happen with a well-behaved client that makes multiple requests on the same connection. After the first request and reply, we will reach ReadHTTPRequestLine and wait until the client has another request to make. This is not new in 0.8.2.

    For now I have worked around the problems by forcing ServiceConnection to close the connection after the first request in all cases. There is still a possibility of hangs if the client fails to send the first request promptly.

  2. gavinandresen commented at 2:53 AM on June 5, 2013: contributor

    The thread code plays nicely with boost::asio.

    I would guess any solution that keeps the calls to std::getline() will be problematic, because they don't get interrupted by boost::thread::interrupt.

  3. laanwj added the label RPC on May 9, 2014
  4. dgenr8 referenced this in commit 009f75d738 on Jul 10, 2014
  5. laanwj commented at 10:49 AM on May 18, 2015: member

    As of 0.10, command line argument -rpckeepalive=0 can be used to disable the keep-alive behavior. The underlying issue will only be solved by switching to another HTTP server. e.g. #5677.

  6. laanwj commented at 11:24 AM on October 27, 2015: member

    HTTP server has been switched to libevent, which properly times out connections, this issue should be solved now.

  7. laanwj closed this on Oct 27, 2015

  8. Bushstar referenced this in commit a34fb6d6f7 on Apr 5, 2019
  9. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me