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