HomePhabricator

http: Track active requests and wait for last to finish

Description

http: Track active requests and wait for last to finish

Summary:
Context from core#19420:

This PR calls evhttp_free before releasing event base. But according to evhttp_free docs:

Works only if no requests are currently being served.

So this PR also tracks active requests with libevent and waits for last request to finish. This requires libevent 2.1 due to evhttp_request_set_on_complete_cb (https://github.com/libevent/libevent/blob/master/whatsnew-2.1.txt).

Finally, the call to evhttp_free is done in the event base loop to avoid concurrency issues.

Now test/functional/feature_abortnode.py quits normally, not due to socket timeouts.

This is a backport of core#26742 and core#28551
Depends on D17303

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17304

Details

Provenance
João Barbosa <joao.paulo.barbosa@gmail.com>Authored on Jun 29 2020, 23:05
PiRKCommitted on Sat, Dec 7, 07:55
PiRKPushed on Sat, Dec 7, 07:55
Reviewer
Restricted Project
Differential Revision
D17304: http: Track active requests and wait for last to finish
Parents
rABCc087bf7278b1: build: Bump libevent minimum version up to 2.1.8
Branches
Unknown
Tags
Unknown