Browse Source

Merge lp:~tangent-org/gearmand/1.0-build/ Build: jenkins-Gearmand-393

Continuous Integration 12 years ago
parent
commit
09704f9a9b
3 changed files with 26 additions and 11 deletions
  1. 11 7
      gearmand/gearmand.cc
  2. 6 4
      libhashkit/md5.cc
  3. 9 0
      tests/gearmand.cc

+ 11 - 7
gearmand/gearmand.cc

@@ -94,7 +94,7 @@ static bool _set_fdlimit(rlim_t fds);
 static bool _switch_user(const char *user);
 
 extern "C" {
-static bool _set_signals(void);
+static bool _set_signals(bool core_dump= false);
 }
 
 static void _log(const char *line, gearmand_verbose_t verbose, void *context);
@@ -124,6 +124,7 @@ int main(int argc, char *argv[])
   bool opt_daemon;
   bool opt_check_args;
   bool opt_syslog;
+  bool opt_coredump;
   uint32_t hashtable_buckets;
 
   boost::program_options::options_description general("General options");
@@ -176,6 +177,9 @@ int main(int argc, char *argv[])
   ("syslog", boost::program_options::bool_switch(&opt_syslog)->default_value(false),
    "Use syslog.")
 
+  ("coredump", boost::program_options::bool_switch(&opt_coredump)->default_value(false),
+   "Whether to create a core dump for uncaught signals.")
+
   ("threads,t", boost::program_options::value(&threads)->default_value(4),
    "Number of I/O threads to use. Default=4.")
 
@@ -310,7 +314,7 @@ int main(int argc, char *argv[])
     return EXIT_SUCCESS;
   }
 
-  if (fds > 0 && _set_fdlimit(fds))
+  if (fds > 0 and _set_fdlimit(fds))
   {
     return EXIT_FAILURE;
   }
@@ -325,7 +329,7 @@ int main(int argc, char *argv[])
     util::daemonize(false, true);
   }
 
-  if (_set_signals())
+  if (_set_signals(opt_coredump))
   {
     return EXIT_FAILURE;
   }
@@ -505,7 +509,7 @@ extern "C" void _crash_handler(int signal_, siginfo_t*, void*)
 }
 
 extern "C" {
-static bool _set_signals(void)
+static bool _set_signals(bool core_dump)
 {
   struct sigaction sa;
 
@@ -548,7 +552,7 @@ static bool _set_signals(void)
 
   bool in_gdb_libtest= bool(getenv("LIBTEST_IN_GDB"));
 
-  if (in_gdb_libtest == false)
+  if ((in_gdb_libtest == false) and (core_dump == false))
   {
     sa.sa_sigaction= _crash_handler;
     if (sigaction(SIGSEGV, &sa, NULL) == -1)
@@ -572,13 +576,13 @@ static bool _set_signals(void)
 #endif
     if (sigaction(SIGILL, &sa, NULL) == -1)
     {
-      error::perror("Could not set SIGBUS handler.");
+      error::perror("Could not set SIGILL handler.");
       return true;
     }
 
     if (sigaction(SIGFPE, &sa, NULL) == -1)
     {
-      error::perror("Could not set SIGBUS handler.");
+      error::perror("Could not set SIGFPE handler.");
       return true;
     }
   }

+ 6 - 4
libhashkit/md5.cc

@@ -71,6 +71,8 @@ documentation and/or software.
 #include <string.h>
 #include <sys/types.h>
 
+#pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
+
 /* POINTER defines a generic pointer type */
 typedef unsigned char *POINTER;
 typedef const unsigned char *CONST_POINTER;
@@ -367,10 +369,10 @@ unsigned int len)
   unsigned int i, j;
 
   for (i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = (unsigned char)(input[i] & 0xff);
- output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
- output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
- output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
+    output[j] = (unsigned char)(input[i] & 0xff);
+    output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
+    output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
+    output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
   }
 }
 

+ 9 - 0
tests/gearmand.cc

@@ -103,6 +103,14 @@ static test_return_t long_daemon_test(void *)
   return TEST_SUCCESS;
 }
 
+static test_return_t long_coredump_TEST(void *)
+{
+  const char *args[]= { "--check-args", "--coredump", 0 };
+
+  ASSERT_EQ(EXIT_SUCCESS, exec_cmdline(gearmand_binary(), args, true));
+  return TEST_SUCCESS;
+}
+
 static test_return_t short_daemon_test(void *)
 {
   const char *args[]= { "--check-args", "-d", 0 };
@@ -538,6 +546,7 @@ test_st gearmand_option_tests[] ={
   {"--check-args", 0, check_args_test},
   {"--backlog=", 0, long_backlog_test},
   {"-b", 0, short_backlog_test},
+  {"--coredump", 0, long_coredump_TEST},
   {"--daemon", 0, long_daemon_test},
   {"-d", 0, short_daemon_test},
   {"--file-descriptors=", 0, long_file_descriptors_test},