Browse Source

Framework update (mostly fix effective c++ warnings).

Brian Aker 12 years ago
parent
commit
21e9d19d62

+ 5 - 5
libgearman-1.0/connection.h

@@ -2,7 +2,7 @@
  * 
  *  Gearmand client and server library.
  *
- *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
  *  Copyright (C) 2008 Brian Aker, Eric Day
  *  All rights reserved.
  *
@@ -44,15 +44,15 @@
 #include <netdb.h>
 
 #ifdef NI_MAXHOST
-#define GEARMAN_NI_MAXHOST NI_MAXHOST
+# define GEARMAN_NI_MAXHOST NI_MAXHOST
 #else
-#define GEARMAN_NI_MAXHOST 1025
+# define GEARMAN_NI_MAXHOST 1025
 #endif
 
 #ifdef NI_MAXSERV
-#define GEARMAN_NI_MAXSERV NI_MAXSERV
+# define GEARMAN_NI_MAXSERV NI_MAXSERV
 #else
-#define GEARMAN_NI_MAXSERV 32
+# define GEARMAN_NI_MAXSERV 32
 #endif
 
 /*

+ 1 - 1
libgearman/common.h

@@ -2,7 +2,7 @@
  * 
  *  Gearmand client and server library.
  *
- *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
  *  Copyright (C) 2008 Brian Aker, Eric Day
  *  All rights reserved.
  *

+ 4 - 0
libgearman/result.hpp

@@ -105,4 +105,8 @@ struct gearman_result_st
       gearman_string_free(&value.string);
     }
   }
+
+private:
+  gearman_result_st( const gearman_result_st& );
+  const gearman_result_st& operator=( const gearman_result_st& );
 };

+ 1 - 1
libgearman/task.cc

@@ -2,7 +2,7 @@
  * 
  *  Gearmand client and server library.
  *
- *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
  *  Copyright (C) 2008 Brian Aker, Eric Day
  *  All rights reserved.
  *

+ 7 - 0
libhostile/dummy.c

@@ -85,3 +85,10 @@ void set_send_close(bool arg, int frequency, int not_until_arg)
   (void)frequency;
   (void)not_until_arg;
 }
+
+void set_getaddrinfo_error(bool arg, int frequency, int not_until_arg)
+{
+  (void)arg;
+  (void)frequency;
+  (void)not_until_arg;
+}

+ 24 - 5
libhostile/getaddrinfo.c

@@ -53,12 +53,26 @@
 
 static int not_until= 500;
 
-static struct function_st __function;
+static struct function_st __function_getaddrinfo;
 
 static pthread_once_t function_lookup_once= PTHREAD_ONCE_INIT;
 static void set_local(void)
 {
-  __function= set_function("getaddrinfo", "HOSTILE_GETADDRINFO");
+  __function_getaddrinfo= set_function("getaddrinfo", "HOSTILE_GETADDRINFO");
+}
+
+void set_getaddrinfo_error(bool arg, int frequency, int not_until_arg)
+{
+  if (arg)
+  {
+    __function_getaddrinfo.frequency= frequency;
+    not_until= not_until_arg;
+  }
+  else
+  {
+    __function_getaddrinfo.frequency= 0;
+    not_until= 0;
+  }
 }
 
 int getaddrinfo(const char *node, const char *service,
@@ -71,20 +85,25 @@ int getaddrinfo(const char *node, const char *service,
 
   if (is_called() == false)
   {
-    if (__function.frequency)
+    if (__function_getaddrinfo.frequency)
     {
-      if (--not_until < 0 && random() % __function.frequency)
+      if (--not_until < 0 && random() % __function_getaddrinfo.frequency)
       {
 #if 0
         perror("HOSTILE CLOSE() of socket during getaddrinfo()");
 #endif
+        if (random() % 2)
+        {
+          return EAI_AGAIN;
+        }
+
         return EAI_FAIL;
       }
     }
   }
 
   set_called();
-  int ret= __function.function.getaddrinfo(node, service, hints, res);
+  int ret= __function_getaddrinfo.function.getaddrinfo(node, service, hints, res);
   reset_called();
 
   return ret;

+ 3 - 0
libhostile/hostile.h

@@ -82,6 +82,9 @@ LIBHOSTILE_API
 LIBHOSTILE_API
   void hostile_dump(void);
 
+LIBHOSTILE_API
+  void set_getaddrinfo_error(bool arg, int frequency, int not_until_arg);
+
 #ifdef __cplusplus
 }
 #endif

+ 2 - 2
libtest/collection.cc

@@ -55,7 +55,7 @@ static test_return_t runner_code(libtest::Framework* frame,
   }
   // Special case where check for the testing of the exception
   // system.
-  catch (libtest::fatal &e)
+  catch (const libtest::fatal& e)
   {
     if (libtest::fatal::is_disabled())
     {
@@ -133,7 +133,7 @@ test_return_t Collection::exec()
         }
         libtest::cancel_alarm();
       }
-      catch (libtest::fatal &e)
+      catch (const libtest::fatal& e)
       {
         stream::cerr(e.file(), e.line(), e.func()) << e.what();
         _failed++;

+ 4 - 0
libtest/collection.h

@@ -103,6 +103,10 @@ private:
   uint32_t _total;
   libtest::Timer _timer;
   libtest::Formatter _formatter;
+
+private:
+  Collection( const Collection& );
+  const Collection& operator=( const Collection& );
 };
 
 } // namespace libtest

+ 19 - 35
libtest/fatal.cc

@@ -43,72 +43,45 @@ namespace libtest {
 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
 
 fatal::fatal(const char *file_arg, int line_arg, const char *func_arg, ...) :
-  __test_result(file_arg, line_arg, func_arg),
-  _error_message(NULL),
-  _error_message_size(0)
+  __test_result(file_arg, line_arg, func_arg)
 {
   va_list args;
   va_start(args, func_arg);
-  const char *format= va_arg(args, const char *);
-  _error_message_size= vasprintf(&_error_message, format, args);
-  assert(_error_message_size != -1);
-  if (_error_message_size > 0)
-  {
-    _error_message_size++;
-  }
+  init(args);
   va_end(args);
 }
 
 fatal::fatal( const fatal& other ) :
-  __test_result(other),
-  _error_message_size(other._error_message_size)
-{
-  _error_message= (char*) malloc(_error_message_size);
-  if (_error_message)
-  {
-    memcpy(_error_message, other._error_message, _error_message_size);
-  }
-  else
-  {
-    _error_message_size= -1;
-  }
-}
-
-fatal::~fatal() throw()
+  __test_result(other)
 {
-  if ((_error_message_size > 0) and _error_message)
-  {
-    free(_error_message);
-    _error_message= NULL;
-  }
 }
 
 static bool _disabled= false;
 static uint32_t _counter= 0;
 
-bool fatal::is_disabled()
+bool fatal::is_disabled() throw()
 {
   return _disabled;
 }
 
-void fatal::disable()
+void fatal::disable() throw()
 {
   _counter= 0;
   _disabled= true;
 }
 
-void fatal::enable()
+void fatal::enable() throw()
 {
   _counter= 0;
   _disabled= false;
 }
 
-uint32_t fatal::disabled_counter()
+uint32_t fatal::disabled_counter() throw()
 {
   return _counter;
 }
 
-void fatal::increment_disabled_counter()
+void fatal::increment_disabled_counter() throw()
 {
   _counter++;
 }
@@ -132,4 +105,15 @@ disconnected::disconnected(const char *file_arg, int line_arg, const char *func_
   snprintf(_error_message, sizeof(_error_message), "%s:%u %s", instance.c_str(), uint32_t(port), last_error);
 }
 
+disconnected::disconnected(const disconnected& other):
+  std::runtime_error(other._func),
+  _port(other._port),
+  _line(other._line),
+  _file(other._file),
+  _func(other._func)
+{
+  strncpy(_error_message, other._error_message, BUFSIZ);
+  strncpy(_instance, other._instance, BUFSIZ);
+}
+
 } // namespace libtest

Some files were not shown because too many files changed in this diff