rpc: work-around an upstream libevent bug
Summary:
A rare race condition may trigger while awaiting the body of a message, see
upsteam commit 5ff8eb26371c4dc56f384b2de35bea2d87814779 for details.
This may fix some reported rpc hangs/crashes.
Backport of Bitcoin Core PR#11593.
Completes T466.
Test Plan:
make check
test_runner.py
Following the only documented attempt I could find for replicating the bug: https://github.com/bitcoin/bitcoin/pull/11593#issuecomment-341489496
Running bitcoind -regtest in with while true; do curl -XGET --data-binary . 127.0.0.1:18444; done while doing rpc commands
This should output curl: (52) Empty reply from server (bug would rarely cause a crash)
Reviewers: jasonbcox, deadalnix, Fabien, O1 Bitcoin ABC, #bitcoin_abc
Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc
Subscribers: teamcity, schancel
Differential Revision: https://reviews.bitcoinabc.org/D2642