Merge lp:~brianaker/gearmand/ssl-wait into lp:gearmand
- ssl-wait
- Merge into 1.2
Proposed by
Brian Aker
Status: | Merged |
---|---|
Merged at revision: | 810 |
Proposed branch: | lp:~brianaker/gearmand/ssl-wait |
Merge into: | lp:gearmand |
Diff against target: |
429 lines (+128/-54) (has conflicts) 6 files modified
libgearman-server/plugins/protocol/gear/protocol.cc (+9/-0) libgearman-server/thread.cc (+1/-1) libgearman/connection.cc (+8/-3) libgearman/interface/task.hpp (+5/-0) libgearman/run.cc (+22/-14) tests/libgearman-1.0/worker_test.cc (+83/-36) Text conflict in libgearman/connection.cc |
To merge this branch: | bzr merge lp:~brianaker/gearmand/ssl-wait |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tangent Trunk | Pending | ||
Review via email: mp+173302@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 'libgearman-server/plugins/protocol/gear/protocol.cc' | |||
2 | --- libgearman-server/plugins/protocol/gear/protocol.cc 2013-07-06 00:33:10 +0000 | |||
3 | +++ libgearman-server/plugins/protocol/gear/protocol.cc 2013-07-06 09:21:25 +0000 | |||
4 | @@ -248,6 +248,15 @@ | |||
5 | 248 | int(packet->data_size), | 248 | int(packet->data_size), |
6 | 249 | packet->data); | 249 | packet->data); |
7 | 250 | } | 250 | } |
8 | 251 | else if (packet->command == GEARMAN_COMMAND_OPTION_REQ) | ||
9 | 252 | { | ||
10 | 253 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, | ||
11 | 254 | "GEAR length: %" PRIu64 " gearmand_command_t: %s option: %.*s", | ||
12 | 255 | uint64_t(packet->data_size), | ||
13 | 256 | gearman_strcommand(packet->command), | ||
14 | 257 | int(packet->data_size), | ||
15 | 258 | packet->data); | ||
16 | 259 | } | ||
17 | 251 | else | 260 | else |
18 | 252 | { | 261 | { |
19 | 253 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, | 262 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, |
20 | 254 | 263 | ||
21 | === modified file 'libgearman-server/thread.cc' | |||
22 | --- libgearman-server/thread.cc 2013-05-05 03:23:55 +0000 | |||
23 | +++ libgearman-server/thread.cc 2013-07-06 09:21:25 +0000 | |||
24 | @@ -309,7 +309,7 @@ | |||
25 | 309 | 309 | ||
26 | 310 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, | 310 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, |
27 | 311 | "Received %s %s:%u", | 311 | "Received %s %s:%u", |
29 | 312 | gearman_command_info(con->packet->packet.command)->name, | 312 | gearmand_strcommand(&con->packet->packet), |
30 | 313 | con->_host == NULL ? "-" : con->_host, | 313 | con->_host == NULL ? "-" : con->_host, |
31 | 314 | con->_port == NULL ? "-" : con->_port); | 314 | con->_port == NULL ? "-" : con->_port); |
32 | 315 | 315 | ||
33 | 316 | 316 | ||
34 | === modified file 'libgearman/connection.cc' | |||
35 | --- libgearman/connection.cc 2013-07-06 00:33:10 +0000 | |||
36 | +++ libgearman/connection.cc 2013-07-06 09:21:25 +0000 | |||
37 | @@ -75,8 +75,8 @@ | |||
38 | 75 | # define FD_CLOEXEC 0 | 75 | # define FD_CLOEXEC 0 |
39 | 76 | #endif | 76 | #endif |
40 | 77 | 77 | ||
43 | 78 | #ifndef MSG_DONTWAIT | 78 | #ifndef MSG_NOSIGNAL |
44 | 79 | # define MSG_DONTWAIT 0 | 79 | # define MSG_NOSIGNAL 0 |
45 | 80 | #endif | 80 | #endif |
46 | 81 | 81 | ||
47 | 82 | 82 | ||
48 | @@ -1105,8 +1105,13 @@ | |||
49 | 1105 | #if defined(HAVE_CYASSL) && HAVE_CYASSL | 1105 | #if defined(HAVE_CYASSL) && HAVE_CYASSL |
50 | 1106 | if (_ssl) | 1106 | if (_ssl) |
51 | 1107 | { | 1107 | { |
52 | 1108 | <<<<<<< TREE | ||
53 | 1108 | read_size= CyaSSL_recv(_ssl, data, data_size, MSG_DONTWAIT); | 1109 | read_size= CyaSSL_recv(_ssl, data, data_size, MSG_DONTWAIT); |
54 | 1109 | if (read_size <= 0) | 1110 | if (read_size <= 0) |
55 | 1111 | ======= | ||
56 | 1112 | read_size= CyaSSL_recv(_ssl, data, data_size, MSG_NOSIGNAL); | ||
57 | 1113 | if (read_size < 0) | ||
58 | 1114 | >>>>>>> MERGE-SOURCE | ||
59 | 1110 | { | 1115 | { |
60 | 1111 | int sendErr= CyaSSL_get_error(_ssl, read_size); | 1116 | int sendErr= CyaSSL_get_error(_ssl, read_size); |
61 | 1112 | if (sendErr != SSL_ERROR_WANT_READ) | 1117 | if (sendErr != SSL_ERROR_WANT_READ) |
62 | @@ -1226,7 +1231,7 @@ | |||
63 | 1226 | int rval; | 1231 | int rval; |
64 | 1227 | do | 1232 | do |
65 | 1228 | { | 1233 | { |
67 | 1229 | rval= fcntl (fd, F_SETFD, flags | FD_CLOEXEC); | 1234 | rval= fcntl(fd, F_SETFD, flags | FD_CLOEXEC); |
68 | 1230 | } while (rval == -1 && (errno == EINTR or errno == EAGAIN)); | 1235 | } while (rval == -1 && (errno == EINTR or errno == EAGAIN)); |
69 | 1231 | 1236 | ||
70 | 1232 | if (rval == -1) | 1237 | if (rval == -1) |
71 | 1233 | 1238 | ||
72 | === modified file 'libgearman/interface/task.hpp' | |||
73 | --- libgearman/interface/task.hpp 2013-05-07 09:45:37 +0000 | |||
74 | +++ libgearman/interface/task.hpp 2013-07-06 09:21:25 +0000 | |||
75 | @@ -154,6 +154,11 @@ | |||
76 | 154 | 154 | ||
77 | 155 | bool create_result(size_t initial_size); | 155 | bool create_result(size_t initial_size); |
78 | 156 | 156 | ||
79 | 157 | void set_state(const enum gearman_task_state_t state_) | ||
80 | 158 | { | ||
81 | 159 | state= state_; | ||
82 | 160 | } | ||
83 | 161 | |||
84 | 157 | private: | 162 | private: |
85 | 158 | gearman_task_st* _shell; | 163 | gearman_task_st* _shell; |
86 | 159 | gearman_task_st _owned_shell; | 164 | gearman_task_st _owned_shell; |
87 | 160 | 165 | ||
88 | === modified file 'libgearman/run.cc' | |||
89 | --- libgearman/run.cc 2013-06-27 02:11:30 +0000 | |||
90 | +++ libgearman/run.cc 2013-07-06 09:21:25 +0000 | |||
91 | @@ -103,7 +103,7 @@ | |||
92 | 103 | } | 103 | } |
93 | 104 | else if (ret == GEARMAN_IO_WAIT) | 104 | else if (ret == GEARMAN_IO_WAIT) |
94 | 105 | { | 105 | { |
96 | 106 | task->state= GEARMAN_TASK_STATE_SUBMIT; | 106 | task->set_state(GEARMAN_TASK_STATE_SUBMIT); |
97 | 107 | return ret; | 107 | return ret; |
98 | 108 | } | 108 | } |
99 | 109 | else if (gearman_failed(ret)) | 109 | else if (gearman_failed(ret)) |
100 | @@ -134,12 +134,12 @@ | |||
101 | 134 | 134 | ||
102 | 135 | if (ret == GEARMAN_COULD_NOT_CONNECT) // If no connection is found, we will let the user try again | 135 | if (ret == GEARMAN_COULD_NOT_CONNECT) // If no connection is found, we will let the user try again |
103 | 136 | { | 136 | { |
105 | 137 | task->state= GEARMAN_TASK_STATE_NEW; | 137 | task->set_state(GEARMAN_TASK_STATE_NEW); |
106 | 138 | task->client->impl()->new_tasks++; | 138 | task->client->impl()->new_tasks++; |
107 | 139 | } | 139 | } |
108 | 140 | else | 140 | else |
109 | 141 | { | 141 | { |
111 | 142 | task->state= GEARMAN_TASK_STATE_FAIL; | 142 | task->set_state(GEARMAN_TASK_STATE_FAIL); |
112 | 143 | task->client->impl()->running_tasks--; | 143 | task->client->impl()->running_tasks--; |
113 | 144 | } | 144 | } |
114 | 145 | return ret; | 145 | return ret; |
115 | @@ -166,13 +166,13 @@ | |||
116 | 166 | gearman_return_t ret= task->func.workload_fn(task->shell()); | 166 | gearman_return_t ret= task->func.workload_fn(task->shell()); |
117 | 167 | if (gearman_failed(ret)) | 167 | if (gearman_failed(ret)) |
118 | 168 | { | 168 | { |
120 | 169 | task->state= GEARMAN_TASK_STATE_WORKLOAD; | 169 | task->set_state(GEARMAN_TASK_STATE_WORKLOAD); |
121 | 170 | return ret; | 170 | return ret; |
122 | 171 | } | 171 | } |
123 | 172 | } | 172 | } |
124 | 173 | 173 | ||
125 | 174 | task->client->impl()->options.no_new= false; | 174 | task->client->impl()->options.no_new= false; |
127 | 175 | task->state= GEARMAN_TASK_STATE_WORK; | 175 | task->set_state(GEARMAN_TASK_STATE_WORK); |
128 | 176 | task->con->set_events(POLLIN); | 176 | task->con->set_events(POLLIN); |
129 | 177 | return GEARMAN_SUCCESS; | 177 | return GEARMAN_SUCCESS; |
130 | 178 | 178 | ||
131 | @@ -190,7 +190,7 @@ | |||
132 | 190 | gearman_return_t ret= task->func.created_fn(task->shell()); | 190 | gearman_return_t ret= task->func.created_fn(task->shell()); |
133 | 191 | if (gearman_failed(ret)) | 191 | if (gearman_failed(ret)) |
134 | 192 | { | 192 | { |
136 | 193 | task->state= GEARMAN_TASK_STATE_CREATED; | 193 | task->set_state(GEARMAN_TASK_STATE_CREATED); |
137 | 194 | return ret; | 194 | return ret; |
138 | 195 | } | 195 | } |
139 | 196 | } | 196 | } |
140 | @@ -201,6 +201,7 @@ | |||
141 | 201 | task->send.command == GEARMAN_COMMAND_SUBMIT_JOB_EPOCH || | 201 | task->send.command == GEARMAN_COMMAND_SUBMIT_JOB_EPOCH || |
142 | 202 | task->send.command == GEARMAN_COMMAND_SUBMIT_REDUCE_JOB_BACKGROUND) | 202 | task->send.command == GEARMAN_COMMAND_SUBMIT_REDUCE_JOB_BACKGROUND) |
143 | 203 | { | 203 | { |
144 | 204 | task->result_rc= GEARMAN_SUCCESS; | ||
145 | 204 | break; | 205 | break; |
146 | 205 | } | 206 | } |
147 | 206 | } | 207 | } |
148 | @@ -215,7 +216,7 @@ | |||
149 | 215 | gearman_return_t ret= task->func.data_fn(task->shell()); | 216 | gearman_return_t ret= task->func.data_fn(task->shell()); |
150 | 216 | if (gearman_failed(ret)) | 217 | if (gearman_failed(ret)) |
151 | 217 | { | 218 | { |
153 | 218 | task->state= GEARMAN_TASK_STATE_DATA; | 219 | task->set_state(GEARMAN_TASK_STATE_DATA); |
154 | 219 | return ret; | 220 | return ret; |
155 | 220 | } | 221 | } |
156 | 221 | } | 222 | } |
157 | @@ -228,7 +229,7 @@ | |||
158 | 228 | gearman_return_t ret= task->func.warning_fn(task->shell()); | 229 | gearman_return_t ret= task->func.warning_fn(task->shell()); |
159 | 229 | if (gearman_failed(ret)) | 230 | if (gearman_failed(ret)) |
160 | 230 | { | 231 | { |
162 | 231 | task->state= GEARMAN_TASK_STATE_WARNING; | 232 | task->set_state(GEARMAN_TASK_STATE_WARNING); |
163 | 232 | return ret; | 233 | return ret; |
164 | 233 | } | 234 | } |
165 | 234 | } | 235 | } |
166 | @@ -318,7 +319,7 @@ | |||
167 | 318 | gearman_return_t ret= task->func.status_fn(task->shell()); | 319 | gearman_return_t ret= task->func.status_fn(task->shell()); |
168 | 319 | if (gearman_failed(ret)) | 320 | if (gearman_failed(ret)) |
169 | 320 | { | 321 | { |
171 | 321 | task->state= GEARMAN_TASK_STATE_STATUS; | 322 | task->set_state(GEARMAN_TASK_STATE_STATUS); |
172 | 322 | return ret; | 323 | return ret; |
173 | 323 | } | 324 | } |
174 | 324 | } | 325 | } |
175 | @@ -345,7 +346,7 @@ | |||
176 | 345 | gearman_return_t ret= task->func.complete_fn(task->shell()); | 346 | gearman_return_t ret= task->func.complete_fn(task->shell()); |
177 | 346 | if (gearman_failed(ret)) | 347 | if (gearman_failed(ret)) |
178 | 347 | { | 348 | { |
180 | 348 | task->state= GEARMAN_TASK_STATE_COMPLETE; | 349 | task->set_state(GEARMAN_TASK_STATE_COMPLETE); |
181 | 349 | return ret; | 350 | return ret; |
182 | 350 | } | 351 | } |
183 | 351 | } | 352 | } |
184 | @@ -369,7 +370,7 @@ | |||
185 | 369 | gearman_return_t ret= task->func.exception_fn(task->shell()); | 370 | gearman_return_t ret= task->func.exception_fn(task->shell()); |
186 | 370 | if (gearman_failed(ret)) | 371 | if (gearman_failed(ret)) |
187 | 371 | { | 372 | { |
189 | 372 | task->state= GEARMAN_TASK_STATE_EXCEPTION; | 373 | task->set_state(GEARMAN_TASK_STATE_EXCEPTION); |
190 | 373 | return ret; | 374 | return ret; |
191 | 374 | } | 375 | } |
192 | 375 | } | 376 | } |
193 | @@ -391,7 +392,7 @@ | |||
194 | 391 | gearman_return_t ret= task->func.fail_fn(task->shell()); | 392 | gearman_return_t ret= task->func.fail_fn(task->shell()); |
195 | 392 | if (gearman_failed(ret)) | 393 | if (gearman_failed(ret)) |
196 | 393 | { | 394 | { |
198 | 394 | task->state= GEARMAN_TASK_STATE_FAIL; | 395 | task->set_state(GEARMAN_TASK_STATE_FAIL); |
199 | 395 | return ret; | 396 | return ret; |
200 | 396 | } | 397 | } |
201 | 397 | } | 398 | } |
202 | @@ -399,7 +400,7 @@ | |||
203 | 399 | break; | 400 | break; |
204 | 400 | } | 401 | } |
205 | 401 | 402 | ||
207 | 402 | task->state= GEARMAN_TASK_STATE_WORK; | 403 | task->set_state(GEARMAN_TASK_STATE_WORK); |
208 | 403 | return GEARMAN_SUCCESS; | 404 | return GEARMAN_SUCCESS; |
209 | 404 | 405 | ||
210 | 405 | case GEARMAN_TASK_STATE_FINISHED: | 406 | case GEARMAN_TASK_STATE_FINISHED: |
211 | @@ -407,7 +408,14 @@ | |||
212 | 407 | } | 408 | } |
213 | 408 | 409 | ||
214 | 409 | task->client->impl()->running_tasks--; | 410 | task->client->impl()->running_tasks--; |
216 | 410 | task->state= GEARMAN_TASK_STATE_FINISHED; | 411 | task->set_state(GEARMAN_TASK_STATE_FINISHED); |
217 | 412 | |||
218 | 413 | // @todo this should never happen... but background tasks can signal it. | ||
219 | 414 | if (task->result_rc == GEARMAN_UNKNOWN_STATE and task->client->impl()->universal.error()) | ||
220 | 415 | { | ||
221 | 416 | fprintf(stderr, "%s:%u %s\n", __FILE__, __LINE__, task->client->impl()->universal.error()); | ||
222 | 417 | } | ||
223 | 418 | assert(task->result_rc != GEARMAN_UNKNOWN_STATE); | ||
224 | 411 | 419 | ||
225 | 412 | if (task->client->impl()->options.free_tasks and task->type == GEARMAN_TASK_KIND_ADD_TASK) | 420 | if (task->client->impl()->options.free_tasks and task->type == GEARMAN_TASK_KIND_ADD_TASK) |
226 | 413 | { | 421 | { |
227 | 414 | 422 | ||
228 | === modified file 'tests/libgearman-1.0/worker_test.cc' | |||
229 | --- tests/libgearman-1.0/worker_test.cc 2013-07-06 08:02:19 +0000 | |||
230 | +++ tests/libgearman-1.0/worker_test.cc 2013-07-06 09:21:25 +0000 | |||
231 | @@ -66,6 +66,19 @@ | |||
232 | 66 | #include "tests/workers/v2/call_exception.h" | 66 | #include "tests/workers/v2/call_exception.h" |
233 | 67 | #include "tests/workers/v2/check_order.h" | 67 | #include "tests/workers/v2/check_order.h" |
234 | 68 | 68 | ||
235 | 69 | #if 0 | ||
236 | 70 | static gearman_return_t exception_fn(gearman_task_st* task) | ||
237 | 71 | { | ||
238 | 72 | Out << "GEARMAN_WORK_EXCEPTION: Task Handle: " << gearman_task_job_handle(task) << " return:" << gearman_strerror(gearman_task_return(task)); | ||
239 | 73 | return GEARMAN_SUCCESS; | ||
240 | 74 | } | ||
241 | 75 | #endif | ||
242 | 76 | |||
243 | 77 | static void error_logger(const char* message, gearman_verbose_t, void*) | ||
244 | 78 | { | ||
245 | 79 | Error << message; | ||
246 | 80 | } | ||
247 | 81 | |||
248 | 69 | static test_return_t init_test(void *) | 82 | static test_return_t init_test(void *) |
249 | 70 | { | 83 | { |
250 | 71 | gearman_worker_st worker; | 84 | gearman_worker_st worker; |
251 | @@ -420,7 +433,6 @@ | |||
252 | 420 | static test_return_t job_order_TEST(void *) | 433 | static test_return_t job_order_TEST(void *) |
253 | 421 | { | 434 | { |
254 | 422 | libgearman::Client client(libtest::default_port());; | 435 | libgearman::Client client(libtest::default_port());; |
255 | 423 | ASSERT_EQ(true, gearman_client_set_server_option(&client, test_literal_param("exceptions"))); | ||
256 | 424 | gearman_client_add_options(&client, GEARMAN_CLIENT_EXCEPTION); | 436 | gearman_client_add_options(&client, GEARMAN_CLIENT_EXCEPTION); |
257 | 425 | gearman_client_add_options(&client, GEARMAN_CLIENT_GENERATE_UNIQUE); | 437 | gearman_client_add_options(&client, GEARMAN_CLIENT_GENERATE_UNIQUE); |
258 | 426 | 438 | ||
259 | @@ -534,13 +546,16 @@ | |||
260 | 534 | for (std::vector<gearman_task_st*>::iterator iter= tasks.begin(); | 546 | for (std::vector<gearman_task_st*>::iterator iter= tasks.begin(); |
261 | 535 | iter != tasks.end(); ++iter) | 547 | iter != tasks.end(); ++iter) |
262 | 536 | { | 548 | { |
264 | 537 | if (gearman_task_return(*iter) != GEARMAN_UNKNOWN_STATE) | 549 | |
265 | 550 | if (gearman_failed(gearman_task_return(*iter))) | ||
266 | 538 | { | 551 | { |
269 | 539 | Error << ":" << gearman_task_error(*iter) << ":"; | 552 | if (gearman_task_return(*iter) != GEARMAN_UNKNOWN_STATE) |
270 | 540 | Error << ":" << gearman_strerror(gearman_task_return(*iter)) << ":"; | 553 | { |
271 | 554 | Error << "gearman_task_error(" << gearman_task_error(*iter) << ") gearman_task_return(" << gearman_strerror(gearman_task_return(*iter)) << ")"; | ||
272 | 555 | ASSERT_EQ(GEARMAN_UNKNOWN_STATE, gearman_task_return(*iter)); | ||
273 | 556 | ASSERT_NULL(gearman_task_error(*iter)); | ||
274 | 557 | } | ||
275 | 541 | } | 558 | } |
276 | 542 | ASSERT_EQ(GEARMAN_UNKNOWN_STATE, gearman_task_return(*iter)); | ||
277 | 543 | ASSERT_NULL(gearman_task_error(*iter)); | ||
278 | 544 | } | 559 | } |
279 | 545 | 560 | ||
280 | 546 | for (uint32_t x= 0; x < 10; ++x) | 561 | for (uint32_t x= 0; x < 10; ++x) |
281 | @@ -759,12 +774,6 @@ | |||
282 | 759 | return TEST_SUCCESS; | 774 | return TEST_SUCCESS; |
283 | 760 | } | 775 | } |
284 | 761 | 776 | ||
285 | 762 | static gearman_return_t exception_fn(gearman_task_st* task) | ||
286 | 763 | { | ||
287 | 764 | Out << "Task Handle: " << gearman_task_job_handle(task); | ||
288 | 765 | return GEARMAN_SUCCESS; | ||
289 | 766 | } | ||
290 | 767 | |||
291 | 768 | static test_return_t gearman_job_send_exception_mass_TEST(void *) | 777 | static test_return_t gearman_job_send_exception_mass_TEST(void *) |
292 | 769 | { | 778 | { |
293 | 770 | gearman_function_t call_exception_WORKER_FN= gearman_function_create(call_exception_WORKER); | 779 | gearman_function_t call_exception_WORKER_FN= gearman_function_create(call_exception_WORKER); |
294 | @@ -779,8 +788,14 @@ | |||
295 | 779 | std::vector<gearman_task_st*> tasks; | 788 | std::vector<gearman_task_st*> tasks; |
296 | 780 | libgearman::Client client(libtest::default_port()); | 789 | libgearman::Client client(libtest::default_port()); |
297 | 781 | 790 | ||
298 | 791 | #if 0 | ||
299 | 782 | gearman_exception_fn *func= exception_fn; | 792 | gearman_exception_fn *func= exception_fn; |
300 | 783 | gearman_client_set_exception_fn(&client, func); | 793 | gearman_client_set_exception_fn(&client, func); |
301 | 794 | #endif | ||
302 | 795 | #if 0 | ||
303 | 796 | ASSERT_EQ(true, gearman_client_set_server_option(&client, test_literal_param("exceptions"))); | ||
304 | 797 | #endif | ||
305 | 798 | gearman_client_add_options(&client, GEARMAN_CLIENT_EXCEPTION); | ||
306 | 784 | 799 | ||
307 | 785 | for (size_t x= 0; x < 100; ++x) | 800 | for (size_t x= 0; x < 100; ++x) |
308 | 786 | { | 801 | { |
309 | @@ -800,33 +815,59 @@ | |||
310 | 800 | tasks.push_back(task); | 815 | tasks.push_back(task); |
311 | 801 | } | 816 | } |
312 | 802 | 817 | ||
324 | 803 | { | 818 | bool more= true; |
325 | 804 | gearman_return_t ret; | 819 | while (more) |
326 | 805 | do { | 820 | { |
327 | 806 | ret= gearman_client_run_tasks(&client); | 821 | for (std::vector<gearman_task_st*>::iterator iter= tasks.begin(); |
328 | 807 | } while (gearman_continue(ret)); | 822 | iter != tasks.end(); ++iter) |
329 | 808 | } | 823 | { |
330 | 809 | 824 | if (gearman_task_return(*iter) == GEARMAN_UNKNOWN_STATE) | |
331 | 810 | for (std::vector<gearman_task_st*>::iterator iter= tasks.begin(); | 825 | { |
332 | 811 | iter != tasks.end(); ++iter) | 826 | { |
333 | 812 | { | 827 | gearman_return_t ret; |
334 | 813 | ASSERT_EQ(GEARMAN_WORK_FAIL, gearman_task_return(*iter)); | 828 | do { |
335 | 829 | ret= gearman_client_run_tasks(&client); | ||
336 | 830 | } while (gearman_continue(ret)); | ||
337 | 831 | |||
338 | 832 | if (gearman_failed(ret)) | ||
339 | 833 | { | ||
340 | 834 | Error << gearman_strerror(ret); | ||
341 | 835 | } | ||
342 | 836 | ASSERT_EQ(GEARMAN_SUCCESS, ret); | ||
343 | 837 | } | ||
344 | 838 | |||
345 | 839 | continue; | ||
346 | 840 | } | ||
347 | 841 | else | ||
348 | 842 | { | ||
349 | 843 | if (gearman_client_has_option(&client, GEARMAN_CLIENT_EXCEPTION)) | ||
350 | 844 | { | ||
351 | 845 | ASSERT_EQ(GEARMAN_WORK_EXCEPTION, gearman_task_return(*iter)); | ||
352 | 846 | } | ||
353 | 847 | else | ||
354 | 848 | { | ||
355 | 849 | ASSERT_EQ(GEARMAN_WORK_FAIL, gearman_task_return(*iter)); | ||
356 | 850 | } | ||
357 | 851 | } | ||
358 | 852 | |||
359 | 853 | more= false; | ||
360 | 854 | } | ||
361 | 814 | } | 855 | } |
362 | 815 | 856 | ||
363 | 816 | return TEST_SUCCESS; | 857 | return TEST_SUCCESS; |
364 | 817 | } | 858 | } |
365 | 818 | 859 | ||
366 | 819 | static void error_logger(const char* message, gearman_verbose_t, void*) | ||
367 | 820 | { | ||
368 | 821 | Error << message; | ||
369 | 822 | } | ||
370 | 823 | |||
371 | 824 | static test_return_t gearman_job_send_exception_TEST(void *) | 860 | static test_return_t gearman_job_send_exception_TEST(void *) |
372 | 825 | { | 861 | { |
373 | 826 | libgearman::Client client(libtest::default_port()); | 862 | libgearman::Client client(libtest::default_port()); |
374 | 827 | gearman_client_set_log_fn(&client, error_logger, NULL, GEARMAN_VERBOSE_ERROR); | 863 | gearman_client_set_log_fn(&client, error_logger, NULL, GEARMAN_VERBOSE_ERROR); |
375 | 828 | 864 | ||
377 | 829 | ASSERT_EQ(true, gearman_client_set_server_option(&client, test_literal_param("exceptions"))); | 865 | #if 0 |
378 | 866 | gearman_exception_fn *func= exception_fn; | ||
379 | 867 | gearman_client_set_exception_fn(&client, func); | ||
380 | 868 | #endif | ||
381 | 869 | |||
382 | 870 | gearman_client_add_options(&client, GEARMAN_CLIENT_EXCEPTION); | ||
383 | 830 | 871 | ||
384 | 831 | gearman_function_t exception_WORKER_FN= gearman_function_create(exception_WORKER); | 872 | gearman_function_t exception_WORKER_FN= gearman_function_create(exception_WORKER); |
385 | 832 | std::auto_ptr<worker_handle_st> handle(test_worker_start(libtest::default_port(), | 873 | std::auto_ptr<worker_handle_st> handle(test_worker_start(libtest::default_port(), |
386 | @@ -848,9 +889,16 @@ | |||
387 | 848 | ret= gearman_client_run_tasks(&client); | 889 | ret= gearman_client_run_tasks(&client); |
388 | 849 | } while (gearman_continue(ret)); | 890 | } while (gearman_continue(ret)); |
389 | 850 | 891 | ||
390 | 892 | if (gearman_client_has_option(&client, GEARMAN_CLIENT_EXCEPTION)) | ||
391 | 893 | { | ||
392 | 894 | ASSERT_EQ(GEARMAN_WORK_EXCEPTION, gearman_task_return(task)); | ||
393 | 895 | } | ||
394 | 896 | else | ||
395 | 897 | { | ||
396 | 898 | ASSERT_EQ(GEARMAN_WORK_FAIL, gearman_task_return(task)); | ||
397 | 899 | } | ||
398 | 900 | ASSERT_TRUE(gearman_task_has_exception(task)); | ||
399 | 851 | gearman_string_t exception= gearman_task_exception(task); | 901 | gearman_string_t exception= gearman_task_exception(task); |
400 | 852 | ASSERT_EQ(gearman_task_return(task), GEARMAN_WORK_EXCEPTION); | ||
401 | 853 | ASSERT_TRUE(gearman_task_has_exception(task)); | ||
402 | 854 | ASSERT_STREQ("dog", gearman_c_str(exception)); | 902 | ASSERT_STREQ("dog", gearman_c_str(exception)); |
403 | 855 | 903 | ||
404 | 856 | return TEST_SUCCESS; | 904 | return TEST_SUCCESS; |
405 | @@ -1252,20 +1300,19 @@ | |||
406 | 1252 | { | 1300 | { |
407 | 1253 | libgearman::Client client(libtest::default_port()); | 1301 | libgearman::Client client(libtest::default_port()); |
408 | 1254 | 1302 | ||
412 | 1255 | ASSERT_EQ(gearman_client_do_background(&client, function_name, unique_name, | 1303 | ASSERT_EQ(GEARMAN_SUCCESS, |
413 | 1256 | test_string_make_from_array(unique_name), NULL), | 1304 | gearman_client_do_background(&client, function_name, unique_name, test_string_make_from_array(unique_name), NULL)); |
411 | 1257 | GEARMAN_SUCCESS); | ||
414 | 1258 | } | 1305 | } |
415 | 1259 | 1306 | ||
416 | 1260 | gearman_worker_remove_options(&worker, GEARMAN_WORKER_GRAB_UNIQ); | 1307 | gearman_worker_remove_options(&worker, GEARMAN_WORKER_GRAB_UNIQ); |
418 | 1261 | test_false(worker->impl()->options.grab_uniq); | 1308 | ASSERT_FALSE(worker->impl()->options.grab_uniq); |
419 | 1262 | 1309 | ||
420 | 1263 | gearman_worker_set_timeout(&worker, 800); | 1310 | gearman_worker_set_timeout(&worker, 800); |
421 | 1264 | 1311 | ||
422 | 1265 | gearman_return_t rc; | 1312 | gearman_return_t rc; |
423 | 1266 | gearman_job_st *job= gearman_worker_grab_job(&worker, NULL, &rc); | 1313 | gearman_job_st *job= gearman_worker_grab_job(&worker, NULL, &rc); |
424 | 1267 | ASSERT_EQ(rc, GEARMAN_SUCCESS); | 1314 | ASSERT_EQ(rc, GEARMAN_SUCCESS); |
426 | 1268 | test_truth(job); | 1315 | ASSERT_TRUE(job); |
427 | 1269 | 1316 | ||
428 | 1270 | size_t size= 0; | 1317 | size_t size= 0; |
429 | 1271 | void *result= no_unique_worker(job, NULL, &size, &rc); | 1318 | void *result= no_unique_worker(job, NULL, &size, &rc); |