Skip to content

Conversation

promag
Copy link
Contributor

@promag promag commented Jun 18, 2018

Fixes #11777. Closes #13485.

When calling RPC stop, there is a race when the event loop terminates before HTTPRequest::WriteReply and so the reply event fails to process. This happens because event_base_dispatch returns when there are no active or pending events, which is the case between InterruptHTTPServer and HTTPRequest::WriteReply.

@promag
Copy link
Contributor Author

promag commented Jun 18, 2018

@ken2812221 and @MarcoFalke please review.

@promag
Copy link
Contributor Author

promag commented Jun 18, 2018

By the way, this is only possible with libevent 2.1.8, so if this is accepted we have to change the minimum version

| libevent | [2.1.8-stable](https://github.com/libevent/libevent/releases) | 2.0.22 | No |  |  |

@ken2812221
Copy link
Contributor

ken2812221 commented Jun 18, 2018

How about we add an infinity timeout timer event before event_base_dispatch and delete it before event_base_loopexit? This might works with older version libevent. (Haven't tested)

@promag
Copy link
Contributor Author

promag commented Jun 18, 2018

@ken2812221 unless there is a strong reason to not bump libevent, that could work too. In that case, it should be enough to remove the timer (instead of event_base_loopexit) and then the event loop would terminate.

@fanquake fanquake requested a review from laanwj June 18, 2018 10:09
@maflcko
Copy link
Member

maflcko commented Jun 18, 2018

I am not sure what the exact policy for bumping the minimum version of a dependency is, but we should at least compile on Xenial, which doesn't come with 2.1.8.

@promag
Copy link
Contributor Author

promag commented Jun 18, 2018

Thanks @MarcoFalke, in that case I'll update with an alternative. WDYT about keeping this for 2.1.8 and provide an alternative for <2.1.8?

@fanquake
Copy link
Member

Thanks @MarcoFalke, in that case I'll update with an alternative. WDYT about keeping this for 2.1.8 and provide an alternative for <2.1.8?

That should be fine, we already do that elsewhere in the code IIRC.

@laanwj
Copy link
Member

laanwj commented Jun 18, 2018

Concept ACK.

Thanks @MarcoFalke, in that case I'll update with an alternative. WDYT about keeping this for 2.1.8 and provide an alternative for <2.1.8?

Yes, please do that. Especially the BSDs tend to come with ancient versions of libevent, so please don't change the minimum requirement but put this in #ifdefs.

@maflcko
Copy link
Member

maflcko commented Jun 18, 2018

WDYT about keeping this for 2.1.8 and provide an alternative for <2.1.8?

If the alternative has no downsides, I'd rather say just do the alternative and keep the code more concise and well tested. (note that travis and most developers don't run the old libevent versions)

@promag
Copy link
Contributor Author

promag commented Jun 19, 2018

Better fix in #13501.

@promag promag closed this Jun 19, 2018
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[qa] Tests occasionally raise http.client.RemoteDisconnected or BadStatusLine
5 participants