Browse Source

Merge 1.0

Brian Aker 12 years ago
parent
commit
892c9e598d
10 changed files with 156 additions and 125 deletions
  1. 48 0
      .bzrignore
  2. 1 0
      Makefile.am
  3. 3 4
      bin/arguments.cc
  4. 11 0
      bin/arguments.h
  5. 69 76
      bootstrap.sh
  6. 9 1
      configure.ac
  7. 6 38
      docs/include.am
  8. 5 5
      libgearman/command.cc
  9. 2 0
      libgearman/connection.hpp
  10. 2 1
      libgearman/result.hpp

+ 48 - 0
.bzrignore

@@ -0,0 +1,48 @@
+!configure.ac
+*.patch
+*dirstamp
+.deps
+.gdb_history
+.libs
+Makefile
+Makefile.in
+aclocal.m4
+aminclude.am
+autom4te.cache
+build-aux
+config*
+docs/conf.py
+gdb.txt
+gear_config.h
+gear_config.in
+libgearman-1.0/version.h
+libgearman/gearman_client.lo
+libgearman/gearman_worker.lo
+libgearman/io.lo
+libgearman/libgearman_client.la
+libgearman/libgearman_config.h
+libgearman/libgearman_config.h.in
+libgearman/libgearman_worker.la
+libgearman/quit.lo
+libgearman/server.lo
+libgearman/stamp-h1
+libhashkit/hashkitcon.h
+libtest/version.h
+libtest/yatlcon.h
+libtool
+m4/libtool.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
+patch
+scripts/gearmand
+scripts/gearmand-init
+scripts/gearmand.xml
+scripts/smf_install.sh
+stamp-h1
+support/gearmand.pc
+support/gearmand.spec
+tests/client_test
+tests/worker_test
+valgrind*xml

+ 1 - 0
Makefile.am

@@ -16,6 +16,7 @@ check_PROGRAMS=
 noinst_PROGRAMS=
 lib_LTLIBRARIES=
 noinst_LTLIBRARIES=
+check_LTLIBRARIES=
 nobase_include_HEADERS=
 noinst_HEADERS=
 man1_MANS=

+ 3 - 4
bin/arguments.cc

@@ -82,10 +82,7 @@ Args::Args(int p_argc, char *p_argv[]) :
 
 Args::~Args()
 {
-  if (_arg_error)
-  {
-    free(_arg_error);
-  }
+  reset_arg_error();
 }
 
 void Args::init(int argc)
@@ -178,6 +175,7 @@ void Args::init(int argc)
       {
         size_t length= snprintf(NULL, 0, "-%c %s", char(c), optarg);
         ++length; // Add in space for null
+        reset_arg_error();
         _arg_error= (char*)malloc(length);
         if (_arg_error)
         {
@@ -188,6 +186,7 @@ void Args::init(int argc)
       {
         size_t length= snprintf(NULL, 0, "-%c", char(c));
         length++;
+        reset_arg_error();
         _arg_error= (char*)malloc(length);
         if (_arg_error)
         {

+ 11 - 0
bin/arguments.h

@@ -171,11 +171,22 @@ public:
     return argv;
   }
 
+  void reset_arg_error()
+  {
+    if (_arg_error)
+    {
+      free(_arg_error);
+      _arg_error= NULL;
+    }
+  }
+
   bool is_error()
   {
     if (_functions.empty())
     {
+      reset_arg_error();
       _arg_error= strdup("No Functions were provided");
+
       return true;
     }
 

+ 69 - 76
bootstrap.sh

@@ -234,6 +234,8 @@ function set_VENDOR_RELEASE ()
         VENDOR_RELEASE="precise"
       elif [[ "x$VENDOR_RELEASE" == 'x12.10' ]]; then
         VENDOR_RELEASE="quantal"
+      elif [[ "x$VENDOR_RELEASE" == 'x13.04' ]]; then
+        VENDOR_RELEASE="raring"
       fi
       ;;
     opensuse)
@@ -383,11 +385,16 @@ function run_configure ()
   local BUILD_CONFIGURE_ARG= 
 
   # If ENV DEBUG is set we enable both debug and asssert, otherwise we see if this is a VCS checkout and if so enable assert
-  # Set ENV ASSERT in order to enable assert
-  if $DEBUG; then 
-    BUILD_CONFIGURE_ARG+=' --enable-debug --enable-assert'
-  elif [[ -n "$VCS_CHECKOUT" ]]; then
-    BUILD_CONFIGURE_ARG+=' --enable-assert'
+  # Set ENV ASSERT in order to enable assert.
+  # If we are doing a valgrind run, we always compile with assert disabled
+  if $valgrind_run; then
+    BUILD_CONFIGURE_ARG+= '--enable-assert=no'
+  else
+    if $DEBUG; then 
+      BUILD_CONFIGURE_ARG+=' --enable-debug --enable-assert'
+    elif [[ -n "$VCS_CHECKOUT" ]]; then
+      BUILD_CONFIGURE_ARG+=' --enable-assert'
+    fi
   fi
 
   if [[ -n "$CONFIGURE_ARG" ]]; then 
@@ -439,7 +446,7 @@ function setup_gdb_command () {
 function setup_valgrind_command () {
   VALGRIND_PROGRAM=`type -p valgrind`
   if [[ -n "$VALGRIND_PROGRAM" ]]; then
-    VALGRIND_COMMAND="$VALGRIND_PROGRAM --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE"
+    VALGRIND_COMMAND="$VALGRIND_PROGRAM --error-exitcode=1 --leak-check=yes --malloc-fill=A5 --free-fill=DE --xml=yes --xml-file=\"valgrind-%p.xml\""
   fi
 }
 
@@ -539,11 +546,6 @@ function safe_popd ()
 
 function make_valgrind ()
 {
-  if [[ "$VENDOR_DISTRIBUTION" == 'darwin' ]]; then
-    make_darwin_malloc
-    return
-  fi
-
   # If the env VALGRIND_COMMAND is set then we assume it is valid
   local valgrind_was_set=false
   if [[ -z "$VALGRIND_COMMAND" ]]; then
@@ -563,20 +565,35 @@ function make_valgrind ()
 
   save_BUILD
 
+  valgrind_run=true
+
   # If we are required to run configure, do so now
-  run_configure_if_required
+  run_configure
 
   # If we don't have a configure, then most likely we will be missing libtool
   assert_file 'configure'
-  if [[ -f 'libtool' ]]; then
+  if [[ -x 'libtool' ]]; then
     TESTS_ENVIRONMENT="./libtool --mode=execute $VALGRIND_COMMAND"
   else
     TESTS_ENVIRONMENT="$VALGRIND_COMMAND"
   fi
 
-  make_target 'check' || return 1
+  make_target 'all'
+  make_target 'check'
+  ret=$?
+
+  # If we aren't going to error, we will clean up our environment
+  if [ "$ret" -eq 0 ]; then
+     make 'distclean'
+  fi
+
+  valgrind_run=false
 
   restore_BUILD
+
+  if [ "$ret" -ne 0 ]; then
+    return 1
+  fi
 }
 
 function make_install_system ()
@@ -627,32 +644,21 @@ function make_darwin_malloc ()
   MallocScribble=$old_MallocScribble
 }
 
-function snapshot_check ()
-{
-  if [ ! -f "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
-    make_for_snapshot
-  fi
-
-  if [ -n "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
-    assert_file "$BOOTSTRAP_SNAPSHOT_CHECK" 'snapshot check failed'
-  fi
-}
-
 # This will reset our environment, and make sure built files are available.
 function make_for_snapshot ()
 {
-  # Make sure it is clean
-  make_maintainer_clean
+  # Lets make sure we have a clean environment
+  assert_no_file 'Makefile'
+  assert_no_file 'configure'
+  assert_no_directory 'autom4te.cache'
 
   run_configure
-  make_target 'dist'
+  make_target 'all'
   make_target 'distclean'
 
   # We should have a configure, but no Makefile at the end of this exercise
   assert_no_file 'Makefile'
   assert_exec_file 'configure'
-
-  snapshot_check
 }
 
 function check_mingw ()
@@ -821,7 +827,7 @@ function make_for_clang_analyzer ()
 function check_for_jenkins ()
 {
   if ! $jenkins_build_environment; then
-    echo "Not inside of jenkins"
+    echo "Not inside of jenkins, simulating environment"
 
     if [ -f 'configure' ]; then
       make_maintainer_clean
@@ -850,6 +856,13 @@ function make_universe ()
   make_install_system
 }
 
+function check_snapshot ()
+{
+  if [ -n "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
+    assert_file "$BOOTSTRAP_SNAPSHOT_CHECK" 'snapshot check failed'
+  fi
+}
+
 function make_for_continuus_integration ()
 {
   # Setup the environment if we are local
@@ -861,7 +874,11 @@ function make_for_continuus_integration ()
   # Platforms which require bootstrap should have some setup done before we hit this stage.
   # If we are building locally, skip this step, unless we are just testing locally. 
   if $BOOTSTRAP_SNAPSHOT; then
-    snapshot_check
+    if $BOOTSTRAP_SNAPSHOT; then
+      assert_file 'configure'
+    fi
+
+    check_snapshot
   else
     # If we didn't require a snapshot, then we should not have a configure
     assert_no_file 'configure'
@@ -872,48 +889,6 @@ function make_for_continuus_integration ()
   assert_no_file 'Makefile' 'Programmer error, Makefile existed where build state should have been clean'
 
   case $HOST_OS in
-    *-fedora-*)
-      run_configure
-
-      assert_exec_file 'configure'
-      assert_file 'Makefile'
-
-      make_target 'all'
-
-      # make rpm includes "make distcheck"
-      if [[ -f rpm.am ]]; then
-        make_rpm
-      elif [[ -d rpm ]]; then
-        make_rpm
-      else
-        make_distcheck
-      fi
-
-      assert_exec_file 'configure'
-      assert_file 'Makefile'
-
-      make_install_system
-      ;;
-    *-precise-*)
-      run_configure
-
-      assert_exec_file 'configure'
-      assert_file 'Makefile'
-
-      make_target 'all'
-
-      make_distcheck
-
-      assert_exec_file 'configure'
-      assert_file 'Makefile'
-
-      make_valgrind
-
-      assert_exec_file 'configure'
-      assert_file 'Makefile'
-
-      make_install_system
-      ;;
     *)
       make_jenkins_default
       ;;
@@ -1015,6 +990,8 @@ function make_target ()
   if [ $ret -ne 0 ]; then
     if [ -n "$2" ]; then
       warn "Failed to execute $MAKE $1: $ret"
+    elif [ $ret -eq 2 ]; then
+      die "Failed to execute $MAKE $1"
     else
       die "Failed to execute $MAKE $1: $ret"
     fi
@@ -1110,7 +1087,7 @@ function run_autoreconf ()
     run $BOOTSTRAP_LIBTOOLIZE '--copy' '--install' '--force' || die "Cannot execute $BOOTSTRAP_LIBTOOLIZE"
   fi
 
-  run $AUTORECONF || die "Cannot execute $AUTORECONF"
+  run $AUTORECONF $AUTORECONF_ARGS || die "Cannot execute $AUTORECONF"
 
   eval 'bash -n configure' || die "autoreconf generated a malformed configure"
 }
@@ -1291,12 +1268,16 @@ function autoreconf_setup ()
         fi
       fi
     fi
+
     if $VERBOSE; then
       LIBTOOLIZE_OPTIONS="--verbose $BOOTSTRAP_LIBTOOLIZE_OPTIONS"
     fi
+
     if $DEBUG; then
       LIBTOOLIZE_OPTIONS="--debug $BOOTSTRAP_LIBTOOLIZE_OPTIONS"
     fi
+
+    # Here we set LIBTOOLIZE to true since we are going to invoke it via BOOTSTRAP_LIBTOOLIZE
     LIBTOOLIZE=true
   fi
 
@@ -1334,7 +1315,7 @@ function autoreconf_setup ()
     fi
 
     if [[ -n "$GNU_BUILD_FLAGS" ]]; then
-      AUTORECONF="$AUTORECONF $GNU_BUILD_FLAGS"
+      AUTORECONF_ARGS="$GNU_BUILD_FLAGS"
     fi
   fi
 
@@ -1561,6 +1542,7 @@ function bootstrap ()
     fi
 
     local snapshot_run=false
+    local valgrind_run=false
 
     case $target in
       'self')
@@ -1620,11 +1602,16 @@ function bootstrap ()
       'snapshot')
         make_for_snapshot
         snapshot_run=true
+        check_snapshot
         ;;
       'rpm')
         make_rpm
         ;;
+      'darwin_malloc')
+        make_darwin_malloc
+        ;;
       'valgrind')
+        make_maintainer_clean 
         make_valgrind
         ;;
       'universe')
@@ -1719,6 +1706,12 @@ function main ()
           MAKE_TARGET="$label"
         fi
       fi
+      if [[ -n "$LABEL" ]]; then
+        check_make_target $LABEL
+        if [ $? -eq 0 ]; then
+          MAKE_TARGET="$LABEL"
+        fi
+      fi
 
       if [ -z "$MAKE_TARGET" ]; then
         MAKE_TARGET='jenkins'

+ 9 - 1
configure.ac

@@ -40,6 +40,9 @@ LT_PREREQ([2.2])
 LT_INIT([disable-static])
 LT_LANG([C++])
 
+AC_PROG_CC_C99
+AS_IF([test "x${ac_cv_prog_cc_c99}" == "xno"],[AC_MSG_ERROR([No c99 compatible compiler found])])
+
 AX_PLATFORM
 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
 AX_ASSERT
@@ -92,14 +95,19 @@ FCNTL_FLAGS
 AX_ENABLE_LIBHIREDIS
 
 # Checks for programs.
+AC_CHECK_PROGS([DPKG_GENSYMBOLS],[dpkg-gensymbols])
+AC_CHECK_PROGS([PERL],[perl])
 AC_CHECK_PROGS([VALGRIND],['valgrind'])
+AC_CHECK_PROGS([WINE],['wine'])
 AC_PATH_PROG([GPERF],['gperf'])
 AC_PROG_AWK
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AX_PROG_MEMCACHED
-AX_PROG_SPHINX_BUILD
+AX_PROG_SPHINX_BUILD(,[AC_MSG_WARN([sphinx-build version 1.0 or greater is required to build man pages])])
+AX_WITH_PROG([LCOV],[lcov])
+AX_WITH_PROG([LCOV_GENHTML],[genhtml])
 
 # Checks for header files.
 AC_HEADER_STDC

+ 6 - 38
docs/include.am

@@ -7,37 +7,21 @@
 
 SPHINXOPTS    = ${SPHINX_WARNINGS} -q
 PAPER         =
-SPHINX_BUILDDIR      = ${abs_top_builddir}/docs
+SPHINX_BUILDDIR      = ${abs_srcdir}/docs
 
 # Internal variables.
 PAPEROPT_a4     = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS   = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SPHINX_BUILDDIR)
+ALLSPHINXOPTS   = -c $(top_builddir)/docs $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SPHINX_BUILDDIR)
 
 .PHONY: clean-docs-check
 clean-docs-check:
-	-rm -rf docs/_build docs/doctrees man/.doctrees/
+	-rm -rf docs/_build docs/doctrees man/.doctrees
 
 .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
-if HAVE_SPHINX
-
-sphinx-help:
-	@echo "Please use \`make <target>' where <target> is one of"
-	@echo "  html       to make standalone HTML files"
-	@echo "  singlehtml to make a single large HTML file"
-	@echo "  pickle     to make pickle files"
-	@echo "  json       to make JSON files"
-	@echo "  htmlhelp   to make HTML files and a HTML help project"
-	@echo "  qthelp     to make HTML files and a qthelp project"
-	@echo "  devhelp    to make HTML files and a Devhelp project"
-	@echo "  epub       to make an epub"
-	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
-	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
-	@echo "  text       to make text files"
-	@echo "  man        to make manual pages"
-	@echo "  changes    to make an overview of all changed/added/deprecated items"
-	@echo "  linkcheck  to check all external links for integrity"
-	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+man: docs/conf.py
+	@PYTHONPATH=$(SPHINX_BUILDDIR)/docs  $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) ${top_builddir}/man
 
 install-html-local: html-local
 	@$(MKDIR_P)  $(htmldir)/html
@@ -86,16 +70,6 @@ latexpdf: latex
 text: docs/conf.py
 	@PYTHONPATH=${top_srcdir}/docs  $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(SPHINX_BUILDDIR)/text
 
-if HAVE_RECENT_SPHINX
-man:
-	@PYTHONPATH=$(SPHINX_BUILDDIR)/docs  $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) ${top_builddir}/man
-
-else
-
-man:
-
-endif
-
 changes: docs/conf.py
 	@PYTHONPATH=${top_srcdir}/docs  $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(SPHINX_BUILDDIR)/changes
 
@@ -107,12 +81,6 @@ doctest: docs/conf.py
 	@echo "Testing of doctests in the sources finished, look at the " \
 	      "results in $(SPHINX_BUILDDIR)/doctest/output.txt."
 
-else
-
-man:
-
-endif
-
 noinst_PROGRAMS+= docs/libgearman/examples/gearman_client_do_background_example
 noinst_PROGRAMS+= docs/libgearman/examples/gearman_client_do_example
 noinst_PROGRAMS+= docs/libgearman/examples/gearman_execute_example

+ 5 - 5
libgearman/command.cc

@@ -88,11 +88,11 @@ gearman_command_info_st gearmand_command_info_list[GEARMAN_COMMAND_MAX]=
   { "SUBMIT_JOB_SCHED", GEARMAN_COMMAND_SUBMIT_JOB_SCHED, 7, true  },
   { "SUBMIT_JOB_EPOCH", GEARMAN_COMMAND_SUBMIT_JOB_EPOCH, 3, true  },
   { "SUBMIT_REDUCE_JOB", GEARMAN_COMMAND_SUBMIT_REDUCE_JOB, 4, true },
-  { "GEARMAN_COMMAND_SUBMIT_REDUCE_JOB_BACKGROUND", GEARMAN_COMMAND_SUBMIT_REDUCE_JOB_BACKGROUND, 4, true },
-  { "GEARMAN_COMMAND_GRAB_JOB_ALL", GEARMAN_COMMAND_GRAB_JOB_ALL, 0, false  },
-  { "GEARMAN_COMMAND_JOB_ASSIGN_ALL", GEARMAN_COMMAND_JOB_ASSIGN_ALL,   4, true  },
-  { "GEARMAN_COMMAND_GET_STATUS_UNIQUE", GEARMAN_COMMAND_GET_STATUS_UNIQUE, 1, false },
-  { "GEARMAN_COMMAND_STATUS_RES_UNIQUE", GEARMAN_COMMAND_STATUS_RES_UNIQUE, 6, false }
+  { "SUBMIT_REDUCE_JOB_BACKGROUND", GEARMAN_COMMAND_SUBMIT_REDUCE_JOB_BACKGROUND, 4, true },
+  { "GRAB_JOB_ALL", GEARMAN_COMMAND_GRAB_JOB_ALL, 0, false  },
+  { "JOB_ASSIGN_ALL", GEARMAN_COMMAND_JOB_ASSIGN_ALL,   4, true  },
+  { "GET_STATUS_UNIQUE", GEARMAN_COMMAND_GET_STATUS_UNIQUE, 1, false },
+  { "STATUS_RES_UNIQUE", GEARMAN_COMMAND_STATUS_RES_UNIQUE, 6, false }
 };
 
 gearman_command_info_st *gearman_command_info(gearman_command_t command)

+ 2 - 0
libgearman/connection.hpp

@@ -131,6 +131,8 @@ public:
     _recv_packet= NULL;
   }
 
+  gearman_connection_st(const gearman_connection_st&);
+
 private:
   gearman_return_t _send_packet(const gearman_packet_st&, const bool flush_buffer);
   gearman_return_t set_socket_options();

+ 2 - 1
libgearman/result.hpp

@@ -64,7 +64,8 @@ struct gearman_result_st
 
     Value() :
       _boolean(false),
-      _integer(0)
+      _integer(0),
+      string()
     { }
 
     Value(size_t initial_size) :

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