Commit 1ef69f23 authored by Victor Vasiliev's avatar Victor Vasiliev Committed by Commit Bot

[QuicTransportSimpleServer] Do not always exit() on UDP socket read errors

Instead, add a callback and only call exit in the CLI version

Bug: 1044513
Change-Id: Ic0fafb21fea42bf48434c38243f9ba27935eb526
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2019789
Commit-Queue: Victor Vasiliev <vasilvv@chromium.org>
Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735318}
parent add3a775
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "components/network_session_configurator/common/network_switches.h" #include "components/network_session_configurator/common/network_switches.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/test/content_browser_test.h" #include "content/public/test/content_browser_test.h"
...@@ -132,13 +131,7 @@ class QuicTransportTest : public ContentBrowserTest { ...@@ -132,13 +131,7 @@ class QuicTransportTest : public ContentBrowserTest {
QuicTransportSimpleServerWithThread server_; QuicTransportSimpleServerWithThread server_;
}; };
// TODO(crbug.com/1044513): Run this test on Windows. IN_PROC_BROWSER_TEST_F(QuicTransportTest, Echo) {
#if defined(OS_WIN)
#define MAYBE_Echo DISABLED_Echo
#else
#define MAYBE_Echo Echo
#endif
IN_PROC_BROWSER_TEST_F(QuicTransportTest, MAYBE_Echo) {
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
ASSERT_TRUE( ASSERT_TRUE(
NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html"))); NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html")));
......
...@@ -121,7 +121,7 @@ void QuicTransportSimpleServer::ProcessReadPacket(int result) { ...@@ -121,7 +121,7 @@ void QuicTransportSimpleServer::ProcessReadPacket(int result) {
LOG(ERROR) << "QuicTransportSimpleServer read failed: " LOG(ERROR) << "QuicTransportSimpleServer read failed: "
<< ErrorToString(result); << ErrorToString(result);
dispatcher_.Shutdown(); dispatcher_.Shutdown();
exit(EXIT_FAILURE); std::move(read_error_callback_).Run(result);
return; return;
} }
......
...@@ -24,6 +24,8 @@ namespace net { ...@@ -24,6 +24,8 @@ namespace net {
// received to the dispatcher. // received to the dispatcher.
class QuicTransportSimpleServer { class QuicTransportSimpleServer {
public: public:
using ReadErrorCallback = base::OnceCallback<void(int)>;
QuicTransportSimpleServer(int port, QuicTransportSimpleServer(int port,
std::vector<url::Origin> accepted_origins, std::vector<url::Origin> accepted_origins,
std::unique_ptr<quic::ProofSource> proof_source); std::unique_ptr<quic::ProofSource> proof_source);
...@@ -33,6 +35,10 @@ class QuicTransportSimpleServer { ...@@ -33,6 +35,10 @@ class QuicTransportSimpleServer {
IPEndPoint server_address() const { return server_address_; } IPEndPoint server_address() const { return server_address_; }
void set_read_error_callback(ReadErrorCallback callback) {
read_error_callback_ = std::move(callback);
}
private: private:
// Schedules a ReadPackets() call on the next iteration of the event loop. // Schedules a ReadPackets() call on the next iteration of the event loop.
void ScheduleReadPackets(); void ScheduleReadPackets();
...@@ -45,6 +51,8 @@ class QuicTransportSimpleServer { ...@@ -45,6 +51,8 @@ class QuicTransportSimpleServer {
const int port_; const int port_;
ReadErrorCallback read_error_callback_;
quic::QuicVersionManager version_manager_; quic::QuicVersionManager version_manager_;
quic::QuicChromiumClock* clock_; // Not owned. quic::QuicChromiumClock* clock_; // Not owned.
quic::QuicConfig config_; quic::QuicConfig config_;
......
...@@ -42,6 +42,8 @@ int main(int argc, char** argv) { ...@@ -42,6 +42,8 @@ int main(int argc, char** argv) {
net::QuicTransportSimpleServer server(GetQuicFlag(FLAGS_port), net::QuicTransportSimpleServer server(GetQuicFlag(FLAGS_port),
accepted_origins, accepted_origins,
quic::CreateDefaultProofSource()); quic::CreateDefaultProofSource());
server.set_read_error_callback(
base::BindOnce([](int /*result*/) { exit(EXIT_FAILURE); }));
if (server.Start() != EXIT_SUCCESS) if (server.Start() != EXIT_SUCCESS)
return EXIT_FAILURE; return EXIT_FAILURE;
......
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