Commit 2d2b9225 authored by tzik's avatar tzik Committed by Commit Bot

Keep shared web::test::HttpServer instance alive

The web::test::HttpServer instance returned by GetSharedInstance has
zero reference count initially, HttpServer::StartOrDie implicitly
increments the reference count through base::Bind, and its
embedded_test_server_ destruction decrements the reference count.
That is, once the server stopped, the shared instance is destroyed, and
GetSharedInstance() starts returning a stale pointer.

After this CL, the resulting instance of GetSharedInstance has non-zero
reference count, so that it keeps alive after server stop.

Bug: 866456
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I1f13dff1e86d08efb28b5805ae73426b874a4f80
Reviewed-on: https://chromium-review.googlesource.com/1146881Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579314}
parent 7e36928e
...@@ -56,6 +56,7 @@ HttpServer& HttpServer::GetSharedInstance() { ...@@ -56,6 +56,7 @@ HttpServer& HttpServer::GetSharedInstance() {
static dispatch_once_t once; static dispatch_once_t once;
dispatch_once(&once, ^{ dispatch_once(&once, ^{
shared_instance = new HttpServer(); shared_instance = new HttpServer();
shared_instance->AddRef();
}); });
return *shared_instance; return *shared_instance;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment