You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2016/11/01 17:50:56 UTC
mesos git commit: Improve `Socket::connect` error message.
Repository: mesos
Updated Branches:
refs/heads/master b5683f234 -> 44797d703
Improve `Socket::connect` error message.
Rather than returning a fixed generic error when `connect(2)` fails,
report the actual socket error as well as the address we were trying
to connect to.
Review: https://reviews.apache.org/r/52997/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/44797d70
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/44797d70
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/44797d70
Branch: refs/heads/master
Commit: 44797d703e2af0e9cfb698b15de87994dc45a6a3
Parents: b5683f2
Author: James Peach <jp...@apache.org>
Authored: Mon Oct 31 17:24:33 2016 -0700
Committer: Michael Park <mp...@apache.org>
Committed: Tue Nov 1 10:44:10 2016 -0700
----------------------------------------------------------------------
3rdparty/libprocess/src/poll_socket.cpp | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/44797d70/3rdparty/libprocess/src/poll_socket.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/poll_socket.cpp b/3rdparty/libprocess/src/poll_socket.cpp
index d9ab3fb..f0ee149 100644
--- a/3rdparty/libprocess/src/poll_socket.cpp
+++ b/3rdparty/libprocess/src/poll_socket.cpp
@@ -111,7 +111,7 @@ Future<Socket> PollSocketImpl::accept()
namespace internal {
-Future<Nothing> connect(const Socket& socket)
+Future<Nothing> connect(const Socket& socket, const Address& to)
{
// Now check that a successful connection was made.
int opt;
@@ -125,11 +125,23 @@ Future<Nothing> connect(const Socket& socket)
SOL_SOCKET,
SO_ERROR,
reinterpret_cast<char*>(&opt),
- &optlen) < 0 ||
- opt != 0) {
- // Connect failure.
- VLOG(1) << "Socket error while connecting";
- return Failure("Socket error while connecting");
+ &optlen) < 0) {
+ return Failure(
+ SocketError("Failed to get status of connection to " + stringify(to)));
+ }
+
+ if (opt != 0) {
+ // Make the error visible to the `SocketError` constructor by pushing
+ // it into the global per-thread error. MESOS-6520 which should
+ // allow us to pass the error code directly into `SocketError`.
+
+#ifdef __WINDOWS__
+ ::WSASetLastError(opt);
+#else
+ errno = opt;
+#endif
+
+ return Failure(SocketError("Failed to connect to " + stringify(to)));
}
return Nothing();
@@ -144,7 +156,7 @@ Future<Nothing> PollSocketImpl::connect(const Address& address)
if (connect.isError()) {
if (net::is_inprogress_error(connect.error().code)) {
return io::poll(get(), io::WRITE)
- .then(lambda::bind(&internal::connect, socket()));
+ .then(lambda::bind(&internal::connect, socket(), address));
}
return Failure(connect.error());