*/
#include <config.h>
+
#include <libtest/common.h>
#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
class CURL;
#endif
+
+static void cleanup_curl(void)
+{
+#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
+ curl_global_cleanup();
+#endif
+}
+
+static void initialize_curl_startup()
+{
+#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
+ if (curl_global_init(CURL_GLOBAL_ALL))
+ {
+ fatal_message("curl_global_init(CURL_GLOBAL_ALL) failed");
+ }
+#endif
+
+ if (atexit(cleanup_curl))
+ {
+ fatal_message("atexit() failed");
+ }
+}
+
+static pthread_once_t start_key_once= PTHREAD_ONCE_INIT;
+void initialize_curl(void)
+{
+ int ret;
+ if (pthread_once(&start_key_once, initialize_curl_startup) != 0)
+ {
+ fatal_message(strerror(ret));
+ }
+}
+
namespace libtest {
namespace http {
}
}
+HTTP::HTTP(const std::string& url_arg) :
+ _url(url_arg),
+ _response(0)
+{
+ initialize_curl();
+}
+
bool GET::execute()
{
if (HAVE_LIBCURL)
class HTTP {
public:
- HTTP(const std::string& url_arg) :
- _url(url_arg),
- _response(0)
- { }
+ HTTP(const std::string& url_arg);
virtual bool execute()= 0;
bool ping()
{
// Memcached is slow to start, so we need to do this
- if (not pid_file().empty())
+ if (pid_file().empty() == false)
{
if (wait_for_pidfile() == false)
{
if (has_socket())
{
- ret= libmemcached_util_ping(socket().c_str(), 0, &rc);
+ ret= libmemcached_util_ping(socket().c_str(), 0, &rc);
}
else
{
class MemcachedSaSL : public Memcached
{
public:
- MemcachedSaSL(const std::string& host_arg, const in_port_t port_arg, const bool is_socket_arg, const std::string& username_arg, const std::string &password_arg) :
+ MemcachedSaSL(const std::string& host_arg,
+ const in_port_t port_arg,
+ const bool is_socket_arg,
+ const std::string& username_arg,
+ const std::string &password_arg) :
Memcached(host_arg, port_arg, is_socket_arg, username_arg, password_arg)
{ }
bool MemcachedLight::build(size_t argc, const char *argv[])
{
- for (int x= 0 ; x < argc ; x++)
+ for (size_t x= 0 ; x < argc ; x++)
{
add_option(argv[x]);
}
/*
We will now cycle the server we have created.
*/
- if (not server->cycle())
+ if (server->cycle() == false)
{
Error << "Could not start up server " << *server;
delete server;
#include <signal.h>
-#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
-#include <curl/curl.h>
-#endif
-
#ifndef __INTEL_COMPILER
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
return s + us;
}
-static void cleanup_curl(void)
-{
-#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
- curl_global_cleanup();
-#endif
-}
-
#include <getopt.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
-#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
- if (curl_global_init(CURL_GLOBAL_ALL))
- {
- Error << "curl_global_init(CURL_GLOBAL_ALL) failed";
- return EXIT_FAILURE;
- }
-#endif
-
- if (atexit(cleanup_curl))
- {
- Error << "atexit() failed";
- return EXIT_FAILURE;
- }
-
bool opt_repeat= false;
std::string collection_to_run;
{
std::cerr << e.what() << std::endl;
}
- catch (std::bad_alloc& e)
+ catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
}
catch (...)
{
- std::cerr << "Unknown exception halted execution" << std::endl;
+ std::cerr << "Unknown exception halted execution." << std::endl;
}
return exit_code;