Merge lp:~brianaker/gearmand/clocktime-option-check-fixes into lp:gearmand

Proposed by Brian Aker
Status: Merged
Merged at revision: 820
Proposed branch: lp:~brianaker/gearmand/clocktime-option-check-fixes
Merge into: lp:gearmand
Diff against target: 627 lines (+246/-56)
21 files modified
configure.ac (+9/-4)
libgearman-1.0/limits.h (+1/-0)
libgearman-server/gearmand_thread.cc (+2/-2)
libgearman-server/plugins/protocol/gear/protocol.cc (+12/-3)
libgearman-server/server.cc (+5/-3)
libgearman/check.cc (+14/-8)
libgearman/check.h (+7/-5)
libgearman/client.cc (+10/-5)
libgearman/connection.cc (+5/-6)
libgearman/execute.cc (+10/-12)
libgearman/include.am (+2/-0)
libgearman/protocol/option.cc (+80/-0)
libgearman/protocol/option.h (+50/-0)
libgearman/universal.cc (+27/-0)
libgearman/universal.hpp (+2/-0)
libgearmancore/include.am (+1/-0)
libtest/timer.cc (+2/-2)
tests/libgearman-1.0/gearman_execute_partition.cc (+2/-2)
tests/libgearman-1.0/include.am (+1/-1)
tests/libgearman-1.0/server_options.cc (+3/-3)
tests/libgearman-1.0/worker_test.cc (+1/-0)
To merge this branch: bzr merge lp:~brianaker/gearmand/clocktime-option-check-fixes
Reviewer Review Type Date Requested Status
Tangent Trunk Pending
Review via email: mp+173908@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.ac'
--- configure.ac 2013-07-09 08:48:15 +0000
+++ configure.ac 2013-07-10 10:57:30 +0000
@@ -205,7 +205,6 @@
205AC_CHECK_FUNCS([strtoul])205AC_CHECK_FUNCS([strtoul])
206AC_CHECK_FUNCS([uname])206AC_CHECK_FUNCS([uname])
207AC_CHECK_FUNCS([atexit])207AC_CHECK_FUNCS([atexit])
208AC_CHECK_FUNCS([clock_gettime])
209AC_CHECK_FUNCS([getcwd])208AC_CHECK_FUNCS([getcwd])
210AC_CHECK_FUNCS([strstr])209AC_CHECK_FUNCS([strstr])
211AC_CHECK_FUNC([setsockopt],[],[AC_CHECK_LIB([socket],[setsockopt])])210AC_CHECK_FUNC([setsockopt],[],[AC_CHECK_LIB([socket],[setsockopt])])
@@ -216,9 +215,15 @@
216215
217# Check for -lrt216# Check for -lrt
218AC_CHECK_LIB([rt],[clock_gettime],217AC_CHECK_LIB([rt],[clock_gettime],
219 [AC_SUBST([RT_LIB],[-lrt])218 [AX_SAVE_FLAGS
220 AC_DEFINE([HAVE_LIBRT],[1],[Have clock_gettime])219 LIBS="$LIB -lrt"
221 ])220 AC_CHECK_FUNCS([clock_gettime])
221 AX_RESTORE_FLAGS
222
223 AC_SUBST([RT_LIB],[-lrt])
224 AC_DEFINE([HAVE_LIBRT],[1],[Have -lrt])
225 ],
226 [AC_CHECK_FUNCS([clock_gettime])])
222227
223# Check for -lm228# Check for -lm
224LT_LIB_M229LT_LIB_M
225230
=== modified file 'libgearman-1.0/limits.h'
--- libgearman-1.0/limits.h 2012-05-13 23:19:56 +0000
+++ libgearman-1.0/limits.h 2013-07-10 10:57:30 +0000
@@ -49,6 +49,7 @@
49#define GEARMAN_MAXIMUM_INTEGER_DISPLAY_LENGTH 2049#define GEARMAN_MAXIMUM_INTEGER_DISPLAY_LENGTH 20
50#define GEARMAN_MAX_COMMAND_ARGS 850#define GEARMAN_MAX_COMMAND_ARGS 8
51#define GEARMAN_MAX_ECHO_SIZE (UINT32_MAX -GEARMAN_ARGS_BUFFER_SIZE)51#define GEARMAN_MAX_ECHO_SIZE (UINT32_MAX -GEARMAN_ARGS_BUFFER_SIZE)
52#define GEARMAN_MAX_OPTION_SIZE (UINT32_MAX -GEARMAN_ARGS_BUFFER_SIZE)
52#define GEARMAN_MAX_ERROR_SIZE 204853#define GEARMAN_MAX_ERROR_SIZE 2048
53#define GEARMAN_MAX_IDENTIFIER 25454#define GEARMAN_MAX_IDENTIFIER 254
54#define GEARMAN_MAX_UNIQUE_SIZE 6455#define GEARMAN_MAX_UNIQUE_SIZE 64
5556
=== modified file 'libgearman-server/gearmand_thread.cc'
--- libgearman-server/gearmand_thread.cc 2013-07-07 00:16:26 +0000
+++ libgearman-server/gearmand_thread.cc 2013-07-10 10:57:30 +0000
@@ -60,8 +60,8 @@
60#if defined(HAVE_PTHREAD_TIMEDJOIN_NP) && HAVE_PTHREAD_TIMEDJOIN_NP60#if defined(HAVE_PTHREAD_TIMEDJOIN_NP) && HAVE_PTHREAD_TIMEDJOIN_NP
61bool fill_timespec(struct timespec& ts)61bool fill_timespec(struct timespec& ts)
62{62{
63#if defined(HAVE_LIBRT) && HAVE_LIBRT63#if defined(HAVE_CLOCK_GETTIME) && HAVE_CLOCK_GETTIME
64 if (HAVE_LIBRT) // This won't be called on OSX, etc,...64 if (HAVE_CLOCK_GETTIME) // This won't be called on OSX, etc,...
65 {65 {
66 if (clock_gettime(CLOCK_REALTIME, &ts) == -1) 66 if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
67 {67 {
6868
=== modified file 'libgearman-server/plugins/protocol/gear/protocol.cc'
--- libgearman-server/plugins/protocol/gear/protocol.cc 2013-07-07 00:23:12 +0000
+++ libgearman-server/plugins/protocol/gear/protocol.cc 2013-07-10 10:57:30 +0000
@@ -254,8 +254,8 @@
254 "GEAR length: %" PRIu64 " gearmand_command_t: %s option: %.*s",254 "GEAR length: %" PRIu64 " gearmand_command_t: %s option: %.*s",
255 uint64_t(packet->data_size),255 uint64_t(packet->data_size),
256 gearman_strcommand(packet->command),256 gearman_strcommand(packet->command),
257 int(packet->data_size),257 int(packet->arg_size[0]),
258 packet->data);258 packet->arg[0]);
259 }259 }
260 else260 else
261 {261 {
@@ -277,12 +277,21 @@
277 if (packet->command == GEARMAN_COMMAND_ECHO_RES)277 if (packet->command == GEARMAN_COMMAND_ECHO_RES)
278 {278 {
279 gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM,279 gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM,
280 "GEAR length: %" PRIu64 " gearmand_command_t: %s echo: %.*",280 "GEAR length: %" PRIu64 " gearmand_command_t: %s echo: %.*s",
281 uint64_t(packet->data_size),281 uint64_t(packet->data_size),
282 gearman_strcommand(packet->command),282 gearman_strcommand(packet->command),
283 int(packet->data_size),283 int(packet->data_size),
284 packet->data);284 packet->data);
285 }285 }
286 else if (packet->command == GEARMAN_COMMAND_OPTION_RES)
287 {
288 gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM,
289 "GEAR length: %" PRIu64 " gearmand_command_t: %s option: %.*s",
290 uint64_t(packet->data_size),
291 gearman_strcommand(packet->command),
292 int(packet->arg_size[0]),
293 packet->arg[0]);
294 }
286 else295 else
287 {296 {
288 gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM,297 gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM,
289298
=== modified file 'libgearman-server/server.cc'
--- libgearman-server/server.cc 2013-07-05 22:06:45 +0000
+++ libgearman-server/server.cc 2013-07-10 10:57:30 +0000
@@ -72,11 +72,13 @@
72 * Queue an error packet.72 * Queue an error packet.
73 */73 */
74static gearmand_error_t _server_error_packet(gearman_server_con_st *server_con,74static gearmand_error_t _server_error_packet(gearman_server_con_st *server_con,
75 gearman_return_t error_code, const char *error_string)75 gearman_return_t client_return_code, const char *error_string)
76{76{
77 const char* error_code_string= gearman_strerror(error_code);77 const char* error_code_string= gearman_strerror(client_return_code);
78 error_code_string+= 8;78 error_code_string+= 8;
7979
80 gearmand_log_error(GEARMAN_DEFAULT_LOG_PARAM, "%s:%s", gearman_strerror(client_return_code), error_string);
81
80 return gearman_server_io_packet_add(server_con, false, GEARMAN_MAGIC_RESPONSE,82 return gearman_server_io_packet_add(server_con, false, GEARMAN_MAGIC_RESPONSE,
81 GEARMAN_COMMAND_ERROR, error_code_string,83 GEARMAN_COMMAND_ERROR, error_code_string,
82 (size_t)(strlen(error_code_string) + 1),84 (size_t)(strlen(error_code_string) + 1),
@@ -818,7 +820,7 @@
818 server_job->function->function_name_size, server_job->function->function_name, server_job->function->function_name_size);820 server_job->function->function_name_size, server_job->function->function_name, server_job->function->function_name_size);
819 if (server_job == NULL)821 if (server_job == NULL)
820 {822 {
821 return _server_error_packet(server_con, GEARMAN_NO_JOBS, "Job given in work result not found");823 return _server_error_packet(server_con, GEARMAN_NO_JOBS, "An exception was received for a job that does not exist");
822 }824 }
823825
824 /* Queue the exception packet for all clients. */826 /* Queue the exception packet for all clients. */
825827
=== modified file 'libgearman/check.cc'
--- libgearman/check.cc 2013-07-08 09:58:12 +0000
+++ libgearman/check.cc 2013-07-10 10:57:30 +0000
@@ -93,19 +93,21 @@
93 if (con->_packet.argc)93 if (con->_packet.argc)
94 {94 {
95 gearman_return_t maybe_server_error= string2return_code(static_cast<char *>(con->_packet.arg[0]), int(con->_packet.arg_size[0]));95 gearman_return_t maybe_server_error= string2return_code(static_cast<char *>(con->_packet.arg[0]), int(con->_packet.arg_size[0]));
96
97 if (maybe_server_error == GEARMAN_MAX_RETURN)96 if (maybe_server_error == GEARMAN_MAX_RETURN)
98 {97 {
99 maybe_server_error= GEARMAN_SERVER_ERROR;98 maybe_server_error= GEARMAN_SERVER_ERROR;
100 }99 }
101100
102 return gearman_universal_set_error(_universal, maybe_server_error, GEARMAN_AT, "%.*s:%.*s",101 return gearman_universal_set_error(_universal, maybe_server_error, GEARMAN_AT, "%s:%s %.*s:%.*s",
102 con->host(), con->service(),
103 con->_packet.arg_size[0], con->_packet.arg[0],103 con->_packet.arg_size[0], con->_packet.arg[0],
104 con->_packet.arg_size[1], con->_packet.arg[1]104 con->_packet.arg_size[1], con->_packet.arg[1]
105 );105 );
106 }106 }
107107
108 return gearman_error(_universal, GEARMAN_SERVER_ERROR, "server lacks support for client's to cancel a job");108 return gearman_universal_set_error(_universal, GEARMAN_SERVER_ERROR, GEARMAN_AT, "%s:%s lacks support for client's to cancel a job",
109 con->host(), con->service()
110 );
109 }111 }
110112
111 return GEARMAN_SUCCESS;113 return GEARMAN_SUCCESS;
@@ -118,20 +120,24 @@
118 if (con->_packet.argc)120 if (con->_packet.argc)
119 {121 {
120 gearman_return_t maybe_server_error= string2return_code(static_cast<char *>(con->_packet.arg[0]), int(con->_packet.arg_size[0]));122 gearman_return_t maybe_server_error= string2return_code(static_cast<char *>(con->_packet.arg[0]), int(con->_packet.arg_size[0]));
121
122 if (maybe_server_error == GEARMAN_MAX_RETURN)123 if (maybe_server_error == GEARMAN_MAX_RETURN)
123 {124 {
124 maybe_server_error= GEARMAN_INVALID_SERVER_OPTION;125 maybe_server_error= GEARMAN_INVALID_SERVER_OPTION;
125 }126 }
126127
127 return gearman_universal_set_error(_universal, maybe_server_error, GEARMAN_AT, "%d: %.*s:%.*s", con->_packet.argc,128 return gearman_universal_set_error(_universal, maybe_server_error, GEARMAN_AT, "%s:%s Invalid option %.*s",
128 con->_packet.arg_size[0], con->_packet.arg[0],129 con->host(), con->service(),
129 con->_packet.arg_size[1], con->_packet.arg[1]130 con->_packet.arg_size[0], con->_packet.arg[0]
130 );131 );
131 }132 }
132133
133 return gearman_error(_universal, GEARMAN_INVALID_SERVER_OPTION, "invalid server option");134 return gearman_universal_set_error(_universal, GEARMAN_INVALID_SERVER_OPTION, GEARMAN_AT, "%s:%s Invalid option %.*s",
135 con->host(), con->service(),
136 con->_packet.arg_size[0], con->_packet.arg[0]
137 );
134 }138 }
135139
140 // @todo mark option set for connection
141
136 return GEARMAN_SUCCESS;142 return GEARMAN_SUCCESS;
137}143}
138144
=== modified file 'libgearman/check.h'
--- libgearman/check.h 2013-04-16 10:05:29 +0000
+++ libgearman/check.h 2013-07-10 10:57:30 +0000
@@ -59,15 +59,17 @@
5959
60class OptionCheck : public Check {60class OptionCheck : public Check {
61public:61public:
62 OptionCheck(gearman_universal_st& universal_):62 OptionCheck(gearman_universal_st& universal_, gearman_string_t& option_):
63 _universal(universal_)63 _universal(universal_),
64 {64 _option(option_)
65 }65 {
66 }
6667
67 gearman_return_t success(gearman_connection_st* con);68 gearman_return_t success(gearman_connection_st* con);
6869
69private:70private:
70 gearman_universal_st& _universal;71 gearman_universal_st& _universal;
72 gearman_string_t& _option;
71};73};
7274
73class CancelCheck : public Check {75class CancelCheck : public Check {
7476
=== modified file 'libgearman/client.cc'
--- libgearman/client.cc 2013-07-08 11:33:16 +0000
+++ libgearman/client.cc 2013-07-10 10:57:30 +0000
@@ -1806,15 +1806,20 @@
1806{1806{
1807 if (client_shell and client_shell->impl())1807 if (client_shell and client_shell->impl())
1808 {1808 {
1809 Client* client= client_shell->impl();
1809 gearman_string_t option= { option_arg, option_arg_size };1810 gearman_string_t option= { option_arg, option_arg_size };
1810 if (gearman_request_option(client_shell->impl()->universal, option))1811
1812 if (gearman_success(gearman_server_option(client->universal, option)))
1811 {1813 {
1812 if (strcmp("exceptions", option_arg) == 0)1814 if (gearman_request_option(client->universal, option))
1813 {1815 {
1814 client_shell->impl()->options.exceptions= true;1816 if (strncmp("exceptions", option_arg, sizeof("exceptions")) == 0)
1817 {
1818 client->options.exceptions= true;
1819 }
1820
1821 return true;
1815 }1822 }
1816
1817 return true;
1818 }1823 }
1819 }1824 }
18201825
18211826
=== modified file 'libgearman/connection.cc'
--- libgearman/connection.cc 2013-07-08 09:58:12 +0000
+++ libgearman/connection.cc 2013-07-10 10:57:30 +0000
@@ -49,6 +49,8 @@
49#include "libgearman/interface/push.hpp"49#include "libgearman/interface/push.hpp"
50#include "libgearman/log.hpp"50#include "libgearman/log.hpp"
5151
52#include "libgearman/protocol/option.h"
53
52#include <cerrno>54#include <cerrno>
53#include <cstdio>55#include <cstdio>
54#include <cstdlib>56#include <cstdlib>
@@ -425,11 +427,8 @@
425 head= head->next)427 head= head->next)
426 {428 {
427 gearman_packet_st message;429 gearman_packet_st message;
428 const void *args[]= { (const void*)head->value() };430 gearman_string_t option= { (const char*)head->value(), head->size() };
429 size_t args_size[]= { head->size() };431 gearman_return_t ret= libgearman::protocol::option(universal, message, option);
430 gearman_return_t ret= gearman_packet_create_args(universal, message, GEARMAN_MAGIC_REQUEST,
431 GEARMAN_COMMAND_OPTION_REQ, args, args_size, 1);
432
433 if (gearman_failed(ret))432 if (gearman_failed(ret))
434 {433 {
435 assert(universal.error_code());434 assert(universal.error_code());
@@ -439,7 +438,7 @@
439 }438 }
440439
441 PUSH_BLOCKING(universal);440 PUSH_BLOCKING(universal);
442 OptionCheck check(universal);441 OptionCheck check(universal, option);
443 ret= _send_packet(message, true);442 ret= _send_packet(message, true);
444 if (gearman_failed(ret))443 if (gearman_failed(ret))
445 {444 {
446445
=== modified file 'libgearman/execute.cc'
--- libgearman/execute.cc 2013-07-07 00:13:00 +0000
+++ libgearman/execute.cc 2013-07-10 10:57:30 +0000
@@ -259,20 +259,18 @@
259 NULL);259 NULL);
260 }260 }
261261
262 if (task == NULL)262 if (task)
263 {263 {
264 return NULL;264 do {
265 gearman_return_t rc;
266 if (gearman_failed(rc= gearman_client_run_tasks(client->shell())))
267 {
268 gearman_gerror(client->universal, rc);
269 gearman_task_free(task);
270 return NULL;
271 }
272 } while (gearman_continue(gearman_task_return(task)));
265 }273 }
266274
267 do {
268 gearman_return_t rc;
269 if (gearman_failed(rc= gearman_client_run_tasks(client->shell())))
270 {
271 gearman_gerror(client->universal, rc);
272 gearman_task_free(task);
273 return NULL;
274 }
275 } while (gearman_continue(gearman_task_return(task)));
276
277 return task;275 return task;
278}276}
279277
=== modified file 'libgearman/include.am'
--- libgearman/include.am 2013-07-09 08:48:15 +0000
+++ libgearman/include.am 2013-07-10 10:57:30 +0000
@@ -56,6 +56,7 @@
56 libgearman/log.hpp \56 libgearman/log.hpp \
57 libgearman/packet.hpp \57 libgearman/packet.hpp \
58 libgearman/protocol/echo.h \58 libgearman/protocol/echo.h \
59 libgearman/protocol/option.h \
59 libgearman/protocol/submit.h \60 libgearman/protocol/submit.h \
60 libgearman/protocol/work_exception.h \61 libgearman/protocol/work_exception.h \
61 libgearman/result.hpp \62 libgearman/result.hpp \
@@ -116,6 +117,7 @@
116 libgearman/packet.cc \117 libgearman/packet.cc \
117 libgearman/parse.cc \118 libgearman/parse.cc \
118 libgearman/protocol/echo.cc \119 libgearman/protocol/echo.cc \
120 libgearman/protocol/option.cc \
119 libgearman/protocol/submit.cc \121 libgearman/protocol/submit.cc \
120 libgearman/protocol/work_exception.cc \122 libgearman/protocol/work_exception.cc \
121 libgearman/result.cc \123 libgearman/result.cc \
122124
=== added file 'libgearman/protocol/option.cc'
--- libgearman/protocol/option.cc 1970-01-01 00:00:00 +0000
+++ libgearman/protocol/option.cc 2013-07-10 10:57:30 +0000
@@ -0,0 +1,80 @@
1/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Gearmand client and server library.
4 *
5 * Copyright (C) 2013 Data Differential, http://datadifferential.com/
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38#include "gear_config.h"
39#include <libgearman/common.h>
40#include "libgearman/vector.h"
41
42#include <cstdio>
43#include <cstring>
44
45namespace libgearman {
46namespace protocol {
47
48 gearman_return_t option(gearman_universal_st& universal,
49 gearman_packet_st& message,
50 const gearman_string_t& option_)
51 {
52 if (gearman_c_str(option_) == NULL)
53 {
54 return gearman_error(universal, GEARMAN_INVALID_ARGUMENT, "option was NULL");
55 }
56
57 if (gearman_size(option_) == 0)
58 {
59 return gearman_error(universal, GEARMAN_INVALID_ARGUMENT, "option size was 0");
60 }
61
62 if (gearman_size(option_) > GEARMAN_MAX_OPTION_SIZE)
63 {
64 return gearman_error(universal, GEARMAN_ARGUMENT_TOO_LARGE, "option was greater then GEARMAN_MAX_OPTION_SIZE");
65 }
66
67 const void *args[1];
68 size_t args_size[1];
69
70 args[0]= gearman_c_str(option_);
71 args_size[0]= gearman_size(option_);
72
73 return gearman_packet_create_args(universal, message, GEARMAN_MAGIC_REQUEST,
74 GEARMAN_COMMAND_OPTION_REQ,
75 args, args_size, 1);
76 }
77
78} // namespace protocol
79} // namespace libgearman
80
081
=== added file 'libgearman/protocol/option.h'
--- libgearman/protocol/option.h 1970-01-01 00:00:00 +0000
+++ libgearman/protocol/option.h 2013-07-10 10:57:30 +0000
@@ -0,0 +1,50 @@
1/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Gearmand client and server library.
4 *
5 * Copyright (C) 2013 Data Differential, http://datadifferential.com/
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38#pragma once
39
40
41namespace libgearman {
42namespace protocol {
43
44 gearman_return_t option(gearman_universal_st&,
45 gearman_packet_st&,
46 const gearman_string_t&);
47
48} // namespace protocol
49} // namespace libgearman
50
051
=== modified file 'libgearman/universal.cc'
--- libgearman/universal.cc 2013-07-06 00:33:10 +0000
+++ libgearman/universal.cc 2013-07-10 10:57:30 +0000
@@ -54,6 +54,7 @@
54#include "libgearman/uuid.hpp"54#include "libgearman/uuid.hpp"
5555
56#include "libgearman/protocol/echo.h"56#include "libgearman/protocol/echo.h"
57#include "libgearman/protocol/option.h"
5758
58#include "libgearman/ssl.h"59#include "libgearman/ssl.h"
5960
@@ -583,6 +584,32 @@
583 return ret;584 return ret;
584}585}
585586
587gearman_return_t gearman_server_option(gearman_universal_st& universal, gearman_string_t& option)
588{
589 if (universal.has_connections() == false)
590 {
591 return gearman_universal_set_error(universal, GEARMAN_NO_SERVERS, GEARMAN_AT, "no servers provided");
592 }
593
594 gearman_packet_st message;
595 gearman_return_t ret= libgearman::protocol::option(universal, message, option);
596 if (gearman_success(ret))
597 {
598 PUSH_BLOCKING(universal);
599
600 OptionCheck check(universal, option);
601 ret= connection_loop(universal, message, check);
602 }
603 else
604 {
605 return universal.error_code();
606 }
607
608 gearman_packet_free(&message);
609
610 return ret;
611}
612
586613
587gearman_return_t gearman_echo(gearman_universal_st& universal,614gearman_return_t gearman_echo(gearman_universal_st& universal,
588 const void *workload_str,615 const void *workload_str,
589616
=== modified file 'libgearman/universal.hpp'
--- libgearman/universal.hpp 2013-05-05 04:31:32 +0000
+++ libgearman/universal.hpp 2013-07-10 10:57:30 +0000
@@ -118,3 +118,5 @@
118 size_t id_size);118 size_t id_size);
119119
120const char *gearman_univeral_namespace(gearman_universal_st& universal);120const char *gearman_univeral_namespace(gearman_universal_st& universal);
121
122gearman_return_t gearman_server_option(gearman_universal_st&, gearman_string_t&);
121123
=== modified file 'libgearmancore/include.am'
--- libgearmancore/include.am 2013-06-27 22:57:50 +0000
+++ libgearmancore/include.am 2013-07-10 10:57:30 +0000
@@ -23,6 +23,7 @@
23libgearman_libgearmancore_la_SOURCES+= libgearman/log.cc23libgearman_libgearmancore_la_SOURCES+= libgearman/log.cc
24libgearman_libgearmancore_la_SOURCES+= libgearman/packet.cc24libgearman_libgearmancore_la_SOURCES+= libgearman/packet.cc
25libgearman_libgearmancore_la_SOURCES+= libgearman/protocol/echo.cc25libgearman_libgearmancore_la_SOURCES+= libgearman/protocol/echo.cc
26libgearman_libgearmancore_la_SOURCES+= libgearman/protocol/option.cc
26libgearman_libgearmancore_la_SOURCES+= libgearman/protocol/submit.cc27libgearman_libgearmancore_la_SOURCES+= libgearman/protocol/submit.cc
27libgearman_libgearmancore_la_SOURCES+= libgearman/protocol/work_exception.cc28libgearman_libgearmancore_la_SOURCES+= libgearman/protocol/work_exception.cc
28libgearman_libgearmancore_la_SOURCES+= libgearman/server_options.cc29libgearman_libgearmancore_la_SOURCES+= libgearman/server_options.cc
2930
=== modified file 'libtest/timer.cc'
--- libtest/timer.cc 2013-01-10 12:05:49 +0000
+++ libtest/timer.cc 2013-07-10 10:57:30 +0000
@@ -41,7 +41,7 @@
41#include <ctime>41#include <ctime>
42#include <iomanip>42#include <iomanip>
4343
44#ifdef __MACH__44#ifdef __APPLE__
45# include <mach/clock.h>45# include <mach/clock.h>
46# include <mach/mach.h>46# include <mach/mach.h>
47#else47#else
@@ -110,7 +110,7 @@
110110
111void Timer::_time(struct timespec& ts)111void Timer::_time(struct timespec& ts)
112{112{
113#ifdef __MACH__ // OSX lacks clock_gettime()113#ifdef __APPLE__ // OSX lacks clock_gettime()
114 clock_serv_t _clock_serv;114 clock_serv_t _clock_serv;
115 mach_timespec_t _mach_timespec;115 mach_timespec_t _mach_timespec;
116 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &_clock_serv);116 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &_clock_serv);
117117
=== modified file 'tests/libgearman-1.0/gearman_execute_partition.cc'
--- tests/libgearman-1.0/gearman_execute_partition.cc 2013-07-06 09:37:11 +0000
+++ tests/libgearman-1.0/gearman_execute_partition.cc 2013-07-10 10:57:30 +0000
@@ -130,12 +130,12 @@
130 ASSERT_TRUE(client);130 ASSERT_TRUE(client);
131131
132 ASSERT_EQ(GEARMAN_SUCCESS,132 ASSERT_EQ(GEARMAN_SUCCESS,
133 gearman_client_echo(client, test_literal_param("this is mine")));133 gearman_client_echo(client, test_literal_param("this is mine")));
134134
135 // This just hear to make it easier to trace when135 // This just hear to make it easier to trace when
136 // gearman_execute_partition() is called (look in the log to see the136 // gearman_execute_partition() is called (look in the log to see the
137 // failed option setting.137 // failed option setting.
138 gearman_client_set_server_option(client, test_literal_param("should fail"));138 ASSERT_FALSE(gearman_client_set_server_option(client, test_literal_param("should fail")));
139139
140 // This is the real work140 // This is the real work
141 gearman_argument_t workload= gearman_argument_make(0, 0, test_literal_param("this dog does not hunt"));141 gearman_argument_t workload= gearman_argument_make(0, 0, test_literal_param("this dog does not hunt"));
142142
=== modified file 'tests/libgearman-1.0/include.am'
--- tests/libgearman-1.0/include.am 2013-07-03 03:54:06 +0000
+++ tests/libgearman-1.0/include.am 2013-07-10 10:57:30 +0000
@@ -106,7 +106,7 @@
106helgrind-worker: t/worker gearmand/gearmand106helgrind-worker: t/worker gearmand/gearmand
107 @$(HELGRIND_COMMAND) t/worker107 @$(HELGRIND_COMMAND) t/worker
108108
109gdb-worker: t/libgearman-1.0/worker gearmand/gearmand109gdb-worker: t/worker gearmand/gearmand
110 @$(GDB_COMMAND) t/worker110 @$(GDB_COMMAND) t/worker
111111
112ptrdiff-worker: t/worker gearmand/gearmand112ptrdiff-worker: t/worker gearmand/gearmand
113113
=== modified file 'tests/libgearman-1.0/server_options.cc'
--- tests/libgearman-1.0/server_options.cc 2013-02-03 13:13:26 +0000
+++ tests/libgearman-1.0/server_options.cc 2013-07-10 10:57:30 +0000
@@ -52,7 +52,7 @@
52test_return_t gearman_client_set_server_option_exception(void *object)52test_return_t gearman_client_set_server_option_exception(void *object)
53{53{
54 gearman_client_st *client= (gearman_client_st *)object;54 gearman_client_st *client= (gearman_client_st *)object;
55 test_true(gearman_client_set_server_option(client, test_literal_param("exceptions")));55 ASSERT_TRUE(gearman_client_set_server_option(client, test_literal_param("exceptions")));
56 test_compare(GEARMAN_SUCCESS, gearman_client_echo(client, test_literal_param("echo")));56 test_compare(GEARMAN_SUCCESS, gearman_client_echo(client, test_literal_param("echo")));
57 return TEST_SUCCESS;57 return TEST_SUCCESS;
58}58}
@@ -60,7 +60,7 @@
60test_return_t gearman_client_set_server_option_bad(void *object)60test_return_t gearman_client_set_server_option_bad(void *object)
61{61{
62 gearman_client_st *client= (gearman_client_st *)object;62 gearman_client_st *client= (gearman_client_st *)object;
63 test_true(gearman_client_set_server_option(client, test_literal_param("bad")));63 ASSERT_FALSE(gearman_client_set_server_option(client, test_literal_param("bad")));
64 test_compare(GEARMAN_INVALID_SERVER_OPTION, gearman_client_echo(client, test_literal_param("echo")));64 test_compare(GEARMAN_SUCCESS, gearman_client_echo(client, test_literal_param("echo")));
65 return TEST_SUCCESS;65 return TEST_SUCCESS;
66}66}
6767
=== modified file 'tests/libgearman-1.0/worker_test.cc'
--- tests/libgearman-1.0/worker_test.cc 2013-07-06 20:11:54 +0000
+++ tests/libgearman-1.0/worker_test.cc 2013-07-10 10:57:30 +0000
@@ -945,6 +945,7 @@
945945
946 /* Now take job with one worker. */946 /* Now take job with one worker. */
947 gearman_universal_st universal;947 gearman_universal_st universal;
948 universal.timeout= 3000;
948949
949 gearman_connection_st *connection1;950 gearman_connection_st *connection1;
950 test_truth(connection1= gearman_connection_create(universal, NULL, default_port()));951 test_truth(connection1= gearman_connection_create(universal, NULL, default_port()));

Subscribers

People subscribed via source and target branches

to all changes: