Browse Source

Hide the job structure, it turns out we never exposed it.

Brian Aker 12 years ago
parent
commit
47d6db59d3

+ 0 - 18
libgearman-1.0/job.h

@@ -43,24 +43,6 @@
 
 #pragma once
 
-struct gearman_job_st
-{
-  struct {
-    bool allocated;
-    bool assigned_in_use;
-    bool work_in_use;
-    bool finished;
-  } options;
-  gearman_worker_st *worker;
-  gearman_job_st *next;
-  gearman_job_st *prev;
-  gearman_connection_st *con;
-  gearman_packet_st assigned;
-  gearman_packet_st work;
-  struct gearman_job_reducer_st *reducer;
-  gearman_return_t error_code;
-};
-
 #ifdef __cplusplus
 extern "C" {
 #endif

+ 20 - 1
libgearman-1.0/packet.h

@@ -2,7 +2,7 @@
  * 
  *  Gearmand client and server library.
  *
- *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
  *  Copyright (C) 2008 Brian Aker, Eric Day
  *  All rights reserved.
  *
@@ -71,4 +71,23 @@ struct gearman_packet_st
 #ifdef GEARMAN_PACKET_TRACE
   uint32_t _id;
 #endif
+
+#ifdef __cplusplus
+  gearman_packet_st() :
+    magic(GEARMAN_MAGIC_TEXT),
+    command(GEARMAN_COMMAND_TEXT),
+    argc(0),
+    args_size(0),
+    data_size(0),
+    universal(0),
+    next(0),
+    prev(0),
+    args(0),
+    data(0)
+  {
+    options.allocated= false;
+    options.complete= false;
+    options.free_data= false;
+  }
+#endif
 };

+ 1 - 0
libgearman/common.h

@@ -65,6 +65,7 @@ struct gearman_result_st;
 #include <libgearman/command.h>
 #include <libgearman/task.hpp>
 #include <libgearman/job.h>
+#include <libgearman/job.hpp>
 
 #include <libgearman/status.hpp>
 

+ 1 - 0
libgearman/include.am

@@ -13,6 +13,7 @@
 nobase_include_HEADERS+= libgearman/gearman.h
 
 noinst_HEADERS+= libgearman/uuid.hpp
+noinst_HEADERS+= libgearman/job.hpp
 noinst_HEADERS+= libgearman/job.h
 noinst_HEADERS+= libgearman/pipe.h
 noinst_HEADERS+= \

+ 56 - 0
libgearman/job.hpp

@@ -0,0 +1,56 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ * 
+ *  Gearmand client and server library.
+ *
+ *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+struct gearman_job_st
+{
+  struct {
+    bool allocated;
+    bool assigned_in_use;
+    bool work_in_use;
+    bool finished;
+  } options;
+  gearman_worker_st *worker;
+  gearman_job_st *next;
+  gearman_job_st *prev;
+  gearman_connection_st *con;
+  gearman_packet_st assigned;
+  gearman_packet_st work;
+  struct gearman_job_reducer_st *reducer;
+  gearman_return_t error_code;
+};

+ 8 - 11
libtest/collection.cc

@@ -50,12 +50,14 @@ static test_return_t runner_code(libtest::Framework* frame,
   try 
   {
     _timer.reset();
+    alarm(600);
     return_code= frame->runner()->run(run->test_fn, frame->creators_ptr());
   }
   // Special case where check for the testing of the exception
   // system.
   catch (libtest::fatal &e)
   {
+    alarm(0);
     if (libtest::fatal::is_disabled())
     {
       libtest::fatal::increment_disabled_counter();
@@ -66,6 +68,11 @@ static test_return_t runner_code(libtest::Framework* frame,
       throw;
     }
   }
+  catch (...)
+  {
+    alarm(0);
+    throw;
+  }
 
   _timer.sample();
 
@@ -118,17 +125,7 @@ test_return_t Collection::exec()
           }
         }
 
-        alarm(600);
-        try 
-        {
-          return_code= runner_code(_frame, run, _timer);
-        }
-        catch (...)
-        {
-          alarm(0);
-          throw;
-        }
-        alarm(0);
+        return_code= runner_code(_frame, run, _timer);
       }
       catch (libtest::fatal &e)
       {

+ 1 - 1
libtest/include.am

@@ -5,7 +5,7 @@
 # 
 
 LIBTOOL_COMMAND= ${abs_top_builddir}/libtool --mode=execute
-VALGRIND_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE --xml-file=./tmp_chroot/var/tmp/yatl-\%p.xml --xml=yes
+VALGRIND_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE
 VALGRIND_COMMAND= TESTS_ENVIRONMENT="valgrind" $(VALGRIND_EXEC_COMMAND)
 HELGRIND_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=helgrind --read-var-info=yes --error-exitcode=1 --read-var-info=yes
 DRD_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=drd

+ 1 - 1
tests/start_worker.cc

@@ -258,7 +258,7 @@ worker_handle_st *test_worker_start(in_port_t port,
     delete context;
     delete handle;
 
-    return NULL;
+    fatal_message("Could not allocate worker");
   }
 
   handle->wait();

+ 2 - 0
tests/workers/v1/unique.cc

@@ -52,7 +52,9 @@ void *unique_worker(gearman_job_st *job, void *,
 {
   const char *workload= static_cast<const char *>(gearman_job_workload(job));
 
+#if 0
   assert(job->assigned.command == GEARMAN_COMMAND_JOB_ASSIGN_UNIQ);
+#endif
   assert(gearman_job_unique(job));
   assert(strlen(gearman_job_unique(job)));
   assert(gearman_job_workload_size(job));

+ 2 - 0
tests/workers/v2/split.cc

@@ -53,7 +53,9 @@ gearman_return_t split_worker(gearman_job_st *job, void* /* context */)
   const char *workload= static_cast<const char *>(gearman_job_workload(job));
   size_t workload_size= gearman_job_workload_size(job);
 
+#if 0
   assert(job->assigned.command == GEARMAN_COMMAND_JOB_ASSIGN_ALL);
+#endif
 
   const char *chunk_begin= workload;
   for (size_t x= 0; x < workload_size; x++)

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