Removed implicit logging from Socket::shutdown in favor of returning a Try.
Review: https://reviews.apache.org/r/38595 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b06e932a Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b06e932a Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b06e932a Branch: refs/heads/master Commit: b06e932a036044c54cd72ddde1d26c5f9271ea51 Parents: bfeb070 Author: Benjamin Mahler <[email protected]> Authored: Mon Sep 21 11:18:06 2015 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Mon Sep 28 10:38:01 2015 -0700 ---------------------------------------------------------------------- 3rdparty/libprocess/include/process/socket.hpp | 10 ++++++---- 3rdparty/libprocess/src/libevent_ssl_socket.cpp | 7 +++++-- 3rdparty/libprocess/src/libevent_ssl_socket.hpp | 2 +- 3rdparty/libprocess/src/process.cpp | 14 ++++++++++++-- 4 files changed, 24 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/b06e932a/3rdparty/libprocess/include/process/socket.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/socket.hpp b/3rdparty/libprocess/include/process/socket.hpp index a677e29..817cb37 100644 --- a/3rdparty/libprocess/include/process/socket.hpp +++ b/3rdparty/libprocess/include/process/socket.hpp @@ -168,11 +168,13 @@ public: // enabling reuse of a pool of preallocated strings/buffers. virtual Future<Nothing> send(const std::string& data); - virtual void shutdown() + virtual Try<Nothing> shutdown() { if (::shutdown(s, SHUT_RD) < 0) { - PLOG(ERROR) << "Shutdown failed on fd=" << s; + return ErrnoError(); } + + return Nothing(); } virtual Socket::Kind kind() const = 0; @@ -291,9 +293,9 @@ public: return impl->send(data); } - void shutdown() + Try<Nothing> shutdown() { - impl->shutdown(); + return impl->shutdown(); } private: http://git-wip-us.apache.org/repos/asf/mesos/blob/b06e932a/3rdparty/libprocess/src/libevent_ssl_socket.cpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/libevent_ssl_socket.cpp b/3rdparty/libprocess/src/libevent_ssl_socket.cpp index 80db6e8..52ae802 100644 --- a/3rdparty/libprocess/src/libevent_ssl_socket.cpp +++ b/3rdparty/libprocess/src/libevent_ssl_socket.cpp @@ -155,7 +155,7 @@ void LibeventSSLSocketImpl::initialize() } -void LibeventSSLSocketImpl::shutdown() +Try<Nothing> LibeventSSLSocketImpl::shutdown() { // Nothing to do if this socket was never initialized. synchronized (lock) { @@ -166,7 +166,8 @@ void LibeventSSLSocketImpl::shutdown() CHECK(recv_request.get() == NULL); CHECK(send_request.get() == NULL); - return; + errno = ENOTCONN; + return ErrnoError(); } } @@ -200,6 +201,8 @@ void LibeventSSLSocketImpl::shutdown() } }, DISALLOW_SHORT_CIRCUIT); + + return Nothing(); } http://git-wip-us.apache.org/repos/asf/mesos/blob/b06e932a/3rdparty/libprocess/src/libevent_ssl_socket.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/libevent_ssl_socket.hpp b/3rdparty/libprocess/src/libevent_ssl_socket.hpp index 3b17fa2..dc54c74 100644 --- a/3rdparty/libprocess/src/libevent_ssl_socket.hpp +++ b/3rdparty/libprocess/src/libevent_ssl_socket.hpp @@ -53,7 +53,7 @@ public: // This call is used to do the equivalent of shutting down the read // end. This means finishing the future of any outstanding read // request. - virtual void shutdown(); + virtual Try<Nothing> shutdown(); // We need a post-initializer because 'shared_from_this()' is not // valid until the constructor has finished. http://git-wip-us.apache.org/repos/asf/mesos/blob/b06e932a/3rdparty/libprocess/src/process.cpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp index c03fba4..7a2b911 100644 --- a/3rdparty/libprocess/src/process.cpp +++ b/3rdparty/libprocess/src/process.cpp @@ -1821,7 +1821,12 @@ Encoder* SocketManager::next(int s) // calling close the termination logic is not run twice. Socket* socket = iterator->second; sockets.erase(iterator); - socket->shutdown(); + + Try<Nothing> shutdown = socket->shutdown(); + if (shutdown.isError()) { + LOG(ERROR) << "Failed to shutdown socket with fd " << socket->get() + << ": " << shutdown.error(); + } delete socket; } @@ -1901,7 +1906,12 @@ void SocketManager::close(int s) // termination logic is not run twice. Socket* socket = iterator->second; sockets.erase(iterator); - socket->shutdown(); + + Try<Nothing> shutdown = socket->shutdown(); + if (shutdown.isError()) { + LOG(ERROR) << "Failed to shutdown socket with fd " << socket->get() + << ": " << shutdown.error(); + } delete socket; }
