Repository: mesos Updated Branches: refs/heads/master 50b7a3e0a -> 669a97eec
Remove support for omitting 202 responses to old libprocess clients. Prior to commit d5fe51c on April 11 2014, we needed to omit the 202 responses for libprocess messages because libprocess did not read the data from its message passing sockets. This change removes support for omitting the responses to old clients. This also means that any 3rdparty libprocess clients (e.g. someone's go library) need to be correctly reading from their sockets to communicate with libprocess after this change. Review: https://reviews.apache.org/r/61410 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/669a97ee Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/669a97ee Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/669a97ee Branch: refs/heads/master Commit: 669a97eec4d78d7bfef9c9b4b579dc2e19eb8412 Parents: 50b7a3e Author: Benjamin Mahler <[email protected]> Authored: Mon Jul 31 18:23:07 2017 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Thu Aug 3 11:28:47 2017 -0700 ---------------------------------------------------------------------- 3rdparty/libprocess/src/process.cpp | 27 ++++++++------------ 3rdparty/libprocess/src/tests/process_tests.cpp | 17 +++++------- 2 files changed, 17 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/669a97ee/3rdparty/libprocess/src/process.cpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp index af5a759..dcd9c67 100644 --- a/3rdparty/libprocess/src/process.cpp +++ b/3rdparty/libprocess/src/process.cpp @@ -3036,22 +3036,17 @@ void ProcessManager::handle( // capture happens-before timing relationships for testing. bool accepted = deliver(event->message.to, event); - // Only send back an HTTP response if this isn't from libprocess - // (which we determine by looking at the User-Agent). This is - // necessary because older versions of libprocess would try and - // recv the data and parse it as an HTTP request which would - // fail thus causing the socket to get closed (but now - // libprocess will ignore responses, see ignore_data). - Option<string> agent = request->headers.get("User-Agent"); - if (agent.getOrElse("").find("libprocess/") == string::npos) { - if (accepted) { - VLOG(2) << "Accepted libprocess message to " << request->url.path; - dispatch(proxy, &HttpProxy::enqueue, Accepted(), *request); - } else { - VLOG(1) << "Failed to handle libprocess message to " - << request->url.path << ": not found"; - dispatch(proxy, &HttpProxy::enqueue, NotFound(), *request); - } + // NOTE: prior to commit d5fe51c on April 11, 2014 we needed + // to ignore sending responses in the event the receiver was a + // version of libprocess that didn't properly ignore + // responses. Now we always send a response. + if (accepted) { + VLOG(2) << "Delivered libprocess message to " << request->url.path; + dispatch(proxy, &HttpProxy::enqueue, Accepted(), *request); + } else { + VLOG(1) << "Failed to deliver libprocess message to " + << request->url.path; + dispatch(proxy, &HttpProxy::enqueue, NotFound(), *request); } delete request; http://git-wip-us.apache.org/repos/asf/mesos/blob/669a97ee/3rdparty/libprocess/src/tests/process_tests.cpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/tests/process_tests.cpp b/3rdparty/libprocess/src/tests/process_tests.cpp index 30d0fb8..8d36600 100644 --- a/3rdparty/libprocess/src/tests/process_tests.cpp +++ b/3rdparty/libprocess/src/tests/process_tests.cpp @@ -1315,11 +1315,9 @@ TEST(ProcessTest, THREADSAFE_Http1) request.method = "POST"; request.url = url; request.headers["User-Agent"] = "libprocess/" + stringify(from); + request.keepAlive = true; request.body = "hello world"; - // Send the libprocess request. Note that we will not - // receive a 202 due to the use of the `User-Agent` - // header, therefore we need to explicitly disconnect! Future<http::Response> response = connection.send(request); AWAIT_READY(body); @@ -1328,7 +1326,7 @@ TEST(ProcessTest, THREADSAFE_Http1) AWAIT_READY(pid); ASSERT_EQ(from, pid.get()); - EXPECT_TRUE(response.isPending()); + AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::Accepted().status, response); AWAIT_READY(connection.disconnect()); @@ -1713,14 +1711,13 @@ TEST(ProcessTest, PercentEncodedURLs) request.method = "POST"; request.url = url; request.headers["User-Agent"] = "libprocess/" + stringify(from); + request.keepAlive = true; - // Send the libprocess request. Note that we will not - // receive a 202 due to the use of the `User-Agent` - // header, therefore we need to explicitly disconnect! Future<http::Response> response = connection.send(request); AWAIT_READY(handler1); - EXPECT_TRUE(response.isPending()); + + AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::Accepted().status, response); AWAIT_READY(connection.disconnect()); @@ -1733,9 +1730,7 @@ TEST(ProcessTest, PercentEncodedURLs) response = http::get(pid, "handler2"); - AWAIT_READY(response); - EXPECT_EQ(http::Status::OK, response->code); - EXPECT_EQ(http::Status::string(http::Status::OK), response->status); + AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response); terminate(process); wait(process);
