Pardon a bit of iteration. This continues/fixes #6719.
event_base_loopexit
was not doing what I expected it to. What I expected was that it sets a timeout, given that no other pending events it would exit in N seconds. However, what it does was delay the event loop exit with N seconds, even if nothing is pending.
Solve it in a different way: give the event loop thread time to exit out of itself, and if it doesn’t, send loopbreak (and then join it).
This speeds up the RPC tests a lot, each exit incurred a 10 second overhead, with this change there should be no shutdown overhead in the common case and up to two seconds if the event loop is blocking.
As a bonus this breaks dependency on the global boost::thread_group, as the HTTP server minds its own offspring.
Time for rpctests with this patch:
0real 7m50.215s
1user 0m30.152s
2sys 0m11.752s
Without:
0real 13m12.069s
1user 0m30.412s
2sys 0m11.168s