|
@@ -50,48 +50,11 @@ using namespace libtest;
|
|
|
#include <tests/context.h>
|
|
|
#include <tests/start_worker.h>
|
|
|
|
|
|
+#include "tests/workers/v2/called.h"
|
|
|
+
|
|
|
#ifndef __INTEL_COMPILER
|
|
|
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
|
|
#endif
|
|
|
-pthread_mutex_t counter_lock= PTHREAD_MUTEX_INITIALIZER;
|
|
|
-
|
|
|
-struct counter_st
|
|
|
-{
|
|
|
- int32_t _count;
|
|
|
- pthread_mutex_t _lock;
|
|
|
-
|
|
|
- counter_st() :
|
|
|
- _count(0)
|
|
|
- {
|
|
|
- pthread_mutex_init(&_lock, NULL);
|
|
|
- }
|
|
|
-
|
|
|
- void increment()
|
|
|
- {
|
|
|
- pthread_mutex_lock(&_lock);
|
|
|
- _count++;
|
|
|
- pthread_mutex_unlock(&_lock);
|
|
|
- }
|
|
|
-
|
|
|
- int32_t count()
|
|
|
- {
|
|
|
- int32_t tmp;
|
|
|
- pthread_mutex_lock(&_lock);
|
|
|
- tmp= _count;
|
|
|
- pthread_mutex_unlock(&_lock);
|
|
|
-
|
|
|
- return tmp;
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
-static gearman_return_t counter_fn(gearman_job_st *, void *object)
|
|
|
-{
|
|
|
- counter_st *count= (counter_st*)object;
|
|
|
- assert(count);
|
|
|
- count->increment();
|
|
|
-
|
|
|
- return GEARMAN_SUCCESS;
|
|
|
-}
|
|
|
|
|
|
test_return_t client_echo_fail_test(void *object)
|
|
|
{
|
|
@@ -153,12 +116,12 @@ test_return_t queue_clean(void *object)
|
|
|
|
|
|
gearman_worker_set_timeout(worker, 3000);
|
|
|
|
|
|
- counter_st counter;
|
|
|
- gearman_function_t counter_function= gearman_function_create(counter_fn);
|
|
|
+ Called called;
|
|
|
+ gearman_function_t counter_function= gearman_function_create(called_worker);
|
|
|
test_compare(gearman_worker_define_function(worker,
|
|
|
test->worker_function_name(), strlen(test->worker_function_name()),
|
|
|
counter_function,
|
|
|
- 5, &counter), GEARMAN_SUCCESS);
|
|
|
+ 5, &called), GEARMAN_SUCCESS);
|
|
|
|
|
|
// Clean out any jobs that might still be in the queue from failed tests.
|
|
|
while (GEARMAN_SUCCESS == gearman_worker_work(worker)) {};
|
|
@@ -220,8 +183,8 @@ test_return_t queue_worker(void *object)
|
|
|
|
|
|
test_true(test->run_worker);
|
|
|
|
|
|
- counter_st counter;
|
|
|
- gearman_function_t counter_function= gearman_function_create(counter_fn);
|
|
|
+ Called counter;
|
|
|
+ gearman_function_t counter_function= gearman_function_create(called_worker);
|
|
|
test_compare(gearman_worker_define_function(worker,
|
|
|
test->worker_function_name(), strlen(test->worker_function_name()),
|
|
|
counter_function,
|
|
@@ -267,14 +230,14 @@ test_return_t lp_734663(void *object)
|
|
|
|
|
|
struct worker_handle_st *worker_handle[NUMBER_OF_WORKERS];
|
|
|
|
|
|
- counter_st counter;
|
|
|
- gearman_function_t counter_function_fn= gearman_function_create(counter_fn);
|
|
|
+ Called called;
|
|
|
+ gearman_function_t counter_function_fn= gearman_function_create(called_worker);
|
|
|
for (uint32_t x= 0; x < NUMBER_OF_WORKERS; x++)
|
|
|
{
|
|
|
- worker_handle[x]= test_worker_start(test->port(), NULL, worker_function_name, counter_function_fn, &counter, gearman_worker_options_t());
|
|
|
+ worker_handle[x]= test_worker_start(test->port(), NULL, worker_function_name, counter_function_fn, &called, gearman_worker_options_t());
|
|
|
}
|
|
|
|
|
|
- while (counter.count() < NUMBER_OF_JOBS)
|
|
|
+ while (called.count() < NUMBER_OF_JOBS)
|
|
|
{
|
|
|
libtest::dream(0, static_cast<long>(gearman_timeout(client) *1000));
|
|
|
}
|