Merge lp:~brianaker/gearmand/clocktime-option-check-fixes into lp:gearmand
- clocktime-option-check-fixes
- Merge into 1.2
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tangent Trunk | Pending | ||
Review via email: mp+173908@code.launchpad.net |
Commit message
Description of the change
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
1 | === modified file 'configure.ac' |
2 | --- configure.ac 2013-07-09 08:48:15 +0000 |
3 | +++ configure.ac 2013-07-10 10:57:30 +0000 |
4 | @@ -205,7 +205,6 @@ |
5 | AC_CHECK_FUNCS([strtoul]) |
6 | AC_CHECK_FUNCS([uname]) |
7 | AC_CHECK_FUNCS([atexit]) |
8 | -AC_CHECK_FUNCS([clock_gettime]) |
9 | AC_CHECK_FUNCS([getcwd]) |
10 | AC_CHECK_FUNCS([strstr]) |
11 | AC_CHECK_FUNC([setsockopt],[],[AC_CHECK_LIB([socket],[setsockopt])]) |
12 | @@ -216,9 +215,15 @@ |
13 | |
14 | # Check for -lrt |
15 | AC_CHECK_LIB([rt],[clock_gettime], |
16 | - [AC_SUBST([RT_LIB],[-lrt]) |
17 | - AC_DEFINE([HAVE_LIBRT],[1],[Have clock_gettime]) |
18 | - ]) |
19 | + [AX_SAVE_FLAGS |
20 | + LIBS="$LIB -lrt" |
21 | + AC_CHECK_FUNCS([clock_gettime]) |
22 | + AX_RESTORE_FLAGS |
23 | + |
24 | + AC_SUBST([RT_LIB],[-lrt]) |
25 | + AC_DEFINE([HAVE_LIBRT],[1],[Have -lrt]) |
26 | + ], |
27 | + [AC_CHECK_FUNCS([clock_gettime])]) |
28 | |
29 | # Check for -lm |
30 | LT_LIB_M |
31 | |
32 | === modified file 'libgearman-1.0/limits.h' |
33 | --- libgearman-1.0/limits.h 2012-05-13 23:19:56 +0000 |
34 | +++ libgearman-1.0/limits.h 2013-07-10 10:57:30 +0000 |
35 | @@ -49,6 +49,7 @@ |
36 | #define GEARMAN_MAXIMUM_INTEGER_DISPLAY_LENGTH 20 |
37 | #define GEARMAN_MAX_COMMAND_ARGS 8 |
38 | #define GEARMAN_MAX_ECHO_SIZE (UINT32_MAX -GEARMAN_ARGS_BUFFER_SIZE) |
39 | +#define GEARMAN_MAX_OPTION_SIZE (UINT32_MAX -GEARMAN_ARGS_BUFFER_SIZE) |
40 | #define GEARMAN_MAX_ERROR_SIZE 2048 |
41 | #define GEARMAN_MAX_IDENTIFIER 254 |
42 | #define GEARMAN_MAX_UNIQUE_SIZE 64 |
43 | |
44 | === modified file 'libgearman-server/gearmand_thread.cc' |
45 | --- libgearman-server/gearmand_thread.cc 2013-07-07 00:16:26 +0000 |
46 | +++ libgearman-server/gearmand_thread.cc 2013-07-10 10:57:30 +0000 |
47 | @@ -60,8 +60,8 @@ |
48 | #if defined(HAVE_PTHREAD_TIMEDJOIN_NP) && HAVE_PTHREAD_TIMEDJOIN_NP |
49 | bool fill_timespec(struct timespec& ts) |
50 | { |
51 | -#if defined(HAVE_LIBRT) && HAVE_LIBRT |
52 | - if (HAVE_LIBRT) // This won't be called on OSX, etc,... |
53 | +#if defined(HAVE_CLOCK_GETTIME) && HAVE_CLOCK_GETTIME |
54 | + if (HAVE_CLOCK_GETTIME) // This won't be called on OSX, etc,... |
55 | { |
56 | if (clock_gettime(CLOCK_REALTIME, &ts) == -1) |
57 | { |
58 | |
59 | === modified file 'libgearman-server/plugins/protocol/gear/protocol.cc' |
60 | --- libgearman-server/plugins/protocol/gear/protocol.cc 2013-07-07 00:23:12 +0000 |
61 | +++ libgearman-server/plugins/protocol/gear/protocol.cc 2013-07-10 10:57:30 +0000 |
62 | @@ -254,8 +254,8 @@ |
63 | "GEAR length: %" PRIu64 " gearmand_command_t: %s option: %.*s", |
64 | uint64_t(packet->data_size), |
65 | gearman_strcommand(packet->command), |
66 | - int(packet->data_size), |
67 | - packet->data); |
68 | + int(packet->arg_size[0]), |
69 | + packet->arg[0]); |
70 | } |
71 | else |
72 | { |
73 | @@ -277,12 +277,21 @@ |
74 | if (packet->command == GEARMAN_COMMAND_ECHO_RES) |
75 | { |
76 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, |
77 | - "GEAR length: %" PRIu64 " gearmand_command_t: %s echo: %.*", |
78 | + "GEAR length: %" PRIu64 " gearmand_command_t: %s echo: %.*s", |
79 | uint64_t(packet->data_size), |
80 | gearman_strcommand(packet->command), |
81 | int(packet->data_size), |
82 | packet->data); |
83 | } |
84 | + else if (packet->command == GEARMAN_COMMAND_OPTION_RES) |
85 | + { |
86 | + gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, |
87 | + "GEAR length: %" PRIu64 " gearmand_command_t: %s option: %.*s", |
88 | + uint64_t(packet->data_size), |
89 | + gearman_strcommand(packet->command), |
90 | + int(packet->arg_size[0]), |
91 | + packet->arg[0]); |
92 | + } |
93 | else |
94 | { |
95 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, |
96 | |
97 | === modified file 'libgearman-server/server.cc' |
98 | --- libgearman-server/server.cc 2013-07-05 22:06:45 +0000 |
99 | +++ libgearman-server/server.cc 2013-07-10 10:57:30 +0000 |
100 | @@ -72,11 +72,13 @@ |
101 | * Queue an error packet. |
102 | */ |
103 | static gearmand_error_t _server_error_packet(gearman_server_con_st *server_con, |
104 | - gearman_return_t error_code, const char *error_string) |
105 | + gearman_return_t client_return_code, const char *error_string) |
106 | { |
107 | - const char* error_code_string= gearman_strerror(error_code); |
108 | + const char* error_code_string= gearman_strerror(client_return_code); |
109 | error_code_string+= 8; |
110 | |
111 | + gearmand_log_error(GEARMAN_DEFAULT_LOG_PARAM, "%s:%s", gearman_strerror(client_return_code), error_string); |
112 | + |
113 | return gearman_server_io_packet_add(server_con, false, GEARMAN_MAGIC_RESPONSE, |
114 | GEARMAN_COMMAND_ERROR, error_code_string, |
115 | (size_t)(strlen(error_code_string) + 1), |
116 | @@ -818,7 +820,7 @@ |
117 | server_job->function->function_name_size, server_job->function->function_name, server_job->function->function_name_size); |
118 | if (server_job == NULL) |
119 | { |
120 | - return _server_error_packet(server_con, GEARMAN_NO_JOBS, "Job given in work result not found"); |
121 | + return _server_error_packet(server_con, GEARMAN_NO_JOBS, "An exception was received for a job that does not exist"); |
122 | } |
123 | |
124 | /* Queue the exception packet for all clients. */ |
125 | |
126 | === modified file 'libgearman/check.cc' |
127 | --- libgearman/check.cc 2013-07-08 09:58:12 +0000 |
128 | +++ libgearman/check.cc 2013-07-10 10:57:30 +0000 |
129 | @@ -93,19 +93,21 @@ |
130 | if (con->_packet.argc) |
131 | { |
132 | gearman_return_t maybe_server_error= string2return_code(static_cast<char *>(con->_packet.arg[0]), int(con->_packet.arg_size[0])); |
133 | - |
134 | if (maybe_server_error == GEARMAN_MAX_RETURN) |
135 | { |
136 | maybe_server_error= GEARMAN_SERVER_ERROR; |
137 | } |
138 | |
139 | - return gearman_universal_set_error(_universal, maybe_server_error, GEARMAN_AT, "%.*s:%.*s", |
140 | + return gearman_universal_set_error(_universal, maybe_server_error, GEARMAN_AT, "%s:%s %.*s:%.*s", |
141 | + con->host(), con->service(), |
142 | con->_packet.arg_size[0], con->_packet.arg[0], |
143 | con->_packet.arg_size[1], con->_packet.arg[1] |
144 | ); |
145 | } |
146 | |
147 | - return gearman_error(_universal, GEARMAN_SERVER_ERROR, "server lacks support for client's to cancel a job"); |
148 | + return gearman_universal_set_error(_universal, GEARMAN_SERVER_ERROR, GEARMAN_AT, "%s:%s lacks support for client's to cancel a job", |
149 | + con->host(), con->service() |
150 | + ); |
151 | } |
152 | |
153 | return GEARMAN_SUCCESS; |
154 | @@ -118,20 +120,24 @@ |
155 | if (con->_packet.argc) |
156 | { |
157 | gearman_return_t maybe_server_error= string2return_code(static_cast<char *>(con->_packet.arg[0]), int(con->_packet.arg_size[0])); |
158 | - |
159 | if (maybe_server_error == GEARMAN_MAX_RETURN) |
160 | { |
161 | maybe_server_error= GEARMAN_INVALID_SERVER_OPTION; |
162 | } |
163 | |
164 | - return gearman_universal_set_error(_universal, maybe_server_error, GEARMAN_AT, "%d: %.*s:%.*s", con->_packet.argc, |
165 | - con->_packet.arg_size[0], con->_packet.arg[0], |
166 | - con->_packet.arg_size[1], con->_packet.arg[1] |
167 | + return gearman_universal_set_error(_universal, maybe_server_error, GEARMAN_AT, "%s:%s Invalid option %.*s", |
168 | + con->host(), con->service(), |
169 | + con->_packet.arg_size[0], con->_packet.arg[0] |
170 | ); |
171 | } |
172 | |
173 | - return gearman_error(_universal, GEARMAN_INVALID_SERVER_OPTION, "invalid server option"); |
174 | + return gearman_universal_set_error(_universal, GEARMAN_INVALID_SERVER_OPTION, GEARMAN_AT, "%s:%s Invalid option %.*s", |
175 | + con->host(), con->service(), |
176 | + con->_packet.arg_size[0], con->_packet.arg[0] |
177 | + ); |
178 | } |
179 | |
180 | + // @todo mark option set for connection |
181 | + |
182 | return GEARMAN_SUCCESS; |
183 | } |
184 | |
185 | === modified file 'libgearman/check.h' |
186 | --- libgearman/check.h 2013-04-16 10:05:29 +0000 |
187 | +++ libgearman/check.h 2013-07-10 10:57:30 +0000 |
188 | @@ -59,15 +59,17 @@ |
189 | |
190 | class OptionCheck : public Check { |
191 | public: |
192 | - OptionCheck(gearman_universal_st& universal_): |
193 | - _universal(universal_) |
194 | - { |
195 | - } |
196 | + OptionCheck(gearman_universal_st& universal_, gearman_string_t& option_): |
197 | + _universal(universal_), |
198 | + _option(option_) |
199 | + { |
200 | + } |
201 | |
202 | gearman_return_t success(gearman_connection_st* con); |
203 | |
204 | private: |
205 | - gearman_universal_st& _universal; |
206 | + gearman_universal_st& _universal; |
207 | + gearman_string_t& _option; |
208 | }; |
209 | |
210 | class CancelCheck : public Check { |
211 | |
212 | === modified file 'libgearman/client.cc' |
213 | --- libgearman/client.cc 2013-07-08 11:33:16 +0000 |
214 | +++ libgearman/client.cc 2013-07-10 10:57:30 +0000 |
215 | @@ -1806,15 +1806,20 @@ |
216 | { |
217 | if (client_shell and client_shell->impl()) |
218 | { |
219 | + Client* client= client_shell->impl(); |
220 | gearman_string_t option= { option_arg, option_arg_size }; |
221 | - if (gearman_request_option(client_shell->impl()->universal, option)) |
222 | + |
223 | + if (gearman_success(gearman_server_option(client->universal, option))) |
224 | { |
225 | - if (strcmp("exceptions", option_arg) == 0) |
226 | + if (gearman_request_option(client->universal, option)) |
227 | { |
228 | - client_shell->impl()->options.exceptions= true; |
229 | + if (strncmp("exceptions", option_arg, sizeof("exceptions")) == 0) |
230 | + { |
231 | + client->options.exceptions= true; |
232 | + } |
233 | + |
234 | + return true; |
235 | } |
236 | - |
237 | - return true; |
238 | } |
239 | } |
240 | |
241 | |
242 | === modified file 'libgearman/connection.cc' |
243 | --- libgearman/connection.cc 2013-07-08 09:58:12 +0000 |
244 | +++ libgearman/connection.cc 2013-07-10 10:57:30 +0000 |
245 | @@ -49,6 +49,8 @@ |
246 | #include "libgearman/interface/push.hpp" |
247 | #include "libgearman/log.hpp" |
248 | |
249 | +#include "libgearman/protocol/option.h" |
250 | + |
251 | #include <cerrno> |
252 | #include <cstdio> |
253 | #include <cstdlib> |
254 | @@ -425,11 +427,8 @@ |
255 | head= head->next) |
256 | { |
257 | gearman_packet_st message; |
258 | - const void *args[]= { (const void*)head->value() }; |
259 | - size_t args_size[]= { head->size() }; |
260 | - gearman_return_t ret= gearman_packet_create_args(universal, message, GEARMAN_MAGIC_REQUEST, |
261 | - GEARMAN_COMMAND_OPTION_REQ, args, args_size, 1); |
262 | - |
263 | + gearman_string_t option= { (const char*)head->value(), head->size() }; |
264 | + gearman_return_t ret= libgearman::protocol::option(universal, message, option); |
265 | if (gearman_failed(ret)) |
266 | { |
267 | assert(universal.error_code()); |
268 | @@ -439,7 +438,7 @@ |
269 | } |
270 | |
271 | PUSH_BLOCKING(universal); |
272 | - OptionCheck check(universal); |
273 | + OptionCheck check(universal, option); |
274 | ret= _send_packet(message, true); |
275 | if (gearman_failed(ret)) |
276 | { |
277 | |
278 | === modified file 'libgearman/execute.cc' |
279 | --- libgearman/execute.cc 2013-07-07 00:13:00 +0000 |
280 | +++ libgearman/execute.cc 2013-07-10 10:57:30 +0000 |
281 | @@ -259,20 +259,18 @@ |
282 | NULL); |
283 | } |
284 | |
285 | - if (task == NULL) |
286 | + if (task) |
287 | { |
288 | - return NULL; |
289 | + do { |
290 | + gearman_return_t rc; |
291 | + if (gearman_failed(rc= gearman_client_run_tasks(client->shell()))) |
292 | + { |
293 | + gearman_gerror(client->universal, rc); |
294 | + gearman_task_free(task); |
295 | + return NULL; |
296 | + } |
297 | + } while (gearman_continue(gearman_task_return(task))); |
298 | } |
299 | |
300 | - do { |
301 | - gearman_return_t rc; |
302 | - if (gearman_failed(rc= gearman_client_run_tasks(client->shell()))) |
303 | - { |
304 | - gearman_gerror(client->universal, rc); |
305 | - gearman_task_free(task); |
306 | - return NULL; |
307 | - } |
308 | - } while (gearman_continue(gearman_task_return(task))); |
309 | - |
310 | return task; |
311 | } |
312 | |
313 | === modified file 'libgearman/include.am' |
314 | --- libgearman/include.am 2013-07-09 08:48:15 +0000 |
315 | +++ libgearman/include.am 2013-07-10 10:57:30 +0000 |
316 | @@ -56,6 +56,7 @@ |
317 | libgearman/log.hpp \ |
318 | libgearman/packet.hpp \ |
319 | libgearman/protocol/echo.h \ |
320 | + libgearman/protocol/option.h \ |
321 | libgearman/protocol/submit.h \ |
322 | libgearman/protocol/work_exception.h \ |
323 | libgearman/result.hpp \ |
324 | @@ -116,6 +117,7 @@ |
325 | libgearman/packet.cc \ |
326 | libgearman/parse.cc \ |
327 | libgearman/protocol/echo.cc \ |
328 | + libgearman/protocol/option.cc \ |
329 | libgearman/protocol/submit.cc \ |
330 | libgearman/protocol/work_exception.cc \ |
331 | libgearman/result.cc \ |
332 | |
333 | === added file 'libgearman/protocol/option.cc' |
334 | --- libgearman/protocol/option.cc 1970-01-01 00:00:00 +0000 |
335 | +++ libgearman/protocol/option.cc 2013-07-10 10:57:30 +0000 |
336 | @@ -0,0 +1,80 @@ |
337 | +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
338 | + * |
339 | + * Gearmand client and server library. |
340 | + * |
341 | + * Copyright (C) 2013 Data Differential, http://datadifferential.com/ |
342 | + * All rights reserved. |
343 | + * |
344 | + * Redistribution and use in source and binary forms, with or without |
345 | + * modification, are permitted provided that the following conditions are |
346 | + * met: |
347 | + * |
348 | + * * Redistributions of source code must retain the above copyright |
349 | + * notice, this list of conditions and the following disclaimer. |
350 | + * |
351 | + * * Redistributions in binary form must reproduce the above |
352 | + * copyright notice, this list of conditions and the following disclaimer |
353 | + * in the documentation and/or other materials provided with the |
354 | + * distribution. |
355 | + * |
356 | + * * The names of its contributors may not be used to endorse or |
357 | + * promote products derived from this software without specific prior |
358 | + * written permission. |
359 | + * |
360 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
361 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
362 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
363 | + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
364 | + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
365 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
366 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
367 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
368 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
369 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
370 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
371 | + * |
372 | + */ |
373 | + |
374 | +#include "gear_config.h" |
375 | +#include <libgearman/common.h> |
376 | +#include "libgearman/vector.h" |
377 | + |
378 | +#include <cstdio> |
379 | +#include <cstring> |
380 | + |
381 | +namespace libgearman { |
382 | +namespace protocol { |
383 | + |
384 | + gearman_return_t option(gearman_universal_st& universal, |
385 | + gearman_packet_st& message, |
386 | + const gearman_string_t& option_) |
387 | + { |
388 | + if (gearman_c_str(option_) == NULL) |
389 | + { |
390 | + return gearman_error(universal, GEARMAN_INVALID_ARGUMENT, "option was NULL"); |
391 | + } |
392 | + |
393 | + if (gearman_size(option_) == 0) |
394 | + { |
395 | + return gearman_error(universal, GEARMAN_INVALID_ARGUMENT, "option size was 0"); |
396 | + } |
397 | + |
398 | + if (gearman_size(option_) > GEARMAN_MAX_OPTION_SIZE) |
399 | + { |
400 | + return gearman_error(universal, GEARMAN_ARGUMENT_TOO_LARGE, "option was greater then GEARMAN_MAX_OPTION_SIZE"); |
401 | + } |
402 | + |
403 | + const void *args[1]; |
404 | + size_t args_size[1]; |
405 | + |
406 | + args[0]= gearman_c_str(option_); |
407 | + args_size[0]= gearman_size(option_); |
408 | + |
409 | + return gearman_packet_create_args(universal, message, GEARMAN_MAGIC_REQUEST, |
410 | + GEARMAN_COMMAND_OPTION_REQ, |
411 | + args, args_size, 1); |
412 | + } |
413 | + |
414 | +} // namespace protocol |
415 | +} // namespace libgearman |
416 | + |
417 | |
418 | === added file 'libgearman/protocol/option.h' |
419 | --- libgearman/protocol/option.h 1970-01-01 00:00:00 +0000 |
420 | +++ libgearman/protocol/option.h 2013-07-10 10:57:30 +0000 |
421 | @@ -0,0 +1,50 @@ |
422 | +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
423 | + * |
424 | + * Gearmand client and server library. |
425 | + * |
426 | + * Copyright (C) 2013 Data Differential, http://datadifferential.com/ |
427 | + * All rights reserved. |
428 | + * |
429 | + * Redistribution and use in source and binary forms, with or without |
430 | + * modification, are permitted provided that the following conditions are |
431 | + * met: |
432 | + * |
433 | + * * Redistributions of source code must retain the above copyright |
434 | + * notice, this list of conditions and the following disclaimer. |
435 | + * |
436 | + * * Redistributions in binary form must reproduce the above |
437 | + * copyright notice, this list of conditions and the following disclaimer |
438 | + * in the documentation and/or other materials provided with the |
439 | + * distribution. |
440 | + * |
441 | + * * The names of its contributors may not be used to endorse or |
442 | + * promote products derived from this software without specific prior |
443 | + * written permission. |
444 | + * |
445 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
446 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
447 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
448 | + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
449 | + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
450 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
451 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
452 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
453 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
454 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
455 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
456 | + * |
457 | + */ |
458 | + |
459 | +#pragma once |
460 | + |
461 | + |
462 | +namespace libgearman { |
463 | +namespace protocol { |
464 | + |
465 | + gearman_return_t option(gearman_universal_st&, |
466 | + gearman_packet_st&, |
467 | + const gearman_string_t&); |
468 | + |
469 | +} // namespace protocol |
470 | +} // namespace libgearman |
471 | + |
472 | |
473 | === modified file 'libgearman/universal.cc' |
474 | --- libgearman/universal.cc 2013-07-06 00:33:10 +0000 |
475 | +++ libgearman/universal.cc 2013-07-10 10:57:30 +0000 |
476 | @@ -54,6 +54,7 @@ |
477 | #include "libgearman/uuid.hpp" |
478 | |
479 | #include "libgearman/protocol/echo.h" |
480 | +#include "libgearman/protocol/option.h" |
481 | |
482 | #include "libgearman/ssl.h" |
483 | |
484 | @@ -583,6 +584,32 @@ |
485 | return ret; |
486 | } |
487 | |
488 | +gearman_return_t gearman_server_option(gearman_universal_st& universal, gearman_string_t& option) |
489 | +{ |
490 | + if (universal.has_connections() == false) |
491 | + { |
492 | + return gearman_universal_set_error(universal, GEARMAN_NO_SERVERS, GEARMAN_AT, "no servers provided"); |
493 | + } |
494 | + |
495 | + gearman_packet_st message; |
496 | + gearman_return_t ret= libgearman::protocol::option(universal, message, option); |
497 | + if (gearman_success(ret)) |
498 | + { |
499 | + PUSH_BLOCKING(universal); |
500 | + |
501 | + OptionCheck check(universal, option); |
502 | + ret= connection_loop(universal, message, check); |
503 | + } |
504 | + else |
505 | + { |
506 | + return universal.error_code(); |
507 | + } |
508 | + |
509 | + gearman_packet_free(&message); |
510 | + |
511 | + return ret; |
512 | +} |
513 | + |
514 | |
515 | gearman_return_t gearman_echo(gearman_universal_st& universal, |
516 | const void *workload_str, |
517 | |
518 | === modified file 'libgearman/universal.hpp' |
519 | --- libgearman/universal.hpp 2013-05-05 04:31:32 +0000 |
520 | +++ libgearman/universal.hpp 2013-07-10 10:57:30 +0000 |
521 | @@ -118,3 +118,5 @@ |
522 | size_t id_size); |
523 | |
524 | const char *gearman_univeral_namespace(gearman_universal_st& universal); |
525 | + |
526 | +gearman_return_t gearman_server_option(gearman_universal_st&, gearman_string_t&); |
527 | |
528 | === modified file 'libgearmancore/include.am' |
529 | --- libgearmancore/include.am 2013-06-27 22:57:50 +0000 |
530 | +++ libgearmancore/include.am 2013-07-10 10:57:30 +0000 |
531 | @@ -23,6 +23,7 @@ |
532 | libgearman_libgearmancore_la_SOURCES+= libgearman/log.cc |
533 | libgearman_libgearmancore_la_SOURCES+= libgearman/packet.cc |
534 | libgearman_libgearmancore_la_SOURCES+= libgearman/protocol/echo.cc |
535 | +libgearman_libgearmancore_la_SOURCES+= libgearman/protocol/option.cc |
536 | libgearman_libgearmancore_la_SOURCES+= libgearman/protocol/submit.cc |
537 | libgearman_libgearmancore_la_SOURCES+= libgearman/protocol/work_exception.cc |
538 | libgearman_libgearmancore_la_SOURCES+= libgearman/server_options.cc |
539 | |
540 | === modified file 'libtest/timer.cc' |
541 | --- libtest/timer.cc 2013-01-10 12:05:49 +0000 |
542 | +++ libtest/timer.cc 2013-07-10 10:57:30 +0000 |
543 | @@ -41,7 +41,7 @@ |
544 | #include <ctime> |
545 | #include <iomanip> |
546 | |
547 | -#ifdef __MACH__ |
548 | +#ifdef __APPLE__ |
549 | # include <mach/clock.h> |
550 | # include <mach/mach.h> |
551 | #else |
552 | @@ -110,7 +110,7 @@ |
553 | |
554 | void Timer::_time(struct timespec& ts) |
555 | { |
556 | -#ifdef __MACH__ // OSX lacks clock_gettime() |
557 | +#ifdef __APPLE__ // OSX lacks clock_gettime() |
558 | clock_serv_t _clock_serv; |
559 | mach_timespec_t _mach_timespec; |
560 | host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &_clock_serv); |
561 | |
562 | === modified file 'tests/libgearman-1.0/gearman_execute_partition.cc' |
563 | --- tests/libgearman-1.0/gearman_execute_partition.cc 2013-07-06 09:37:11 +0000 |
564 | +++ tests/libgearman-1.0/gearman_execute_partition.cc 2013-07-10 10:57:30 +0000 |
565 | @@ -130,12 +130,12 @@ |
566 | ASSERT_TRUE(client); |
567 | |
568 | ASSERT_EQ(GEARMAN_SUCCESS, |
569 | - gearman_client_echo(client, test_literal_param("this is mine"))); |
570 | + gearman_client_echo(client, test_literal_param("this is mine"))); |
571 | |
572 | // This just hear to make it easier to trace when |
573 | // gearman_execute_partition() is called (look in the log to see the |
574 | // failed option setting. |
575 | - gearman_client_set_server_option(client, test_literal_param("should fail")); |
576 | + ASSERT_FALSE(gearman_client_set_server_option(client, test_literal_param("should fail"))); |
577 | |
578 | // This is the real work |
579 | gearman_argument_t workload= gearman_argument_make(0, 0, test_literal_param("this dog does not hunt")); |
580 | |
581 | === modified file 'tests/libgearman-1.0/include.am' |
582 | --- tests/libgearman-1.0/include.am 2013-07-03 03:54:06 +0000 |
583 | +++ tests/libgearman-1.0/include.am 2013-07-10 10:57:30 +0000 |
584 | @@ -106,7 +106,7 @@ |
585 | helgrind-worker: t/worker gearmand/gearmand |
586 | @$(HELGRIND_COMMAND) t/worker |
587 | |
588 | -gdb-worker: t/libgearman-1.0/worker gearmand/gearmand |
589 | +gdb-worker: t/worker gearmand/gearmand |
590 | @$(GDB_COMMAND) t/worker |
591 | |
592 | ptrdiff-worker: t/worker gearmand/gearmand |
593 | |
594 | === modified file 'tests/libgearman-1.0/server_options.cc' |
595 | --- tests/libgearman-1.0/server_options.cc 2013-02-03 13:13:26 +0000 |
596 | +++ tests/libgearman-1.0/server_options.cc 2013-07-10 10:57:30 +0000 |
597 | @@ -52,7 +52,7 @@ |
598 | test_return_t gearman_client_set_server_option_exception(void *object) |
599 | { |
600 | gearman_client_st *client= (gearman_client_st *)object; |
601 | - test_true(gearman_client_set_server_option(client, test_literal_param("exceptions"))); |
602 | + ASSERT_TRUE(gearman_client_set_server_option(client, test_literal_param("exceptions"))); |
603 | test_compare(GEARMAN_SUCCESS, gearman_client_echo(client, test_literal_param("echo"))); |
604 | return TEST_SUCCESS; |
605 | } |
606 | @@ -60,7 +60,7 @@ |
607 | test_return_t gearman_client_set_server_option_bad(void *object) |
608 | { |
609 | gearman_client_st *client= (gearman_client_st *)object; |
610 | - test_true(gearman_client_set_server_option(client, test_literal_param("bad"))); |
611 | - test_compare(GEARMAN_INVALID_SERVER_OPTION, gearman_client_echo(client, test_literal_param("echo"))); |
612 | + ASSERT_FALSE(gearman_client_set_server_option(client, test_literal_param("bad"))); |
613 | + test_compare(GEARMAN_SUCCESS, gearman_client_echo(client, test_literal_param("echo"))); |
614 | return TEST_SUCCESS; |
615 | } |
616 | |
617 | === modified file 'tests/libgearman-1.0/worker_test.cc' |
618 | --- tests/libgearman-1.0/worker_test.cc 2013-07-06 20:11:54 +0000 |
619 | +++ tests/libgearman-1.0/worker_test.cc 2013-07-10 10:57:30 +0000 |
620 | @@ -945,6 +945,7 @@ |
621 | |
622 | /* Now take job with one worker. */ |
623 | gearman_universal_st universal; |
624 | + universal.timeout= 3000; |
625 | |
626 | gearman_connection_st *connection1; |
627 | test_truth(connection1= gearman_connection_create(universal, NULL, default_port())); |