You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by me...@apache.org on 2014/10/14 10:21:43 UTC
[2/2] git commit: libprocess: Always use stout ABORT() rather than
system abort()
libprocess: Always use stout ABORT() rather than system abort()
This makes it so any time there is an abort, we get a line number and at least
a basic message as to why there was an abort. If you want a clean(er) exit,
use <stout/exit>.
Review: https://reviews.apache.org/r/26473
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3eb58598
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3eb58598
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3eb58598
Branch: refs/heads/master
Commit: 3eb585981b95801eae174a8ff52d581f20b09247
Parents: c713c5d
Author: Cody Maloney <co...@mesosphere.io>
Authored: Tue Oct 14 00:24:26 2014 -0700
Committer: Adam B <ad...@mesosphere.io>
Committed: Tue Oct 14 00:24:52 2014 -0700
----------------------------------------------------------------------
3rdparty/libprocess/include/process/event.hpp | 4 ++--
3rdparty/libprocess/include/process/http.hpp | 6 ++----
3rdparty/libprocess/include/process/socket.hpp | 7 ++-----
3rdparty/libprocess/src/httpd.cpp | 9 +--------
3rdparty/libprocess/src/synchronized.hpp | 9 +++------
5 files changed, 10 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/3eb58598/3rdparty/libprocess/include/process/event.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/event.hpp b/3rdparty/libprocess/include/process/event.hpp
index bf689d7..294e215 100644
--- a/3rdparty/libprocess/include/process/event.hpp
+++ b/3rdparty/libprocess/include/process/event.hpp
@@ -6,6 +6,7 @@
#include <process/message.hpp>
#include <process/socket.hpp>
+#include <stout/abort.hpp>
#include <stout/lambda.hpp>
#include <stout/memory.hpp> // TODO(benh): Replace shared_ptr with unique_ptr.
@@ -63,8 +64,7 @@ struct Event
} visitor(&result);
visit(&visitor);
if (result == NULL) {
- std::cerr << "Attempting to \"cast\" event incorrectly!" << std::endl;
- abort();
+ ABORT("Attempting to \"cast\" event incorrectly!");
}
return *result;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/3eb58598/3rdparty/libprocess/include/process/http.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp
index d540775..9cf05ac 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -494,10 +494,8 @@ inline Try<std::string> decode(const std::string& s)
unsigned long l;
in >> std::hex >> l;
if (l > UCHAR_MAX) {
- std::cerr << "Unexpected conversion from hex string: "
- << s.substr(i + 1, 2) << " to unsigned long: "
- << l << std::endl;
- abort();
+ ABORT("Unexpected conversion from hex string: " + s.substr(i + 1, 2) +
+ " to unsigned long: " + stringify(l));
}
out << static_cast<unsigned char>(l);
http://git-wip-us.apache.org/repos/asf/mesos/blob/3eb58598/3rdparty/libprocess/include/process/socket.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/socket.hpp b/3rdparty/libprocess/include/process/socket.hpp
index dbcb4f4..6683881 100644
--- a/3rdparty/libprocess/include/process/socket.hpp
+++ b/3rdparty/libprocess/include/process/socket.hpp
@@ -2,10 +2,8 @@
#define __PROCESS_SOCKET_HPP__
#include <assert.h>
-#include <unistd.h> // For close.
-
-#include <iostream>
+#include <stout/abort.hpp>
#include <stout/nothing.hpp>
#include <stout/os.hpp>
#include <stout/try.hpp>
@@ -94,8 +92,7 @@ private:
if (s >= 0) {
Try<Nothing> close = os::close(s);
if (close.isError()) {
- std::cerr << "Failed to close socket: " << close.error() << std::endl;
- abort();
+ ABORT("Failed to close socket: " + close.error());
}
}
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/3eb58598/3rdparty/libprocess/src/httpd.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/httpd.cpp b/3rdparty/libprocess/src/httpd.cpp
index eab3aa5..902ba89 100644
--- a/3rdparty/libprocess/src/httpd.cpp
+++ b/3rdparty/libprocess/src/httpd.cpp
@@ -29,12 +29,6 @@ using std::map;
using process::tuple::Tuple;
-#define malloc(bytes) \
- ({ void *tmp; if ((tmp = malloc(bytes)) == NULL) abort(); tmp; })
-
-#define realloc(address, bytes) \
- ({ void *tmp; if ((tmp = realloc(address, bytes)) == NULL) abort(); tmp; })
-
#define HTTP_500 \
"HTTP/1.1 500 Internal Server Error\r\n\r\n"
@@ -94,8 +88,7 @@ public:
http_parser_execute(&parser, raw.c_str(), raw.length());
if (http_parser_has_error(&parser)) {
- //cerr << "parser error" << endl;
- abort();
+ ABORT("parser error");
}
return message;
http://git-wip-us.apache.org/repos/asf/mesos/blob/3eb58598/3rdparty/libprocess/src/synchronized.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/synchronized.hpp b/3rdparty/libprocess/src/synchronized.hpp
index 70f6cd0..6a341b8 100644
--- a/3rdparty/libprocess/src/synchronized.hpp
+++ b/3rdparty/libprocess/src/synchronized.hpp
@@ -34,8 +34,7 @@ public:
void acquire()
{
if (!initialized) {
- std::cerr << "synchronizable not initialized" << std::endl;
- abort();
+ ABORT("synchronizable not initialized");
}
pthread_mutex_lock(&mutex);
}
@@ -43,8 +42,7 @@ public:
void release()
{
if (!initialized) {
- std::cerr << "synchronizable not initialized" << std::endl;
- abort();
+ ABORT("synchronizable not initialized");
}
pthread_mutex_unlock(&mutex);
}
@@ -60,8 +58,7 @@ private:
pthread_mutexattr_destroy(&attr);
initialized = true;
} else {
- std::cerr << "synchronizable already initialized" << std::endl;
- abort();
+ ABORT("synchronizable already initialized");
}
}