You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/03/20 22:19:50 UTC
svn commit: r1303158 - in /incubator/mesos/trunk: configure.ac
src/Makefile.am src/common/utils.hpp src/launcher/launcher.cpp
Author: benh
Date: Tue Mar 20 21:19:49 2012
New Revision: 1303158
URL: http://svn.apache.org/viewvc?rev=1303158&view=rev
Log:
Added an autoconf option to conditionally use libcurl (disabled by default) and made a few semantics changes to 'download' (contributed by Florian Leibert).
Modified:
incubator/mesos/trunk/configure.ac
incubator/mesos/trunk/src/Makefile.am
incubator/mesos/trunk/src/common/utils.hpp
incubator/mesos/trunk/src/launcher/launcher.cpp
Modified: incubator/mesos/trunk/configure.ac
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/configure.ac?rev=1303158&r1=1303157&r2=1303158&view=diff
==============================================================================
--- incubator/mesos/trunk/configure.ac (original)
+++ incubator/mesos/trunk/configure.ac Tue Mar 20 21:19:49 2012
@@ -109,6 +109,12 @@ AC_ARG_ENABLE([optimize],
[don't try to compile with optimizations]),
[], [enable_optimize=yes])
+AC_ARG_WITH([curl],
+ AS_HELP_STRING([--with-curl],
+ [builds Mesos assuming libcurl
+ (and its dependencies) are available]),
+ [], [with_curl=no])
+
AC_ARG_WITH([included-zookeeper],
AS_HELP_STRING([--without-included-zookeeper],
[excludes building and using the included ZooKeeper
@@ -379,7 +385,21 @@ if test "x$enable_optimize" = "xyes"; th
fi
+# Check if we should/can build with libcurl.
+if test "x$with_curl" = "xyes"; then
+ AC_CHECK_LIB([z], [gzread], [],
+ [AC_MSG_ERROR([can't find libz])])
+ AC_CHECK_LIB([crypto], [BN_init], [],
+ [AC_MSG_ERROR([can't find libcrypto])])
+ AC_CHECK_LIB([ssl], [SSL_accept], [],
+ [AC_MSG_ERROR([can't find libssl])])
+ AC_CHECK_LIB([curl], [curl_global_init], [],
+ [AC_MSG_ERROR([can't find libcurl])])
+fi
+
+
AM_CONDITIONAL([WITH_INCLUDED_ZOOKEEPER],
[test "x$with_included_zookeeper" = "xyes"])
+
AC_OUTPUT
Modified: incubator/mesos/trunk/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/Makefile.am?rev=1303158&r1=1303157&r2=1303158&view=diff
==============================================================================
--- incubator/mesos/trunk/src/Makefile.am (original)
+++ incubator/mesos/trunk/src/Makefile.am Tue Mar 20 21:19:49 2012
@@ -236,10 +236,6 @@ liblog_la_CPPFLAGS = -I../$(LEVELDB)/inc
libmesos_no_third_party_la_LIBADD += liblog.la
-# Libraries for performing HTTP requests.
-libmesos_no_third_party_la_LIBADD += -lcurl -lssl -lcrypto -lz
-
-
# Convenience library for the webui to include Python specific flags.
if WEBUI
noinst_LTLIBRARIES += libwebui.la
Modified: incubator/mesos/trunk/src/common/utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/common/utils.hpp?rev=1303158&r1=1303157&r2=1303158&view=diff
==============================================================================
--- incubator/mesos/trunk/src/common/utils.hpp (original)
+++ incubator/mesos/trunk/src/common/utils.hpp Tue Mar 20 21:19:49 2012
@@ -33,7 +33,9 @@
#include <stdlib.h>
#include <unistd.h>
+#ifdef HAVE_LIBCURL
#include <curl/curl.h>
+#endif
#include <google/protobuf/message.h>
@@ -647,12 +649,15 @@ inline Result<bool> read(const std::stri
} // namespace protobuf {
// Handles http requests.
-namespace http {
+namespace net {
-// Returns the HTTP code resulting from attempting to download the
-// specified url into a file at the specified path.
+// Returns the return code resulting from attempting to download the
+// specified HTTP or FTP URL into a file at the specified path.
inline Try<int> download(const std::string& url, const std::string& path)
{
+#ifndef HAVE_LIBCURL
+ return Try<int>::error("Downloading via HTTP/FTP is not supported");
+#else
Result<int> fd = utils::os::open(path, O_CREAT | O_WRONLY,
S_IRUSR | S_IWUSR | S_IRGRP | S_IRWXO);
@@ -668,7 +673,7 @@ inline Try<int> download(const std::stri
if (curl == NULL) {
curl_easy_cleanup(curl);
utils::os::close(fd.get());
- return Try<int>::error("Failed to initialize cURL");
+ return Try<int>::error("Failed to initialize libcurl");
}
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
@@ -684,18 +689,19 @@ inline Try<int> download(const std::stri
return Try<int>::error(curl_easy_strerror(curlErrorCode));
}
- long httpCode;
- curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
+ long code;
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
curl_easy_cleanup(curl);
if (!fclose(file)) {
- return Try<int>::error("Unable to close file handle!");
+ return Try<int>::error("Failed to close file handle");
}
- return Try<int>::some(httpCode);
+ return Try<int>::some(code);
+#endif // HAVE_LIBCURL
}
-} // namespace http {
+} // namespace net {
} // namespace utils {
} // namespace internal {
Modified: incubator/mesos/trunk/src/launcher/launcher.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/launcher/launcher.cpp?rev=1303158&r1=1303157&r2=1303158&view=diff
==============================================================================
--- incubator/mesos/trunk/src/launcher/launcher.cpp (original)
+++ incubator/mesos/trunk/src/launcher/launcher.cpp Tue Mar 20 21:19:49 2012
@@ -196,11 +196,11 @@ void ExecutorLauncher::fetchExecutor()
CHECK(path.size() > path.find("/") + 1) << "Malformed URL (missing path)";
path = "./" + path.substr(path.find_last_of("/") + 1);
cout << "Downloading " << executor << " to " << path << endl;
- Try<int> code = utils::http::download(executor, path);
+ Try<int> code = utils::net::download(executor, path);
if (code.isError()) {
fatal("Error downloading executor: %s", code.error().c_str());
} else if (code.get() != 200) {
- fatal("Error downloading executor, received http status: %d",
+ fatal("Error downloading executor, received HTTP/FTP return code: %d",
code.get());
}
executor = path;