You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by dm...@apache.org on 2014/12/13 00:41:22 UTC
[1/5] mesos git commit: Fixed coding style issues related to the
variable naming convention in stout
Repository: mesos
Updated Branches:
refs/heads/master 87e299f3e -> a8ee2d320
Fixed coding style issues related to the variable naming convention in stout
Review: https://reviews.apache.org/r/28955
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6e2c8891
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6e2c8891
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6e2c8891
Branch: refs/heads/master
Commit: 6e2c8891c293c741cd311b3b38ad3bcbafba396e
Parents: 87e299f
Author: Evelina Dumitrescu <ev...@gmail.com>
Authored: Fri Dec 12 15:26:29 2014 -0800
Committer: Dominic Hamon <dh...@twitter.com>
Committed: Fri Dec 12 15:26:53 2014 -0800
----------------------------------------------------------------------
.../3rdparty/stout/include/stout/net.hpp | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/6e2c8891/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
index a7aed65..2f2298c 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
@@ -144,10 +144,10 @@ inline Try<std::string> hostname()
struct addrinfo ai = createAddrInfo(SOCK_STREAM, AF_INET, AI_CANONNAME);
struct addrinfo *aip;
- int err = getaddrinfo(host, NULL, &ai, &aip);
+ int error = getaddrinfo(host, NULL, &ai, &aip);
- if (err != 0 || aip == NULL) {
- return Error(gai_strerror(err));
+ if (error != 0 || aip == NULL) {
+ return Error(gai_strerror(error));
}
std::string hostname = aip->ai_canonname;
@@ -164,7 +164,7 @@ inline Try<std::string> getHostname(uint32_t ip)
sockaddr_in addr = createSockaddrIn(ip, 0);
char hostname[MAXHOSTNAMELEN];
- int err= getnameinfo(
+ int error = getnameinfo(
(sockaddr*)&addr,
sizeof(addr),
hostname,
@@ -172,8 +172,8 @@ inline Try<std::string> getHostname(uint32_t ip)
NULL,
0,
0);
- if (err != 0) {
- return Error(std::string(gai_strerror(err)));
+ if (error != 0) {
+ return Error(std::string(gai_strerror(error)));
}
return std::string(hostname);
@@ -186,9 +186,9 @@ inline Try<uint32_t> getIP(const std::string& hostname, sa_family_t family)
struct addrinfo ai, *aip;
ai = createAddrInfo(SOCK_STREAM, family, 0);
- int err = getaddrinfo(hostname.c_str(), NULL, &ai, &aip);
- if (err != 0 || aip == NULL) {
- return Error(gai_strerror(err));
+ int error = getaddrinfo(hostname.c_str(), NULL, &ai, &aip);
+ if (error != 0 || aip == NULL) {
+ return Error(gai_strerror(error));
}
if (aip->ai_addr == NULL) {
return Error("Got no addresses for '" + hostname + "'");
[2/5] mesos git commit: Fixed coding style issues related to the
variable naming convention in libprocess
Posted by dm...@apache.org.
Fixed coding style issues related to the variable naming convention in libprocess
Review: https://reviews.apache.org/r/28956
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/bd71c1fb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/bd71c1fb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/bd71c1fb
Branch: refs/heads/master
Commit: bd71c1fb3d291082974e66e667b1eb37f637bfb3
Parents: 6e2c889
Author: Evelina Dumitrescu <ev...@gmail.com>
Authored: Fri Dec 12 15:28:03 2014 -0800
Committer: Dominic Hamon <dh...@twitter.com>
Committed: Fri Dec 12 15:28:27 2014 -0800
----------------------------------------------------------------------
3rdparty/libprocess/include/process/socket.hpp | 12 ++++++------
3rdparty/libprocess/src/http.cpp | 6 +++---
3rdparty/libprocess/src/process.cpp | 12 ++++++------
3rdparty/libprocess/src/tests/http_tests.cpp | 6 +++---
3rdparty/libprocess/src/tests/process_tests.cpp | 12 ++++++------
5 files changed, 24 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/bd71c1fb/3rdparty/libprocess/include/process/socket.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/socket.hpp b/3rdparty/libprocess/include/process/socket.hpp
index 91f9084..9f6c847 100644
--- a/3rdparty/libprocess/include/process/socket.hpp
+++ b/3rdparty/libprocess/include/process/socket.hpp
@@ -62,24 +62,24 @@ inline Try<int> bind(int s, const Node& node)
{
sockaddr_in addr = net::createSockaddrIn(node.ip, node.port);
- int bound = ::bind(s, (sockaddr*) &addr, sizeof(addr));
- if (bound < 0) {
+ int error = ::bind(s, (sockaddr*) &addr, sizeof(addr));
+ if (error < 0) {
return ErrnoError("Failed to bind on " + stringify(node));
}
- return bound;
+ return error;
}
inline Try<int> connect(int s, const Node& node)
{
sockaddr_in addr = net::createSockaddrIn(node.ip, node.port);
- int connected = ::connect(s, (sockaddr*) &addr, sizeof(addr));
- if (connected < 0) {
+ int error = ::connect(s, (sockaddr*) &addr, sizeof(addr));
+ if (error < 0) {
return ErrnoError("Failed to connect to " + stringify(node));
}
- return connected;
+ return error;
}
inline Try<Node> getsockname(int s, sa_family_t family)
http://git-wip-us.apache.org/repos/asf/mesos/blob/bd71c1fb/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index 465e447..54f0e5d 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -82,10 +82,10 @@ Future<Response> request(
const string host = stringify(upid.node);
- Try<int> connected = process::connect(s, upid.node);
- if (connected.isError()) {
+ Try<int> connect = process::connect(s, upid.node);
+ if (connect.isError()) {
os::close(s);
- return Failure(connected.error());
+ return Failure(connect.error());
}
std::ostringstream out;
http://git-wip-us.apache.org/repos/asf/mesos/blob/bd71c1fb/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 688aebd..d4d823d 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -1281,14 +1281,14 @@ Future<Nothing> connect(const Socket& socket)
Future<Nothing> Socket::Impl::connect(const Node& node)
{
- Try<int> connected = process::connect(get(), node);
- if (connected.isError()) {
+ Try<int> connect = process::connect(get(), node);
+ if (connect.isError()) {
if (errno == EINPROGRESS) {
return io::poll(get(), io::WRITE)
.then(lambda::bind(&internal::connect, Socket(shared_from_this())));
}
- return Failure(connected.error());
+ return Failure(connect.error());
}
return Nothing();
@@ -1393,9 +1393,9 @@ Future<size_t> Socket::Impl::sendfile(int fd, off_t offset, size_t size)
Try<Node> Socket::Impl::bind(const Node& node)
{
- Try<int> bound = process::bind(get(), node);
- if (bound.isError()) {
- return Error(bound.error());
+ Try<int> bind = process::bind(get(), node);
+ if (bind.isError()) {
+ return Error(bind.error());
}
// Lookup and store assigned ip and assigned port.
http://git-wip-us.apache.org/repos/asf/mesos/blob/bd71c1fb/3rdparty/libprocess/src/tests/http_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp
index 3bda76d..ac7913c 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -114,11 +114,11 @@ TEST(HTTP, Endpoints)
spawn(process);
// First hit '/body' (using explicit sockets and HTTP/1.0).
- Try<int> sock = process::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
+ Try<int> socket = process::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
- ASSERT_TRUE(sock.isSome());
+ ASSERT_TRUE(socket.isSome());
- int s = sock.get();
+ int s = socket.get();
ASSERT_TRUE(process::connect(s, process.self().node).isSome());
http://git-wip-us.apache.org/repos/asf/mesos/blob/bd71c1fb/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 45be2e1..d0a3945 100644
--- a/3rdparty/libprocess/src/tests/process_tests.cpp
+++ b/3rdparty/libprocess/src/tests/process_tests.cpp
@@ -1419,11 +1419,11 @@ TEST(Process, remote)
EXPECT_CALL(process, handler(_, _))
.WillOnce(FutureSatisfy(&handler));
- Try<int> sock = process::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
+ Try<int> socket = process::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
- ASSERT_TRUE(sock.isSome());
+ ASSERT_TRUE(socket.isSome());
- int s = sock.get();
+ int s = socket.get();
ASSERT_TRUE(process::connect(s, process.self().node).isSome());
@@ -1485,10 +1485,10 @@ TEST(Process, http2)
spawn(process);
// Create a receiving socket so we can get messages back.
- Try<int> sock = process::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
- ASSERT_TRUE(sock.isSome());
+ Try<int> socket = process::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
+ ASSERT_TRUE(socket.isSome());
- int s = sock.get();
+ int s = socket.get();
ASSERT_TRUE(process::bind(s, Node()).isSome());
[5/5] mesos git commit: Introduce process::network namespace.
Posted by dm...@apache.org.
Introduce process::network namespace.
Introduce process::network namespace to encapsulate socket call wrappers
and Socket class.
Review: https://reviews.apache.org/r/28959
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a8ee2d32
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a8ee2d32
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a8ee2d32
Branch: refs/heads/master
Commit: a8ee2d320e5eedec0c3a295c7d9aa384342ab4b1
Parents: 16fc87a
Author: Evelina Dumitrescu <ev...@gmail.com>
Authored: Fri Dec 12 15:30:22 2014 -0800
Committer: Dominic Hamon <dh...@twitter.com>
Committed: Fri Dec 12 15:30:46 2014 -0800
----------------------------------------------------------------------
3rdparty/libprocess/include/process/event.hpp | 4 ++--
3rdparty/libprocess/include/process/socket.hpp | 6 ++++--
3rdparty/libprocess/src/decoder.hpp | 6 +++---
3rdparty/libprocess/src/encoder.hpp | 14 +++++++-------
3rdparty/libprocess/src/http.cpp | 4 ++--
3rdparty/libprocess/src/process.cpp | 9 +++++----
3rdparty/libprocess/src/tests/decoder_tests.cpp | 1 +
3rdparty/libprocess/src/tests/http_tests.cpp | 4 ++--
3rdparty/libprocess/src/tests/process_tests.cpp | 12 ++++++------
9 files changed, 32 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/a8ee2d32/3rdparty/libprocess/include/process/event.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/event.hpp b/3rdparty/libprocess/include/process/event.hpp
index 6392332..fa6beea 100644
--- a/3rdparty/libprocess/include/process/event.hpp
+++ b/3rdparty/libprocess/include/process/event.hpp
@@ -102,7 +102,7 @@ private:
struct HttpEvent : Event
{
- HttpEvent(const Socket& _socket, http::Request* _request)
+ HttpEvent(const network::Socket& _socket, http::Request* _request)
: socket(_socket), request(_request) {}
virtual ~HttpEvent()
@@ -115,7 +115,7 @@ struct HttpEvent : Event
visitor->visit(*this);
}
- const Socket socket;
+ const network::Socket socket;
http::Request* const request;
private:
http://git-wip-us.apache.org/repos/asf/mesos/blob/a8ee2d32/3rdparty/libprocess/include/process/socket.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/socket.hpp b/3rdparty/libprocess/include/process/socket.hpp
index 9f6c847..7e1e3f2 100644
--- a/3rdparty/libprocess/include/process/socket.hpp
+++ b/3rdparty/libprocess/include/process/socket.hpp
@@ -16,6 +16,7 @@
namespace process {
+namespace network {
// Returns a socket fd for the specified options. Note that on OS X,
// the returned socket will have the SO_NOSIGPIPE option set.
@@ -158,13 +159,13 @@ public:
// Supported in Linux >= 2.6.27.
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)
Try<int> fd =
- process::socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
+ network::socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
if (fd.isError()) {
ABORT("Failed to create socket: " + fd.error());
}
#else
- Try<int> fd = process::socket(AF_INET, SOCK_STREAM, 0);
+ Try<int> fd = network::socket(AF_INET, SOCK_STREAM, 0);
if (fd.isError()) {
ABORT("Failed to create socket: " + fd.error());
}
@@ -253,6 +254,7 @@ private:
std::shared_ptr<Impl> impl;
};
+} // namespace network {
} // namespace process {
#endif // __PROCESS_SOCKET_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/a8ee2d32/3rdparty/libprocess/src/decoder.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/decoder.hpp b/3rdparty/libprocess/src/decoder.hpp
index b66f378..8168464 100644
--- a/3rdparty/libprocess/src/decoder.hpp
+++ b/3rdparty/libprocess/src/decoder.hpp
@@ -23,7 +23,7 @@ namespace process {
class DataDecoder
{
public:
- explicit DataDecoder(const Socket& _s)
+ explicit DataDecoder(const network::Socket& _s)
: s(_s), failure(false), request(NULL)
{
settings.on_message_begin = &DataDecoder::on_message_begin;
@@ -67,7 +67,7 @@ public:
return failure;
}
- Socket socket() const
+ network::Socket socket() const
{
return s;
}
@@ -240,7 +240,7 @@ private:
return 0;
}
- const Socket s; // The socket this decoder is associated with.
+ const network::Socket s; // The socket this decoder is associated with.
bool failure;
http://git-wip-us.apache.org/repos/asf/mesos/blob/a8ee2d32/3rdparty/libprocess/src/encoder.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/encoder.hpp b/3rdparty/libprocess/src/encoder.hpp
index 7331e28..52dfd7f 100644
--- a/3rdparty/libprocess/src/encoder.hpp
+++ b/3rdparty/libprocess/src/encoder.hpp
@@ -37,7 +37,7 @@ public:
FILE
};
- explicit Encoder(const Socket& _s) : s(_s) {}
+ explicit Encoder(const network::Socket& _s) : s(_s) {}
virtual ~Encoder() {}
virtual Kind kind() const = 0;
@@ -46,20 +46,20 @@ public:
virtual size_t remaining() const = 0;
- Socket socket() const
+ network::Socket socket() const
{
return s;
}
private:
- const Socket s; // The socket this encoder is associated with.
+ const network::Socket s; // The socket this encoder is associated with.
};
class DataEncoder : public Encoder
{
public:
- DataEncoder(const Socket& s, const std::string& _data)
+ DataEncoder(const network::Socket& s, const std::string& _data)
: Encoder(s), data(_data), index(0) {}
virtual ~DataEncoder() {}
@@ -98,7 +98,7 @@ private:
class MessageEncoder : public DataEncoder
{
public:
- MessageEncoder(const Socket& s, Message* _message)
+ MessageEncoder(const network::Socket& s, Message* _message)
: DataEncoder(s, encode(_message)), message(_message) {}
virtual ~MessageEncoder()
@@ -153,7 +153,7 @@ class HttpResponseEncoder : public DataEncoder
{
public:
HttpResponseEncoder(
- const Socket& s,
+ const network::Socket& s,
const http::Response& response,
const http::Request& request)
: DataEncoder(s, encode(response, request)) {}
@@ -237,7 +237,7 @@ public:
class FileEncoder : public Encoder
{
public:
- FileEncoder(const Socket& s, int _fd, size_t _size)
+ FileEncoder(const network::Socket& s, int _fd, size_t _size)
: Encoder(s), fd(_fd), size(_size), index(0) {}
virtual ~FileEncoder()
http://git-wip-us.apache.org/repos/asf/mesos/blob/a8ee2d32/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index 54f0e5d..869b205 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -66,7 +66,7 @@ Future<Response> request(
const Option<string>& body,
const Option<string>& contentType)
{
- Try<int> socket = process::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
+ Try<int> socket = network::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
if (socket.isError()) {
return Failure("Failed to create socket: " + socket.error());
@@ -82,7 +82,7 @@ Future<Response> request(
const string host = stringify(upid.node);
- Try<int> connect = process::connect(s, upid.node);
+ Try<int> connect = network::connect(s, upid.node);
if (connect.isError()) {
os::close(s);
return Failure(connect.error());
http://git-wip-us.apache.org/repos/asf/mesos/blob/a8ee2d32/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index d4d823d..028b33e 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -97,6 +97,7 @@ using process::http::OK;
using process::http::Request;
using process::http::Response;
using process::http::ServiceUnavailable;
+using process::network::Socket;
using std::deque;
using std::find;
@@ -1281,7 +1282,7 @@ Future<Nothing> connect(const Socket& socket)
Future<Nothing> Socket::Impl::connect(const Node& node)
{
- Try<int> connect = process::connect(get(), node);
+ Try<int> connect = network::connect(get(), node);
if (connect.isError()) {
if (errno == EINPROGRESS) {
return io::poll(get(), io::WRITE)
@@ -1393,13 +1394,13 @@ Future<size_t> Socket::Impl::sendfile(int fd, off_t offset, size_t size)
Try<Node> Socket::Impl::bind(const Node& node)
{
- Try<int> bind = process::bind(get(), node);
+ Try<int> bind = network::bind(get(), node);
if (bind.isError()) {
return Error(bind.error());
}
// Lookup and store assigned ip and assigned port.
- return process::getsockname(get(), AF_INET);
+ return network::getsockname(get(), AF_INET);
}
@@ -1416,7 +1417,7 @@ namespace internal {
Future<Socket> accept(int fd)
{
- Try<int> accepted = process::accept(fd, AF_INET);
+ Try<int> accepted = network::accept(fd, AF_INET);
if (accepted.isError()) {
return Failure(accepted.error());
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/a8ee2d32/3rdparty/libprocess/src/tests/decoder_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/decoder_tests.cpp b/3rdparty/libprocess/src/tests/decoder_tests.cpp
index 04ca3ff..ef52798 100644
--- a/3rdparty/libprocess/src/tests/decoder_tests.cpp
+++ b/3rdparty/libprocess/src/tests/decoder_tests.cpp
@@ -15,6 +15,7 @@ using namespace process::http;
using std::deque;
using std::string;
+using process::network::Socket;
TEST(Decoder, Request)
{
http://git-wip-us.apache.org/repos/asf/mesos/blob/a8ee2d32/3rdparty/libprocess/src/tests/http_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp
index ac7913c..c71a91d 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -114,13 +114,13 @@ TEST(HTTP, Endpoints)
spawn(process);
// First hit '/body' (using explicit sockets and HTTP/1.0).
- Try<int> socket = process::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
+ Try<int> socket = network::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
ASSERT_TRUE(socket.isSome());
int s = socket.get();
- ASSERT_TRUE(process::connect(s, process.self().node).isSome());
+ ASSERT_TRUE(network::connect(s, process.self().node).isSome());
std::ostringstream out;
out << "GET /" << process.self().id << "/body"
http://git-wip-us.apache.org/repos/asf/mesos/blob/a8ee2d32/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 d0a3945..3bbfe0a 100644
--- a/3rdparty/libprocess/src/tests/process_tests.cpp
+++ b/3rdparty/libprocess/src/tests/process_tests.cpp
@@ -1419,13 +1419,13 @@ TEST(Process, remote)
EXPECT_CALL(process, handler(_, _))
.WillOnce(FutureSatisfy(&handler));
- Try<int> socket = process::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
+ Try<int> socket = network::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
ASSERT_TRUE(socket.isSome());
int s = socket.get();
- ASSERT_TRUE(process::connect(s, process.self().node).isSome());
+ ASSERT_TRUE(network::connect(s, process.self().node).isSome());
Message message;
message.name = "handler";
@@ -1485,16 +1485,16 @@ TEST(Process, http2)
spawn(process);
// Create a receiving socket so we can get messages back.
- Try<int> socket = process::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
+ Try<int> socket = network::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
ASSERT_TRUE(socket.isSome());
int s = socket.get();
- ASSERT_TRUE(process::bind(s, Node()).isSome());
+ ASSERT_TRUE(network::bind(s, Node()).isSome());
// Create a UPID for 'Libprocess-From' based on the IP and port we
// got assigned.
- Try<Node> node = process::getsockname(s, AF_INET);
+ Try<Node> node = network::getsockname(s, AF_INET);
ASSERT_TRUE(node.isSome());
UPID from("", node.get());
@@ -1527,7 +1527,7 @@ TEST(Process, http2)
post(process.self(), from, name);
// Accept the incoming connection.
- Try<int> accepted = process::accept(s, AF_INET);
+ Try<int> accepted = network::accept(s, AF_INET);
ASSERT_TRUE(accepted.isSome());
int c = accepted.get();
[4/5] mesos git commit: Renamed getaddrinfo arguments to be more
suggestive
Posted by dm...@apache.org.
Renamed getaddrinfo arguments to be more suggestive
Also add missing call to freeaddrinfo when the call fails
Review: https://reviews.apache.org/r/28958
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/16fc87a1
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/16fc87a1
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/16fc87a1
Branch: refs/heads/master
Commit: 16fc87a1c62434c8f6a433c2e916b78f3aa5ae15
Parents: e864025
Author: Evelina Dumitrescu <ev...@gmail.com>
Authored: Fri Dec 12 15:29:31 2014 -0800
Committer: Dominic Hamon <dh...@twitter.com>
Committed: Fri Dec 12 15:29:54 2014 -0800
----------------------------------------------------------------------
.../3rdparty/stout/include/stout/net.hpp | 33 ++++++++++++--------
1 file changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/16fc87a1/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
index 2f2298c..80578e2 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
@@ -141,17 +141,20 @@ inline Try<std::string> hostname()
}
// TODO(evelinad): Add AF_UNSPEC when we will support IPv6
- struct addrinfo ai = createAddrInfo(SOCK_STREAM, AF_INET, AI_CANONNAME);
- struct addrinfo *aip;
+ struct addrinfo hints = createAddrInfo(SOCK_STREAM, AF_INET, AI_CANONNAME);
+ struct addrinfo *result;
- int error = getaddrinfo(host, NULL, &ai, &aip);
+ int error = getaddrinfo(host, NULL, &hints, &result);
- if (error != 0 || aip == NULL) {
+ if (error != 0 || result == NULL) {
+ if (result != NULL) {
+ freeaddrinfo(result);
+ }
return Error(gai_strerror(error));
}
- std::string hostname = aip->ai_canonname;
- freeaddrinfo(aip);
+ std::string hostname = result->ai_canonname;
+ freeaddrinfo(result);
return hostname;
}
@@ -183,19 +186,23 @@ inline Try<std::string> getHostname(uint32_t ip)
// obtained.
inline Try<uint32_t> getIP(const std::string& hostname, sa_family_t family)
{
- struct addrinfo ai, *aip;
- ai = createAddrInfo(SOCK_STREAM, family, 0);
+ struct addrinfo hints, *result;
+ hints = createAddrInfo(SOCK_STREAM, family, 0);
- int error = getaddrinfo(hostname.c_str(), NULL, &ai, &aip);
- if (error != 0 || aip == NULL) {
+ int error = getaddrinfo(hostname.c_str(), NULL, &hints, &result);
+ if (error != 0 || result == NULL) {
+ if (result != NULL ) {
+ freeaddrinfo(result);
+ }
return Error(gai_strerror(error));
}
- if (aip->ai_addr == NULL) {
+ if (result->ai_addr == NULL) {
+ freeaddrinfo(result);
return Error("Got no addresses for '" + hostname + "'");
}
- uint32_t ip = ((struct sockaddr_in*)(aip->ai_addr))->sin_addr.s_addr;
- freeaddrinfo(aip);
+ uint32_t ip = ((struct sockaddr_in*)(result->ai_addr))->sin_addr.s_addr;
+ freeaddrinfo(result);
return ip;
}
[3/5] mesos git commit: Fixed coding style issues related to the
variable naming convention in the routing library
Posted by dm...@apache.org.
Fixed coding style issues related to the variable naming convention in the routing library
Review: https://reviews.apache.org/r/28957
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e864025b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e864025b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e864025b
Branch: refs/heads/master
Commit: e864025ba9d44e818ae1da6943ae47be4974191d
Parents: bd71c1f
Author: Evelina Dumitrescu <ev...@gmail.com>
Authored: Fri Dec 12 15:28:45 2014 -0800
Committer: Dominic Hamon <dh...@twitter.com>
Committed: Fri Dec 12 15:29:08 2014 -0800
----------------------------------------------------------------------
src/linux/routing/diagnosis/diagnosis.cpp | 12 +-
src/linux/routing/filter/arp.cpp | 6 +-
src/linux/routing/filter/icmp.cpp | 28 ++--
src/linux/routing/filter/internal.hpp | 176 ++++++++++++-------------
src/linux/routing/filter/ip.cpp | 52 ++++----
src/linux/routing/internal.hpp | 8 +-
src/linux/routing/link/internal.hpp | 32 ++---
src/linux/routing/link/link.cpp | 48 +++----
src/linux/routing/queueing/ingress.cpp | 6 +-
src/linux/routing/queueing/internal.hpp | 62 ++++-----
src/linux/routing/route.cpp | 16 +--
11 files changed, 223 insertions(+), 223 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e864025b/src/linux/routing/diagnosis/diagnosis.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/diagnosis/diagnosis.cpp b/src/linux/routing/diagnosis/diagnosis.cpp
index d826ae2..136ba37 100644
--- a/src/linux/routing/diagnosis/diagnosis.cpp
+++ b/src/linux/routing/diagnosis/diagnosis.cpp
@@ -50,15 +50,15 @@ static Option<net::IP> IP(nl_addr* _ip)
Try<vector<Info> > infos(int family, int states)
{
- Try<Netlink<struct nl_sock> > sock = routing::socket(NETLINK_INET_DIAG);
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket(NETLINK_INET_DIAG);
+ if (socket.isError()) {
+ return Error(socket.error());
}
struct nl_cache* c = NULL;
- int err = idiagnl_msg_alloc_cache(sock.get().get(), family, states, &c);
- if (err != 0) {
- return Error(nl_geterror(err));
+ int error = idiagnl_msg_alloc_cache(socket.get().get(), family, states, &c);
+ if (error != 0) {
+ return Error(nl_geterror(error));
}
Netlink<struct nl_cache> cache(c);
http://git-wip-us.apache.org/repos/asf/mesos/blob/e864025b/src/linux/routing/filter/arp.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/arp.cpp b/src/linux/routing/filter/arp.cpp
index b794a73..bf19264 100644
--- a/src/linux/routing/filter/arp.cpp
+++ b/src/linux/routing/filter/arp.cpp
@@ -76,11 +76,11 @@ Try<Nothing> encode<arp::Classifier>(
{
rtnl_cls_set_protocol(cls.get(), ETH_P_ARP);
- int err = rtnl_tc_set_kind(TC_CAST(cls.get()), "basic");
- if (err != 0) {
+ int error = rtnl_tc_set_kind(TC_CAST(cls.get()), "basic");
+ if (error != 0) {
return Error(
"Failed to set the kind of the classifier: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
return Nothing();
http://git-wip-us.apache.org/repos/asf/mesos/blob/e864025b/src/linux/routing/filter/icmp.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/icmp.cpp b/src/linux/routing/filter/icmp.cpp
index 12b9eb7..86bd67b 100644
--- a/src/linux/routing/filter/icmp.cpp
+++ b/src/linux/routing/filter/icmp.cpp
@@ -68,11 +68,11 @@ Try<Nothing> encode<icmp::Classifier>(
// ICMP packets are one type of IP packets.
rtnl_cls_set_protocol(cls.get(), ETH_P_IP);
- int err = rtnl_tc_set_kind(TC_CAST(cls.get()), "u32");
- if (err != 0) {
+ int error = rtnl_tc_set_kind(TC_CAST(cls.get()), "u32");
+ if (error != 0) {
return Error(
"Failed to set the kind of the classifier: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
// To avoid confusion, we only use u32 selectors which are used to
@@ -88,32 +88,32 @@ Try<Nothing> encode<icmp::Classifier>(
uint32_t mask = 0x00ff0000; // Ignore offset 8, 10, 11.
// To match ICMP packets (protocol = 1).
- err = rtnl_u32_add_key(
+ error = rtnl_u32_add_key(
cls.get(),
htonl(protocol),
htonl(mask),
8, // Offset from which to start matching.
0);
- if (err != 0) {
+ if (error != 0) {
return Error(
"Failed to add selector for IP protocol: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
if (classifier.destinationIP().isSome()) {
// To match those IP packets that have the given destination IP.
- err = rtnl_u32_add_key(
+ error = rtnl_u32_add_key(
cls.get(),
htonl(classifier.destinationIP().get().address()),
htonl(0xffffffff),
16, // Offset from which to start matching.
0);
- if (err != 0) {
+ if (error != 0) {
return Error(
"Failed to add selector for destination IP address: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
}
@@ -145,7 +145,7 @@ Result<icmp::Classifier> decode<icmp::Classifier>(
int offsetmask;
// Decode a selector from the libnl filter 'cls'.
- int err = rtnl_u32_get_key(
+ int error = rtnl_u32_get_key(
cls.get(),
i,
&value,
@@ -153,17 +153,17 @@ Result<icmp::Classifier> decode<icmp::Classifier>(
&offset,
&offsetmask);
- if (err != 0) {
- if (err == -NLE_INVAL) {
+ if (error != 0) {
+ if (error == -NLE_INVAL) {
// This is the case where cls does not have a u32 selector. In
// that case, we just return None.
return None();
- } else if (err == -NLE_RANGE) {
+ } else if (error == -NLE_RANGE) {
break;
} else {
return Error(
"Failed to decode a u32 selector: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/e864025b/src/linux/routing/filter/internal.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/internal.hpp b/src/linux/routing/filter/internal.hpp
index a970613..8a6c0c0 100644
--- a/src/linux/routing/filter/internal.hpp
+++ b/src/linux/routing/filter/internal.hpp
@@ -89,7 +89,7 @@ inline Try<Nothing> attach(
const Netlink<struct rtnl_cls>& cls,
const action::Redirect& redirect)
{
- Result<Netlink<struct rtnl_link> > link =
+ Result<Netlink<struct rtnl_link>> link =
link::internal::get(redirect.link());
if (link.isError()) {
@@ -108,12 +108,12 @@ inline Try<Nothing> attach(
// Set the kind of the action to 'mirred'. The kind 'mirred' stands
// for mirror or redirect actions.
- int err = rtnl_tc_set_kind(TC_CAST(act), "mirred");
- if (err != 0) {
+ int error = rtnl_tc_set_kind(TC_CAST(act), "mirred");
+ if (error != 0) {
rtnl_act_put(act);
return Error(
"Failed to set the kind of the action: " +
- std::string(nl_geterror(err)));
+ std::string(nl_geterror(error)));
}
rtnl_mirred_set_ifindex(act, rtnl_link_get_ifindex(link.get().get()));
@@ -122,25 +122,25 @@ inline Try<Nothing> attach(
const std::string kind = rtnl_tc_get_kind(TC_CAST(cls.get()));
if (kind == "basic") {
- err = rtnl_basic_add_action(cls.get(), act);
- if (err != 0) {
+ error = rtnl_basic_add_action(cls.get(), act);
+ if (error != 0) {
rtnl_act_put(act);
- return Error(std::string(nl_geterror(err)));
+ return Error(std::string(nl_geterror(error)));
}
} else if (kind == "u32") {
- err = rtnl_u32_add_action(cls.get(), act);
- if (err != 0) {
+ error = rtnl_u32_add_action(cls.get(), act);
+ if (error != 0) {
rtnl_act_put(act);
- return Error(std::string(nl_geterror(err)));
+ return Error(std::string(nl_geterror(error)));
}
// Automatically set the 'terminal' flag for u32 filters if a
// redirect action is attached.
- err = rtnl_u32_set_cls_terminal(cls.get());
- if (err != 0) {
+ error = rtnl_u32_set_cls_terminal(cls.get());
+ if (error != 0) {
return Error(
"Failed to set the terminal flag: " +
- std::string(nl_geterror(err)));
+ std::string(nl_geterror(error)));
}
} else {
rtnl_act_put(act);
@@ -159,7 +159,7 @@ inline Try<Nothing> attach(
const std::string kind = rtnl_tc_get_kind(TC_CAST(cls.get()));
foreach (const std::string& _link, mirror.links()) {
- Result<Netlink<struct rtnl_link> > link = link::internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
@@ -174,12 +174,12 @@ inline Try<Nothing> attach(
return Error("Failed to allocate a libnl action (rtnl_act)");
}
- int err = rtnl_tc_set_kind(TC_CAST(act), "mirred");
- if (err != 0) {
+ int error = rtnl_tc_set_kind(TC_CAST(act), "mirred");
+ if (error != 0) {
rtnl_act_put(act);
return Error(
"Failed to set the kind of the action: " +
- std::string(nl_geterror(err)));
+ std::string(nl_geterror(error)));
}
rtnl_mirred_set_ifindex(act, rtnl_link_get_ifindex(link.get().get()));
@@ -187,16 +187,16 @@ inline Try<Nothing> attach(
rtnl_mirred_set_policy(act, TC_ACT_PIPE);
if (kind == "basic") {
- err = rtnl_basic_add_action(cls.get(), act);
- if (err != 0) {
+ error = rtnl_basic_add_action(cls.get(), act);
+ if (error != 0) {
rtnl_act_put(act);
- return Error(std::string(nl_geterror(err)));
+ return Error(std::string(nl_geterror(error)));
}
} else if (kind == "u32") {
- err = rtnl_u32_add_action(cls.get(), act);
- if (err != 0) {
+ error = rtnl_u32_add_action(cls.get(), act);
+ if (error != 0) {
rtnl_act_put(act);
- return Error(std::string(nl_geterror(err)));
+ return Error(std::string(nl_geterror(error)));
}
} else {
rtnl_act_put(act);
@@ -207,11 +207,11 @@ inline Try<Nothing> attach(
// Automatically set the 'terminal' flag for u32 filters if a mirror
// action is attached.
if (kind == "u32") {
- int err = rtnl_u32_set_cls_terminal(cls.get());
- if (err != 0) {
+ int error = rtnl_u32_set_cls_terminal(cls.get());
+ if (error != 0) {
return Error(
"Failed to set the terminal flag: " +
- std::string(nl_geterror(err)));
+ std::string(nl_geterror(error)));
}
}
@@ -233,11 +233,11 @@ inline Try<Nothing> attach(
return Error("Cannot attach terminal action to a non-u32 filter.");
}
- int err = rtnl_u32_set_cls_terminal(cls.get());
- if (err != 0) {
+ int error = rtnl_u32_set_cls_terminal(cls.get());
+ if (error != 0) {
return Error(
"Failed to set the terminal flag: " +
- std::string(nl_geterror(err)));
+ std::string(nl_geterror(error)));
}
return Nothing();
@@ -288,24 +288,24 @@ Result<U32Handle> generateU32Handle(
}
// Scan all the filters attached to the given parent on the link.
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
// Dump all the libnl filters (i.e., rtnl_cls) attached to the given
// parent on the link.
struct nl_cache* c = NULL;
- int err = rtnl_cls_alloc_cache(
- sock.get().get(),
+ int error = rtnl_cls_alloc_cache(
+ socket.get().get(),
rtnl_link_get_ifindex(link.get()),
filter.parent().get(),
&c);
- if (err != 0) {
+ if (error != 0) {
return Error(
"Failed to get filter info from kernel: " +
- std::string(nl_geterror(err)));
+ std::string(nl_geterror(error)));
}
Netlink<struct nl_cache> cache(c);
@@ -314,7 +314,7 @@ Result<U32Handle> generateU32Handle(
hashmap<uint16_t, uint32_t> htids;
// A map from 'htid' to a set of already used nodes.
- hashmap<uint32_t, hashset<uint32_t> > nodes;
+ hashmap<uint32_t, hashset<uint32_t>> nodes;
for (struct nl_object* o = nl_cache_get_first(cache.get());
o != NULL; o = nl_cache_get_next(o)) {
@@ -356,7 +356,7 @@ Result<U32Handle> generateU32Handle(
// (rtnl_cls). We use template here so that it works for any type of
// classifier.
template <typename Classifier>
-Try<Netlink<struct rtnl_cls> > encodeFilter(
+Try<Netlink<struct rtnl_cls>> encodeFilter(
const Netlink<struct rtnl_link>& link,
const Filter<Classifier>& filter)
{
@@ -423,7 +423,7 @@ Try<Netlink<struct rtnl_cls> > encodeFilter(
// classifier type. We use template here so that it works for any type
// of classifier.
template <typename Classifier>
-Result<Filter<Classifier> > decodeFilter(const Netlink<struct rtnl_cls>& cls)
+Result<Filter<Classifier>> decodeFilter(const Netlink<struct rtnl_cls>& cls)
{
// If the handle of the libnl filer is 0, it means that it is an
// internal filter, therefore is definitly not created by us.
@@ -464,33 +464,33 @@ Result<Filter<Classifier> > decodeFilter(const Netlink<struct rtnl_cls>& cls)
// Returns all the libnl filters (rtnl_cls) attached to the given
// parent on the link.
-inline Try<std::vector<Netlink<struct rtnl_cls> > > getClses(
+inline Try<std::vector<Netlink<struct rtnl_cls>>> getClses(
const Netlink<struct rtnl_link>& link,
const queueing::Handle& parent)
{
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
// Dump all the libnl filters (i.e., rtnl_cls) attached to the given
// parent on the link.
struct nl_cache* c = NULL;
- int err = rtnl_cls_alloc_cache(
- sock.get().get(),
+ int error = rtnl_cls_alloc_cache(
+ socket.get().get(),
rtnl_link_get_ifindex(link.get()),
parent.get(),
&c);
- if (err != 0) {
+ if (error != 0) {
return Error(
"Failed to get filter info from kernel: " +
- std::string(nl_geterror(err)));
+ std::string(nl_geterror(error)));
}
Netlink<struct nl_cache> cache(c);
- std::vector<Netlink<struct rtnl_cls> > results;
+ std::vector<Netlink<struct rtnl_cls>> results;
for (struct nl_object* o = nl_cache_get_first(cache.get());
o != NULL; o = nl_cache_get_next(o)) {
@@ -507,12 +507,12 @@ inline Try<std::vector<Netlink<struct rtnl_cls> > > getClses(
// no match has been found. We use template here so that it works for
// any type of classifier.
template <typename Classifier>
-Result<Netlink<struct rtnl_cls> > getCls(
+Result<Netlink<struct rtnl_cls>> getCls(
const Netlink<struct rtnl_link>& link,
const queueing::Handle& parent,
const Classifier& classifier)
{
- Try<std::vector<Netlink<struct rtnl_cls> > > clses = getClses(link, parent);
+ Try<std::vector<Netlink<struct rtnl_cls>>> clses = getClses(link, parent);
if (clses.isError()) {
return Error(clses.error());
}
@@ -521,7 +521,7 @@ Result<Netlink<struct rtnl_cls> > getCls(
// The decode function will return None if 'cls' does not match
// the classifier type. In that case, we just move on to the next
// libnl filter.
- Result<Filter<Classifier> > filter = decodeFilter<Classifier>(cls);
+ Result<Filter<Classifier>> filter = decodeFilter<Classifier>(cls);
if (filter.isError()) {
return Error("Failed to decode: " + filter.error());
} else if (filter.isSome() && filter.get().classifier() == classifier) {
@@ -545,14 +545,14 @@ Try<bool> exists(
const queueing::Handle& parent,
const Classifier& classifier)
{
- Result<Netlink<struct rtnl_link> > link = link::internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
return false;
}
- Result<Netlink<struct rtnl_cls> > cls =
+ Result<Netlink<struct rtnl_cls>> cls =
getCls(link.get(), parent, classifier);
if (cls.isError()) {
@@ -581,33 +581,33 @@ Try<bool> create(const std::string& _link, const Filter<Classifier>& filter)
return false;
}
- Result<Netlink<struct rtnl_link> > link = link::internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
return Error("Link '" + _link + "' is not found");
}
- Try<Netlink<struct rtnl_cls> > cls = encodeFilter(link.get(), filter);
+ Try<Netlink<struct rtnl_cls>> cls = encodeFilter(link.get(), filter);
if (cls.isError()) {
return Error("Failed to encode the filter: " + cls.error());
}
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
- int err = rtnl_cls_add(
- sock.get().get(),
+ int error = rtnl_cls_add(
+ socket.get().get(),
cls.get().get(),
NLM_F_CREATE | NLM_F_EXCL);
- if (err != 0) {
- if (err == -NLE_EXIST) {
+ if (error != 0) {
+ if (error == -NLE_EXIST) {
return false;
} else {
- return Error(std::string(nl_geterror(err)));
+ return Error(std::string(nl_geterror(error)));
}
}
@@ -625,14 +625,14 @@ Try<bool> remove(
const queueing::Handle& parent,
const Classifier& classifier)
{
- Result<Netlink<struct rtnl_link> > link = link::internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
return false;
}
- Result<Netlink<struct rtnl_cls> > cls =
+ Result<Netlink<struct rtnl_cls>> cls =
getCls(link.get(), parent, classifier);
if (cls.isError()) {
@@ -641,16 +641,16 @@ Try<bool> remove(
return false;
}
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
- int err = rtnl_cls_delete(sock.get().get(), cls.get().get(), 0);
- if (err != 0) {
+ int error = rtnl_cls_delete(socket.get().get(), cls.get().get(), 0);
+ if (error != 0) {
// TODO(jieyu): Interpret the error code and return false if it
// indicates that the filter is not found.
- return Error(std::string(nl_geterror(err)));
+ return Error(std::string(nl_geterror(error)));
}
return true;
@@ -664,7 +664,7 @@ Try<bool> remove(
template <typename Classifier>
Try<bool> update(const std::string& _link, const Filter<Classifier>& filter)
{
- Result<Netlink<struct rtnl_link> > link = link::internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
@@ -672,7 +672,7 @@ Try<bool> update(const std::string& _link, const Filter<Classifier>& filter)
}
// Get the old libnl classifier (to-be-updated) from kernel.
- Result<Netlink<struct rtnl_cls> > oldCls =
+ Result<Netlink<struct rtnl_cls>> oldCls =
getCls(link.get(), filter.parent(), filter.classifier());
if (oldCls.isError()) {
@@ -704,7 +704,7 @@ Try<bool> update(const std::string& _link, const Filter<Classifier>& filter)
stringify(filter.handle().get().get()));
}
- Try<Netlink<struct rtnl_cls> > newCls = encodeFilter(link.get(), filter);
+ Try<Netlink<struct rtnl_cls>> newCls = encodeFilter(link.get(), filter);
if (newCls.isError()) {
return Error("Failed to encode the new filter: " + newCls.error());
}
@@ -719,17 +719,17 @@ Try<bool> update(const std::string& _link, const Filter<Classifier>& filter)
newCls.get().get(),
rtnl_cls_get_prio(oldCls.get().get()));
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
- int err = rtnl_cls_change(sock.get().get(), newCls.get().get(), 0);
- if (err != 0) {
- if (err == -NLE_OBJ_NOTFOUND) {
+ int error = rtnl_cls_change(socket.get().get(), newCls.get().get(), 0);
+ if (error != 0) {
+ if (error == -NLE_OBJ_NOTFOUND) {
return false;
} else {
- return Error(std::string(nl_geterror(err)));
+ return Error(std::string(nl_geterror(error)));
}
}
@@ -741,31 +741,31 @@ Try<bool> update(const std::string& _link, const Filter<Classifier>& filter)
// Returns None if the link or the parent is not found. We use
// template here so that it works for any type of classifier.
template <typename Classifier>
-Result<std::vector<Filter<Classifier> > > filters(
+Result<std::vector<Filter<Classifier>>> filters(
const std::string& _link,
const queueing::Handle& parent)
{
- Result<Netlink<struct rtnl_link> > link = link::internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
return None();
}
- Try<std::vector<Netlink<struct rtnl_cls> > > clses =
+ Try<std::vector<Netlink<struct rtnl_cls>>> clses =
getClses(link.get(), parent);
if (clses.isError()) {
return Error(clses.error());
}
- std::vector<Filter<Classifier> > results;
+ std::vector<Filter<Classifier>> results;
foreach (const Netlink<struct rtnl_cls>& cls, clses.get()) {
// The decode function will return None if 'cls' does not match
// the classifier type. In that case, we just move on to the next
// libnl filter.
- Result<Filter<Classifier> > filter = decodeFilter<Classifier>(cls);
+ Result<Filter<Classifier>> filter = decodeFilter<Classifier>(cls);
if (filter.isError()) {
return Error(filter.error());
} else if (filter.isSome()) {
@@ -781,11 +781,11 @@ Result<std::vector<Filter<Classifier> > > filters(
// link. Returns None if the link or the parent is not found. We use
// template here so that it works for any type of classifier.
template <typename Classifier>
-Result<std::vector<Classifier> > classifiers(
+Result<std::vector<Classifier>> classifiers(
const std::string& link,
const queueing::Handle& parent)
{
- Result<std::vector<Filter<Classifier> > > _filters =
+ Result<std::vector<Filter<Classifier>>> _filters =
filters<Classifier>(link, parent);
if (_filters.isError()) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/e864025b/src/linux/routing/filter/ip.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/filter/ip.cpp b/src/linux/routing/filter/ip.cpp
index 74525a9..922a732 100644
--- a/src/linux/routing/filter/ip.cpp
+++ b/src/linux/routing/filter/ip.cpp
@@ -63,11 +63,11 @@ Try<Nothing> encode<ip::Classifier>(
{
rtnl_cls_set_protocol(cls.get(), ETH_P_IP);
- int err = rtnl_tc_set_kind(TC_CAST(cls.get()), "u32");
- if (err != 0) {
+ int error = rtnl_tc_set_kind(TC_CAST(cls.get()), "u32");
+ if (error != 0) {
return Error(
"Failed to set the kind of the classifier: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
// TODO(jieyu): Do we need to check the protocol (e.g., TCP/UDP)?
@@ -82,17 +82,17 @@ Try<Nothing> encode<ip::Classifier>(
// | IHL | X | X | X |
// +--------+--------+--------+--------+
// Offset: 0 1 2 3
- err = rtnl_u32_add_key(
+ error = rtnl_u32_add_key(
cls.get(),
htonl(0x05000000),
htonl(0x0f000000),
0, // Offset from which to start matching.
0);
- if (err != 0) {
+ if (error != 0) {
return Error(
"Failed to add selector for IP header length: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
if (classifier.destinationMAC().isSome()) {
@@ -127,47 +127,47 @@ Try<Nothing> encode<ip::Classifier>(
((uint32_t) mac[5]);
// To match the first two bytes of the MAC address.
- err = rtnl_u32_add_key(
+ error = rtnl_u32_add_key(
cls.get(),
htonl(value[0]),
htonl(0x0000ffff), // Ignore offset -16 and -15.
-16, // Offset from which to start matching.
0);
- if (err != 0) {
+ if (error != 0) {
return Error(
"Failed to add selector for destination MAC address: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
// To match the last four bytes of the MAC address.
- err = rtnl_u32_add_key(
+ error = rtnl_u32_add_key(
cls.get(),
htonl(value[1]),
htonl(0xffffffff),
-12, // Offset from which to start matching.
0);
- if (err != 0) {
+ if (error != 0) {
return Error(
"Failed to add selector for destination MAC address: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
}
if (classifier.destinationIP().isSome()) {
// To match those IP packets that have the given destination IP.
- err = rtnl_u32_add_key(
+ error = rtnl_u32_add_key(
cls.get(),
htonl(classifier.destinationIP().get().address()),
htonl(0xffffffff),
16,
0);
- if (err != 0) {
+ if (error != 0) {
return Error(
"Failed to add selector for destination IP address: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
}
@@ -186,17 +186,17 @@ Try<Nothing> encode<ip::Classifier>(
uint32_t mask = ((uint32_t) classifier.sourcePorts().get().mask()) << 16;
// To match IP packets that have the given source ports.
- err = rtnl_u32_add_key(
+ error = rtnl_u32_add_key(
cls.get(),
htonl(value),
htonl(mask),
20, // Offset to which to start matching.
0);
- if (err != 0) {
+ if (error != 0) {
return Error(
"Failed to add selector for source ports: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
}
@@ -210,17 +210,17 @@ Try<Nothing> encode<ip::Classifier>(
uint32_t mask = (uint32_t) classifier.destinationPorts().get().mask();
// To match IP packets that have the given destination ports.
- err = rtnl_u32_add_key(
+ error = rtnl_u32_add_key(
cls.get(),
htonl(value),
htonl(mask),
20,
0);
- if (err != 0) {
+ if (error != 0) {
return Error(
"Failed to add selector for destination ports: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
}
@@ -258,7 +258,7 @@ Result<ip::Classifier> decode<ip::Classifier>(
int offset;
int offsetmask;
- int err = rtnl_u32_get_key(
+ int error = rtnl_u32_get_key(
cls.get(),
i,
&value,
@@ -266,17 +266,17 @@ Result<ip::Classifier> decode<ip::Classifier>(
&offset,
&offsetmask);
- if (err != 0) {
- if (err == -NLE_INVAL) {
+ if (error != 0) {
+ if (error == -NLE_INVAL) {
// This is the case where cls does not have a u32 selector. In
// that case, we just return none.
return None();
- } else if (err == -NLE_RANGE) {
+ } else if (error == -NLE_RANGE) {
break;
} else {
return Error(
"Failed to decode a u32 classifier: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/e864025b/src/linux/routing/internal.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/internal.hpp b/src/linux/routing/internal.hpp
index 87a539b..aa60796 100644
--- a/src/linux/routing/internal.hpp
+++ b/src/linux/routing/internal.hpp
@@ -88,7 +88,7 @@ private:
// of the netlink socket is NETLINK_ROUTE, but you can optionally
// provide a different one.
// TODO(chzhcn): Consider renaming 'routing' to 'netlink'.
-inline Try<Netlink<struct nl_sock> > socket(int protocol = NETLINK_ROUTE)
+inline Try<Netlink<struct nl_sock>> socket(int protocol = NETLINK_ROUTE)
{
Try<Nothing> checking = check();
if (checking.isError()) {
@@ -102,11 +102,11 @@ inline Try<Netlink<struct nl_sock> > socket(int protocol = NETLINK_ROUTE)
Netlink<struct nl_sock> sock(s);
- int err = nl_connect(sock.get(), protocol);
- if (err != 0) {
+ int error = nl_connect(sock.get(), protocol);
+ if (error != 0) {
return Error(
"Failed to connect to netlink protocol: " +
- std::string(nl_geterror(err)));
+ std::string(nl_geterror(error)));
}
return sock;
http://git-wip-us.apache.org/repos/asf/mesos/blob/e864025b/src/linux/routing/link/internal.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/link/internal.hpp b/src/linux/routing/link/internal.hpp
index 0d46e9a..015c0ef 100644
--- a/src/linux/routing/link/internal.hpp
+++ b/src/linux/routing/link/internal.hpp
@@ -49,19 +49,19 @@ namespace internal {
// Returns the netlink link object associated with a given link by its
// name. Returns None if the link is not found.
-inline Result<Netlink<struct rtnl_link> > get(const std::string& link)
+inline Result<Netlink<struct rtnl_link>> get(const std::string& link)
{
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
// Dump all the netlink link objects from kernel. Note that the flag
// AF_UNSPEC means all available families.
struct nl_cache* c = NULL;
- int err = rtnl_link_alloc_cache(sock.get().get(), AF_UNSPEC, &c);
- if (err != 0) {
- return Error(nl_geterror(err));
+ int error = rtnl_link_alloc_cache(socket.get().get(), AF_UNSPEC, &c);
+ if (error != 0) {
+ return Error(nl_geterror(error));
}
Netlink<struct nl_cache> cache(c);
@@ -76,19 +76,19 @@ inline Result<Netlink<struct rtnl_link> > get(const std::string& link)
// Returns the netlink link object associated with a given link by its
// interface index. Returns None if the link is not found.
-inline Result<Netlink<struct rtnl_link> > get(int index)
+inline Result<Netlink<struct rtnl_link>> get(int index)
{
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
// Dump all the netlink link objects from kernel. Note that the flag
// AF_UNSPEC means all available families.
struct nl_cache* c = NULL;
- int err = rtnl_link_alloc_cache(sock.get().get(), AF_UNSPEC, &c);
- if (err != 0) {
- return Error(nl_geterror(err));
+ int error = rtnl_link_alloc_cache(socket.get().get(), AF_UNSPEC, &c);
+ if (error != 0) {
+ return Error(nl_geterror(error));
}
Netlink<struct nl_cache> cache(c);
@@ -105,7 +105,7 @@ inline Result<Netlink<struct rtnl_link> > get(int index)
// not found.
inline Result<bool> test(const std::string& _link, unsigned int flags)
{
- Result<Netlink<struct rtnl_link> > link = get(_link);
+ Result<Netlink<struct rtnl_link>> link = get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
@@ -119,7 +119,7 @@ inline Result<bool> test(const std::string& _link, unsigned int flags)
// Sets the flags on the link. Returns false if the link is not found.
inline Try<bool> set(const std::string& _link, unsigned int flags)
{
- Result<Netlink<struct rtnl_link> > link = get(_link);
+ Result<Netlink<struct rtnl_link>> link = get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/e864025b/src/linux/routing/link/link.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/link/link.cpp b/src/linux/routing/link/link.cpp
index a912122..eb3211a 100644
--- a/src/linux/routing/link/link.cpp
+++ b/src/linux/routing/link/link.cpp
@@ -63,7 +63,7 @@ namespace link {
Result<string> eth0()
{
- Try<vector<route::Rule> > mainRoutingTable = route::table();
+ Try<vector<route::Rule>> mainRoutingTable = route::table();
if (mainRoutingTable.isError()) {
return Error(
"Failed to retrieve the main routing table on the host: " +
@@ -92,7 +92,7 @@ Result<string> eth0()
Result<string> lo()
{
- Try<set<string> > links = net::links();
+ Try<set<string>> links = net::links();
if (links.isError()) {
return Error("Failed to get all the links: " + links.error());
}
@@ -112,7 +112,7 @@ Result<string> lo()
Try<bool> exists(const string& _link)
{
- Result<Netlink<struct rtnl_link> > link = internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = internal::get(_link);
if (link.isError()) {
return Error(link.error());
}
@@ -125,22 +125,22 @@ Try<bool> create(
const string& peer,
const Option<pid_t>& pid)
{
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
- int err = rtnl_link_veth_add(
+ int error = rtnl_link_veth_add(
sock.get().get(),
veth.c_str(),
peer.c_str(),
(pid.isNone() ? getpid() : pid.get()));
- if (err != 0) {
- if (err == -NLE_EXIST) {
+ if (error = 0) {
+ if (error = -NLE_EXIST) {
return false;
}
- return Error(nl_geterror(err));
+ return Error(nl_geterror(error));
}
return true;
@@ -149,24 +149,24 @@ Try<bool> create(
Try<bool> remove(const string& _link)
{
- Result<Netlink<struct rtnl_link> > link = internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
return false;
}
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
- int err = rtnl_link_delete(sock.get().get(), link.get().get());
- if (err != 0) {
- if (err == -NLE_OBJ_NOTFOUND || err == -NLE_NODEV) {
+ int error = rtnl_link_delete(socket.get().get(), link.get().get());
+ if (error != 0) {
+ if (error == -NLE_OBJ_NOTFOUND || error == -NLE_NODEV) {
return false;
}
- return Error(nl_geterror(err));
+ return Error(nl_geterror(error));
}
return true;
@@ -237,7 +237,7 @@ Future<Nothing> removed(const string& link)
Result<int> index(const string& _link)
{
- Result<Netlink<struct rtnl_link> > link = internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
@@ -250,7 +250,7 @@ Result<int> index(const string& _link)
Result<string> name(int index)
{
- Result<Netlink<struct rtnl_link> > link = internal::get(index);
+ Result<Netlink<struct rtnl_link>> link = internal::get(index);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
@@ -328,7 +328,7 @@ Try<bool> setMAC(const string& link, const net::MAC& mac)
Result<unsigned int> mtu(const string& _link)
{
- Result<Netlink<struct rtnl_link> > link = internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
@@ -341,7 +341,7 @@ Result<unsigned int> mtu(const string& _link)
Try<bool> setMTU(const string& _link, unsigned int mtu)
{
- Result<Netlink<struct rtnl_link> > link = internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
@@ -377,9 +377,9 @@ Try<bool> setMTU(const string& _link, unsigned int mtu)
}
-Result<hashmap<string, uint64_t> > statistics(const string& _link)
+Result<hashmap<string, uint64_t>> statistics(const string& _link)
{
- Result<Netlink<struct rtnl_link> > link = internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/e864025b/src/linux/routing/queueing/ingress.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/ingress.cpp b/src/linux/routing/queueing/ingress.cpp
index e696950..47c7337 100644
--- a/src/linux/routing/queueing/ingress.cpp
+++ b/src/linux/routing/queueing/ingress.cpp
@@ -62,11 +62,11 @@ Try<Nothing> encode<ingress::Discipline>(
const Netlink<struct rtnl_qdisc>& qdisc,
const ingress::Discipline& discipline)
{
- int err = rtnl_tc_set_kind(TC_CAST(qdisc.get()), "ingress");
- if (err != 0) {
+ int error = rtnl_tc_set_kind(TC_CAST(qdisc.get()), "ingress");
+ if (error != 0) {
return Error(
"Failed to set the kind of the queueing discipline: " +
- string(nl_geterror(err)));
+ string(nl_geterror(error)));
}
rtnl_tc_set_parent(TC_CAST(qdisc.get()), INGRESS_ROOT.get());
http://git-wip-us.apache.org/repos/asf/mesos/blob/e864025b/src/linux/routing/queueing/internal.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/queueing/internal.hpp b/src/linux/routing/queueing/internal.hpp
index 4d8bd55..7c6c4d3 100644
--- a/src/linux/routing/queueing/internal.hpp
+++ b/src/linux/routing/queueing/internal.hpp
@@ -73,7 +73,7 @@ Result<Discipline> decode(const Netlink<struct rtnl_qdisc>& qdisc);
// queueing discipline (rtnl_qdisc). We use template here so that it
// works for any type of queueing discipline.
template <typename Discipline>
-Try<Netlink<struct rtnl_qdisc> > encode(
+Try<Netlink<struct rtnl_qdisc>> encode(
const Netlink<struct rtnl_link>& link,
const Discipline& discipline)
{
@@ -102,26 +102,26 @@ Try<Netlink<struct rtnl_qdisc> > encode(
/////////////////////////////////////////////////
// Returns all the libnl queue discipline (rtnl_qdisc) on the link.
-inline Try<std::vector<Netlink<struct rtnl_qdisc> > > getQdiscs(
+inline Try<std::vector<Netlink<struct rtnl_qdisc>>> getQdiscs(
const Netlink<struct rtnl_link>& link)
{
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
// Dump all the queueing discipline from kernel.
struct nl_cache* c = NULL;
- int err = rtnl_qdisc_alloc_cache(sock.get().get(), &c);
- if (err != 0) {
+ int error = rtnl_qdisc_alloc_cache(socket.get().get(), &c);
+ if (error != 0) {
return Error(
"Failed to get queueing discipline info from kernel: " +
- std::string(nl_geterror(err)));
+ std::string(nl_geterror(error)));
}
Netlink<struct nl_cache> cache(c);
- std::vector<Netlink<struct rtnl_qdisc> > results;
+ std::vector<Netlink<struct rtnl_qdisc>> results;
for (struct nl_object* o = nl_cache_get_first(cache.get());
o != NULL; o = nl_cache_get_next(o)) {
@@ -138,11 +138,11 @@ inline Try<std::vector<Netlink<struct rtnl_qdisc> > > getQdiscs(
// has been found. We use template here so that it works for any type
// of queueing discipline.
template <typename Discipline>
-Result<Netlink<struct rtnl_qdisc> > getQdisc(
+Result<Netlink<struct rtnl_qdisc>> getQdisc(
const Netlink<struct rtnl_link>& link,
const Discipline& discipline)
{
- Try<std::vector<Netlink<struct rtnl_qdisc> > > qdiscs = getQdiscs(link);
+ Try<std::vector<Netlink<struct rtnl_qdisc>>> qdiscs = getQdiscs(link);
if (qdiscs.isError()) {
return Error(qdiscs.error());
}
@@ -172,14 +172,14 @@ Result<Netlink<struct rtnl_qdisc> > getQdisc(
template <typename Discipline>
Try<bool> exists(const std::string& _link, const Discipline& discipline)
{
- Result<Netlink<struct rtnl_link> > link = link::internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
return false;
}
- Result<Netlink<struct rtnl_qdisc> > qdisc = getQdisc(link.get(), discipline);
+ Result<Netlink<struct rtnl_qdisc>> qdisc = getQdisc(link.get(), discipline);
if (qdisc.isError()) {
return Error(qdisc.error());
}
@@ -193,37 +193,37 @@ Try<bool> exists(const std::string& _link, const Discipline& discipline)
template <typename Discipline>
Try<bool> create(const std::string& _link, const Discipline& discipline)
{
- Result<Netlink<struct rtnl_link> > link = link::internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
return Error("Link '" + _link + "' is not found");
}
- Try<Netlink<struct rtnl_qdisc> > qdisc = encode(link.get(), discipline);
+ Try<Netlink<struct rtnl_qdisc>> qdisc = encode(link.get(), discipline);
if (qdisc.isError()) {
return Error("Failed to encode the queueing discipline: " + qdisc.error());
}
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
// The flag NLM_F_EXCL tells libnl that if the qdisc already exists,
// this function should return error.
- int err = rtnl_qdisc_add(
- sock.get().get(),
+ int error = rtnl_qdisc_add(
+ socket.get().get(),
qdisc.get().get(),
NLM_F_CREATE | NLM_F_EXCL);
- if (err != 0) {
- if (err == -NLE_EXIST) {
+ if (error != 0) {
+ if (error == -NLE_EXIST) {
return false;
}
return Error(
"Failed to add a queueing discipline to the link: " +
- std::string(nl_geterror(err)));
+ std::string(nl_geterror(error)));
}
return true;
@@ -236,30 +236,30 @@ Try<bool> create(const std::string& _link, const Discipline& discipline)
template <typename Discipline>
Try<bool> remove(const std::string& _link, const Discipline& discipline)
{
- Result<Netlink<struct rtnl_link> > link = link::internal::get(_link);
+ Result<Netlink<struct rtnl_link>> link = link::internal::get(_link);
if (link.isError()) {
return Error(link.error());
} else if (link.isNone()) {
return false;
}
- Result<Netlink<struct rtnl_qdisc> > qdisc = getQdisc(link.get(), discipline);
+ Result<Netlink<struct rtnl_qdisc>> qdisc = getQdisc(link.get(), discipline);
if (qdisc.isError()) {
return Error(qdisc.error());
} else if (qdisc.isNone()) {
return false;
}
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
- int err = rtnl_qdisc_delete(sock.get().get(), qdisc.get().get());
- if (err != 0) {
+ int error = rtnl_qdisc_delete(socket.get().get(), qdisc.get().get());
+ if (error != 0) {
// TODO(jieyu): Interpret the error code and return false if it
// indicates that the queueing discipline is not found.
- return Error(std::string(nl_geterror(err)));
+ return Error(std::string(nl_geterror(error)));
}
return true;
http://git-wip-us.apache.org/repos/asf/mesos/blob/e864025b/src/linux/routing/route.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/route.cpp b/src/linux/routing/route.cpp
index 8086034..b0eda7b 100644
--- a/src/linux/routing/route.cpp
+++ b/src/linux/routing/route.cpp
@@ -47,18 +47,18 @@ using std::vector;
namespace routing {
namespace route {
-Try<vector<Rule> > table()
+Try<vector<Rule>> table()
{
- Try<Netlink<struct nl_sock> > sock = routing::socket();
- if (sock.isError()) {
- return Error(sock.error());
+ Try<Netlink<struct nl_sock>> socket = routing::socket();
+ if (socket.isError()) {
+ return Error(socket.error());
}
// Dump all the routes (for IPv4) from kernel.
struct nl_cache* c = NULL;
- int err = rtnl_route_alloc_cache(sock.get().get(), AF_INET, 0, &c);
- if (err != 0) {
- return Error(nl_geterror(err));
+ int error = rtnl_route_alloc_cache(socket.get().get(), AF_INET, 0, &c);
+ if (error != 0) {
+ return Error(nl_geterror(error));
}
Netlink<struct nl_cache> cache(c);
@@ -122,7 +122,7 @@ Try<vector<Rule> > table()
Result<net::IP> defaultGateway()
{
- Try<vector<Rule> > rules = table();
+ Try<vector<Rule>> rules = table();
if (rules.isError()) {
return Error("Failed to get the routing table: " + rules.error());
}