Merge lp:~brianaker/gearmand/client_impl_cleanup into lp:gearmand

Proposed by Brian Aker on 2013-07-07
Status: Merged
Merged at revision: 813
Proposed branch: lp:~brianaker/gearmand/client_impl_cleanup
Merge into: lp:gearmand
Diff against target: 812 lines (+128/-119)
9 files modified
libgearman/add.cc (+31/-31)
libgearman/add.hpp (+4/-4)
libgearman/client.cc (+38/-34)
libgearman/do.cc (+4/-4)
libgearman/execute.cc (+17/-13)
libgearman/interface/task.hpp (+8/-8)
libgearman/job.cc (+23/-22)
libgearman/task.cc (+2/-2)
libgearman/task.hpp (+1/-1)
To merge this branch: bzr merge lp:~brianaker/gearmand/client_impl_cleanup
Reviewer Review Type Date Requested Status
Tangent Trunk 2013-07-07 Pending
Review via email: mp+173340@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
1=== modified file 'libgearman/add.cc'
2--- libgearman/add.cc 2013-07-06 17:53:34 +0000
3+++ libgearman/add.cc 2013-07-07 00:33:27 +0000
4@@ -119,7 +119,7 @@
5
6 } // namespace
7
8-gearman_task_st *add_task(gearman_client_st& client,
9+gearman_task_st *add_task(Client& client,
10 void *context,
11 gearman_command_t command,
12 const gearman_string_t &function,
13@@ -131,7 +131,7 @@
14 return add_task(client, NULL, context, command, function, unique, workload, when, actions);
15 }
16
17-gearman_task_st *add_task_ptr(gearman_client_st& client,
18+gearman_task_st *add_task_ptr(Client& client,
19 gearman_task_st *task,
20 void *context,
21 gearman_command_t command,
22@@ -149,7 +149,7 @@
23 task= add_task(client, task, context, command, function, local_unique, workload, when, actions);
24 if (task == NULL)
25 {
26- ret_ptr= client.impl()->universal.error_code();
27+ ret_ptr= client.universal.error_code();
28 return NULL;
29 }
30
31@@ -158,7 +158,7 @@
32 return task;
33 }
34
35-gearman_task_st *add_task(gearman_client_st& client,
36+gearman_task_st *add_task(Client& client,
37 gearman_task_st *task_shell,
38 void *context,
39 gearman_command_t command,
40@@ -172,11 +172,11 @@
41 {
42 if (gearman_size(function) > GEARMAN_FUNCTION_MAX_SIZE)
43 {
44- gearman_error(client.impl()->universal, GEARMAN_INVALID_ARGUMENT, "function name longer then GEARMAN_MAX_FUNCTION_SIZE");
45+ gearman_error(client.universal, GEARMAN_INVALID_ARGUMENT, "function name longer then GEARMAN_MAX_FUNCTION_SIZE");
46 }
47 else
48 {
49- gearman_error(client.impl()->universal, GEARMAN_INVALID_ARGUMENT, "invalid function");
50+ gearman_error(client.universal, GEARMAN_INVALID_ARGUMENT, "invalid function");
51 }
52
53 return NULL;
54@@ -184,21 +184,21 @@
55
56 if (gearman_size(unique) > GEARMAN_MAX_UNIQUE_SIZE)
57 {
58- gearman_error(client.impl()->universal, GEARMAN_INVALID_ARGUMENT, "unique name longer then GEARMAN_MAX_UNIQUE_SIZE");
59+ gearman_error(client.universal, GEARMAN_INVALID_ARGUMENT, "unique name longer then GEARMAN_MAX_UNIQUE_SIZE");
60
61 return NULL;
62 }
63
64 if ((gearman_size(workload) && gearman_c_str(workload) == NULL) or (gearman_size(workload) == 0 && gearman_c_str(workload)))
65 {
66- gearman_error(client.impl()->universal, GEARMAN_INVALID_ARGUMENT, "invalid workload");
67+ gearman_error(client.universal, GEARMAN_INVALID_ARGUMENT, "invalid workload");
68 return NULL;
69 }
70
71- task_shell= gearman_task_internal_create(client, task_shell);
72+ task_shell= gearman_task_internal_create(&client, task_shell);
73 if (task_shell == NULL or task_shell->impl() == NULL)
74 {
75- assert(client.impl()->universal.error());
76+ assert(client.universal.error());
77 return NULL;
78 }
79 assert(task_shell->impl()->client);
80@@ -224,7 +224,7 @@
81 }
82 else
83 {
84- if (client.impl()->options.generate_unique or is_background(command))
85+ if (client.options.generate_unique or is_background(command))
86 {
87 if (safe_uuid_generate(task->unique, task->unique_length) == -1)
88 {
89@@ -324,8 +324,8 @@
90
91 if (gearman_success(rc))
92 {
93- client.impl()->new_tasks++;
94- client.impl()->running_tasks++;
95+ client.new_tasks++;
96+ client.running_tasks++;
97 task->options.send_in_use= true;
98
99 return task->shell();
100@@ -336,7 +336,7 @@
101 return NULL;
102 }
103
104-gearman_task_st *add_reducer_task(gearman_client_st *client,
105+gearman_task_st *add_reducer_task(Client* client,
106 gearman_command_t command,
107 const gearman_job_priority_t,
108 const gearman_string_t &function,
109@@ -354,11 +354,11 @@
110 {
111 if (gearman_size(function) > GEARMAN_FUNCTION_MAX_SIZE)
112 {
113- gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "function name longer then GEARMAN_MAX_FUNCTION_SIZE");
114+ gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "function name longer then GEARMAN_MAX_FUNCTION_SIZE");
115 }
116 else
117 {
118- gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "invalid function");
119+ gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "invalid function");
120 }
121
122 return NULL;
123@@ -366,21 +366,21 @@
124
125 if (gearman_size(unique) > GEARMAN_MAX_UNIQUE_SIZE)
126 {
127- gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "unique name longer then GEARMAN_MAX_UNIQUE_SIZE");
128+ gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "unique name longer then GEARMAN_MAX_UNIQUE_SIZE");
129
130 return NULL;
131 }
132
133 if ((gearman_size(workload) and not gearman_c_str(workload)) or (gearman_size(workload) == 0 && gearman_c_str(workload)))
134 {
135- gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "invalid workload");
136+ gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "invalid workload");
137 return NULL;
138 }
139
140- gearman_task_st *task_shell= gearman_task_internal_create(*client, NULL);
141+ gearman_task_st *task_shell= gearman_task_internal_create(client, NULL);
142 if (task_shell == NULL)
143 {
144- assert(client->impl()->universal.error_code());
145+ assert(client->universal.error_code());
146 return NULL;
147 }
148
149@@ -392,11 +392,11 @@
150 @todo fix it so that NULL is done by default by the API not by happenstance.
151 */
152 char function_buffer[1024];
153- if (client->impl()->universal._namespace)
154+ if (client->universal._namespace)
155 {
156 char *ptr= function_buffer;
157- memcpy(ptr, gearman_string_value(client->impl()->universal._namespace), gearman_string_length(client->impl()->universal._namespace));
158- ptr+= gearman_string_length(client->impl()->universal._namespace);
159+ memcpy(ptr, gearman_string_value(client->universal._namespace), gearman_string_length(client->universal._namespace));
160+ ptr+= gearman_string_length(client->universal._namespace);
161
162 memcpy(ptr, gearman_c_str(function), gearman_size(function) +1);
163 ptr+= gearman_size(function);
164@@ -426,7 +426,7 @@
165 }
166 else
167 {
168- if (client->impl()->options.generate_unique or is_background(command))
169+ if (client->options.generate_unique or is_background(command))
170 {
171 safe_uuid_generate(task->unique, task->unique_length);
172 }
173@@ -444,11 +444,11 @@
174 "Command was not appropriate for request");
175
176 char reducer_buffer[1024];
177- if (client->impl()->universal._namespace)
178+ if (client->universal._namespace)
179 {
180 char *ptr= reducer_buffer;
181- memcpy(ptr, gearman_string_value(client->impl()->universal._namespace), gearman_string_length(client->impl()->universal._namespace));
182- ptr+= gearman_string_length(client->impl()->universal._namespace);
183+ memcpy(ptr, gearman_string_value(client->universal._namespace), gearman_string_length(client->universal._namespace));
184+ ptr+= gearman_string_length(client->universal._namespace);
185
186 memcpy(ptr, gearman_c_str(reducer), gearman_size(reducer) +1);
187 ptr+= gearman_size(reducer);
188@@ -473,18 +473,18 @@
189 args_size[4]= gearman_size(workload);
190
191 gearman_return_t rc;
192- if (gearman_success(rc= gearman_packet_create_args(client->impl()->universal, task->send,
193+ if (gearman_success(rc= gearman_packet_create_args(client->universal, task->send,
194 GEARMAN_MAGIC_REQUEST, command,
195 args, args_size,
196 5)))
197 {
198- client->impl()->new_tasks++;
199- client->impl()->running_tasks++;
200+ client->new_tasks++;
201+ client->running_tasks++;
202 task->options.send_in_use= true;
203 }
204 else
205 {
206- gearman_gerror(client->impl()->universal, rc);
207+ gearman_gerror(client->universal, rc);
208 gearman_task_free(task);
209 task= NULL;
210 }
211
212=== modified file 'libgearman/add.hpp'
213--- libgearman/add.hpp 2013-07-03 09:00:14 +0000
214+++ libgearman/add.hpp 2013-07-07 00:33:27 +0000
215@@ -42,7 +42,7 @@
216
217 #pragma once
218
219-gearman_task_st *add_task(gearman_client_st& client,
220+gearman_task_st *add_task(Client& client,
221 void *context,
222 gearman_command_t command,
223 const gearman_string_t &function,
224@@ -51,7 +51,7 @@
225 time_t when,
226 const gearman_actions_t &actions);
227
228-gearman_task_st *add_task_ptr(gearman_client_st& client,
229+gearman_task_st *add_task_ptr(Client& client,
230 gearman_task_st *task,
231 void *context,
232 gearman_command_t command,
233@@ -62,7 +62,7 @@
234 gearman_return_t& ret_ptr,
235 const gearman_actions_t &actions);
236
237-gearman_task_st *add_task(gearman_client_st& client,
238+gearman_task_st *add_task(Client& client,
239 gearman_task_st *task,
240 void *context,
241 gearman_command_t command,
242@@ -72,7 +72,7 @@
243 time_t when,
244 const gearman_actions_t &actions);
245
246-gearman_task_st *add_reducer_task(gearman_client_st *client,
247+gearman_task_st *add_reducer_task(Client *client,
248 gearman_command_t command,
249 const gearman_job_priority_t priority,
250 const gearman_string_t &function,
251
252=== modified file 'libgearman/client.cc'
253--- libgearman/client.cc 2013-07-06 19:11:08 +0000
254+++ libgearman/client.cc 2013-07-07 00:33:27 +0000
255@@ -125,7 +125,7 @@
256 gearman_task_st do_task;
257 {
258 client->universal.options.no_new_data= true;
259- gearman_task_st *do_task_ptr= add_task(*(client->shell()), &do_task, NULL, command,
260+ gearman_task_st *do_task_ptr= add_task(*client, &do_task, NULL, command,
261 function,
262 local_unique,
263 workload,
264@@ -237,7 +237,7 @@
265 gearman_task_st do_task;
266 {
267 client->universal.options.no_new_data= true;
268- gearman_task_st* do_task_ptr= add_task(*client_shell, &do_task,
269+ gearman_task_st* do_task_ptr= add_task(*client, &do_task,
270 client,
271 command,
272 function,
273@@ -826,7 +826,7 @@
274 gearman_status_t status;
275 gearman_init(status);
276
277- if (client == NULL)
278+ if (client == NULL or client->impl() == NULL)
279 {
280 gearman_status_set_return(status, GEARMAN_INVALID_ARGUMENT);
281 return status;
282@@ -889,7 +889,7 @@
283 return status;
284 }
285
286-gearman_return_t gearman_client_job_status(gearman_client_st *client,
287+gearman_return_t gearman_client_job_status(gearman_client_st *client_shell,
288 const gearman_job_handle_t job_handle,
289 bool *is_known, bool *is_running,
290 uint32_t *numerator,
291@@ -897,16 +897,18 @@
292 {
293 gearman_return_t ret;
294
295- if (client == NULL)
296+ if (client_shell == NULL or client_shell->impl() == NULL)
297 {
298 return GEARMAN_INVALID_ARGUMENT;
299 }
300
301- client->impl()->universal.reset_error();
302+ Client* client= client_shell->impl();
303+
304+ client->universal.reset_error();
305
306 gearman_task_st do_task;
307 {
308- gearman_task_st *do_task_ptr= gearman_client_add_task_status(client, &do_task, client,
309+ gearman_task_st *do_task_ptr= gearman_client_add_task_status(client_shell, &do_task, client,
310 job_handle, &ret);
311 if (gearman_failed(ret))
312 {
313@@ -918,7 +920,7 @@
314
315 gearman_task_clear_fn(&do_task);
316
317- ret= gearman_client_run_block_tasks(client, &do_task);
318+ ret= gearman_client_run_block_tasks(client_shell, &do_task);
319
320 // @note we don't know if our task was run or not, we just know something
321 // happened.
322@@ -1049,13 +1051,13 @@
323 ret_ptr= &unused;
324 }
325
326- if (client == NULL)
327+ if (client == NULL or client->impl() == NULL)
328 {
329 *ret_ptr= GEARMAN_INVALID_ARGUMENT;
330 return NULL;
331 }
332
333- return add_task_ptr(*client, task,
334+ return add_task_ptr(*(client->impl()), task,
335 context, GEARMAN_COMMAND_SUBMIT_JOB,
336 function,
337 unique,
338@@ -1079,13 +1081,13 @@
339 ret_ptr= &unused;
340 }
341
342- if (client == NULL)
343+ if (client == NULL or client->impl() == NULL)
344 {
345 *ret_ptr= GEARMAN_INVALID_ARGUMENT;
346 return NULL;
347 }
348
349- return add_task_ptr(*client, task, context,
350+ return add_task_ptr(*(client->impl()), task, context,
351 GEARMAN_COMMAND_SUBMIT_JOB_HIGH,
352 function,
353 unique,
354@@ -1109,13 +1111,13 @@
355 ret_ptr= &unused;
356 }
357
358- if (client == NULL)
359+ if (client == NULL or client->impl() == NULL)
360 {
361 *ret_ptr= GEARMAN_INVALID_ARGUMENT;
362 return NULL;
363 }
364
365- return add_task_ptr(*client, task, context, GEARMAN_COMMAND_SUBMIT_JOB_LOW,
366+ return add_task_ptr(*(client->impl()), task, context, GEARMAN_COMMAND_SUBMIT_JOB_LOW,
367 function,
368 unique,
369 workload, workload_size,
370@@ -1138,13 +1140,13 @@
371 ret_ptr= &unused;
372 }
373
374- if (client == NULL)
375+ if (client == NULL or client->impl() == NULL)
376 {
377 *ret_ptr= GEARMAN_INVALID_ARGUMENT;
378 return NULL;
379 }
380
381- return add_task_ptr(*client, task, context, GEARMAN_COMMAND_SUBMIT_JOB_BG,
382+ return add_task_ptr(*(client->impl()), task, context, GEARMAN_COMMAND_SUBMIT_JOB_BG,
383 function,
384 unique,
385 workload, workload_size,
386@@ -1168,13 +1170,13 @@
387 ret_ptr= &unused;
388 }
389
390- if (client == NULL)
391+ if (client == NULL or client->impl() == NULL)
392 {
393 *ret_ptr= GEARMAN_INVALID_ARGUMENT;
394 return NULL;
395 }
396
397- return add_task_ptr(*client, task, context,
398+ return add_task_ptr(*(client->impl()), task, context,
399 GEARMAN_COMMAND_SUBMIT_JOB_HIGH_BG,
400 function,
401 unique,
402@@ -1198,13 +1200,13 @@
403 ret_ptr= &unused;
404 }
405
406- if (client == NULL)
407+ if (client == NULL or client->impl() == NULL)
408 {
409 *ret_ptr= GEARMAN_INVALID_ARGUMENT;
410 return NULL;
411 }
412
413- return add_task_ptr(*client, task, context,
414+ return add_task_ptr(*(client->impl()), task, context,
415 GEARMAN_COMMAND_SUBMIT_JOB_LOW_BG,
416 function,
417 unique,
418@@ -1215,7 +1217,7 @@
419
420 }
421
422-gearman_task_st *gearman_client_add_task_status(gearman_client_st *client,
423+gearman_task_st *gearman_client_add_task_status(gearman_client_st *client_shell,
424 gearman_task_st *task_shell,
425 void *context,
426 const gearman_job_handle_t job_handle,
427@@ -1230,15 +1232,16 @@
428 ret_ptr= &unused;
429 }
430
431- if (client == NULL)
432+ if (client_shell == NULL or client_shell->impl() == NULL)
433 {
434 *ret_ptr= GEARMAN_INVALID_ARGUMENT;
435 return NULL;
436 }
437+ Client* client= client_shell->impl();
438
439- if ((task_shell= gearman_task_internal_create(*client, task_shell)) == NULL)
440+ if ((task_shell= gearman_task_internal_create(client, task_shell)) == NULL)
441 {
442- *ret_ptr= gearman_client_error_code(client);
443+ *ret_ptr= gearman_client_error_code(client_shell);
444 return NULL;
445 }
446
447@@ -1249,14 +1252,14 @@
448
449 args[0]= job_handle;
450 args_size[0]= strlen(job_handle);
451- gearman_return_t rc= gearman_packet_create_args(client->impl()->universal, task->send,
452+ gearman_return_t rc= gearman_packet_create_args(client->universal, task->send,
453 GEARMAN_MAGIC_REQUEST,
454 GEARMAN_COMMAND_GET_STATUS,
455 args, args_size, 1);
456 if (gearman_success(rc))
457 {
458- client->impl()->new_tasks++;
459- client->impl()->running_tasks++;
460+ client->new_tasks++;
461+ client->running_tasks++;
462 task->options.send_in_use= true;
463 }
464 *ret_ptr= rc;
465@@ -1264,7 +1267,7 @@
466 return task_shell;
467 }
468
469-gearman_task_st *gearman_client_add_task_status_by_unique(gearman_client_st *client,
470+gearman_task_st *gearman_client_add_task_status_by_unique(gearman_client_st *client_shell,
471 gearman_task_st *task_shell,
472 const char *unique_handle,
473 gearman_return_t *ret_ptr)
474@@ -1278,11 +1281,12 @@
475 ret_ptr= &unused;
476 }
477
478- if (client == NULL)
479+ if (client_shell == NULL or client_shell->impl() == NULL)
480 {
481 *ret_ptr= GEARMAN_INVALID_ARGUMENT;
482 return NULL;
483 }
484+ Client* client= client_shell->impl();
485
486 if (unique_handle == NULL)
487 {
488@@ -1297,9 +1301,9 @@
489 return NULL;
490 }
491
492- if ((task_shell= gearman_task_internal_create(*client, task_shell)) == NULL)
493+ if ((task_shell= gearman_task_internal_create(client, task_shell)) == NULL)
494 {
495- *ret_ptr= gearman_client_error_code(client);
496+ *ret_ptr= gearman_client_error_code(client_shell);
497 return NULL;
498 }
499
500@@ -1311,14 +1315,14 @@
501
502 args[0]= task->unique;
503 args_size[0]= task->unique_length;
504- gearman_return_t rc= gearman_packet_create_args(client->impl()->universal, task->send,
505+ gearman_return_t rc= gearman_packet_create_args(client->universal, task->send,
506 GEARMAN_MAGIC_REQUEST,
507 GEARMAN_COMMAND_GET_STATUS_UNIQUE,
508 args, args_size, 1);
509 if (gearman_success(rc))
510 {
511- client->impl()->new_tasks++;
512- client->impl()->running_tasks++;
513+ client->new_tasks++;
514+ client->running_tasks++;
515 task->options.send_in_use= true;
516 }
517 *ret_ptr= rc;
518
519=== modified file 'libgearman/do.cc'
520--- libgearman/do.cc 2013-01-28 23:44:49 +0000
521+++ libgearman/do.cc 2013-07-07 00:33:27 +0000
522@@ -71,14 +71,14 @@
523 ret_ptr= &unused;
524 }
525
526- if (client == NULL)
527+ if (client == NULL or client->impl() == NULL)
528 {
529 *ret_ptr= GEARMAN_INVALID_ARGUMENT;
530 return NULL;
531 }
532
533 {
534- gearman_task_st *do_task_ptr= add_task(*client, &do_task, NULL, command,
535+ gearman_task_st *do_task_ptr= add_task(*(client->impl()), &do_task, NULL, command,
536 function,
537 local_unique,
538 workload,
539@@ -144,14 +144,14 @@
540 gearman_string_t &workload,
541 gearman_job_handle_t job_handle)
542 {
543- if (client == NULL)
544+ if (client == NULL or client->impl() == NULL)
545 {
546 return GEARMAN_INVALID_ARGUMENT;
547 }
548
549 gearman_task_st do_task;
550 {
551- gearman_task_st *do_task_ptr= add_task(*client, &do_task,
552+ gearman_task_st *do_task_ptr= add_task(*(client->impl()), &do_task,
553 client,
554 command,
555 function,
556
557=== modified file 'libgearman/execute.cc'
558--- libgearman/execute.cc 2013-05-11 11:15:03 +0000
559+++ libgearman/execute.cc 2013-07-07 00:33:27 +0000
560@@ -70,18 +70,20 @@
561
562
563
564-gearman_task_st *gearman_execute(gearman_client_st *client,
565+gearman_task_st *gearman_execute(gearman_client_st *client_shell,
566 const char *function_name, size_t function_length,
567 const char *unique_str, size_t unique_length,
568 gearman_task_attr_t *task_attr,
569 gearman_argument_t *arguments,
570 void *context)
571 {
572- if (client == NULL)
573+ if (client_shell == NULL or client_shell->impl() == NULL)
574 {
575 return NULL;
576 }
577
578+ Client* client= client_shell->impl();
579+
580 gearman_argument_t null_arg= gearman_argument_make(0, 0, 0, 0);
581 if (arguments == NULL)
582 {
583@@ -90,7 +92,7 @@
584
585 if (function_name == NULL or function_length == 0)
586 {
587- gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "function_name was NULL");
588+ gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "function_name was NULL");
589 return NULL;
590 }
591 gearman_string_t function= { function_name, function_length };
592@@ -149,18 +151,18 @@
593
594 if (task == NULL)
595 {
596- gearman_universal_error_code(client->impl()->universal);
597+ gearman_universal_error_code(client->universal);
598
599 return NULL;
600 }
601
602 task->impl()->type= GEARMAN_TASK_KIND_EXECUTE;
603- gearman_client_run_tasks(client);
604+ gearman_client_run_tasks(client->shell());
605
606 return task;
607 }
608
609-gearman_task_st *gearman_execute_by_partition(gearman_client_st *client,
610+gearman_task_st *gearman_execute_by_partition(gearman_client_st *client_shell,
611 const char *partition_function, const size_t partition_function_length,
612 const char *function_name, const size_t function_name_length,
613 const char *unique_str, const size_t unique_length,
614@@ -168,25 +170,27 @@
615 gearman_argument_t *arguments,
616 void *context)
617 {
618- if (client == NULL)
619+ if (client_shell == NULL or client_shell->impl() == NULL)
620 {
621 errno= EINVAL;
622 return NULL;
623 }
624
625+ Client* client= client_shell->impl();
626+
627 if ((partition_function == NULL) or (partition_function_length == 0))
628 {
629- gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "partition_function was NULL");
630+ gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "partition_function was NULL");
631 return NULL;
632 }
633
634 if ((function_name == NULL) or (function_name_length == 0))
635 {
636- gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "function_name was NULL");
637+ gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "function_name was NULL");
638 return NULL;
639 }
640
641- universal_reset_error(client->impl()->universal);
642+ universal_reset_error(client->universal);
643
644 gearman_task_st *task= NULL;
645 gearman_string_t partition= { partition_function, partition_function_length };
646@@ -211,7 +215,7 @@
647 break;
648
649 case GEARMAN_TASK_ATTR_EPOCH:
650- gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "EPOCH is not currently supported for gearman_client_execute_reduce()");
651+ gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "EPOCH is not currently supported for gearman_client_execute_reduce()");
652 return NULL;
653 #if 0
654 task= add_task(client,
655@@ -262,9 +266,9 @@
656
657 do {
658 gearman_return_t rc;
659- if (gearman_failed(rc= gearman_client_run_tasks(client)))
660+ if (gearman_failed(rc= gearman_client_run_tasks(client->shell())))
661 {
662- gearman_gerror(client->impl()->universal, rc);
663+ gearman_gerror(client->universal, rc);
664 gearman_task_free(task);
665 return NULL;
666 }
667
668=== modified file 'libgearman/interface/task.hpp'
669--- libgearman/interface/task.hpp 2013-07-06 20:11:54 +0000
670+++ libgearman/interface/task.hpp 2013-07-07 00:33:27 +0000
671@@ -89,7 +89,7 @@
672 return _shell;
673 }
674
675- Task(gearman_client_st& client_, gearman_task_st* shell_) :
676+ Task(Client* client_, gearman_task_st* shell_) :
677 type(GEARMAN_TASK_KIND_ADD_TASK),
678 state(GEARMAN_TASK_STATE_NEW),
679 magic_(TASK_MAGIC),
680@@ -97,13 +97,13 @@
681 numerator(0),
682 denominator(0),
683 client_count(0),
684- client(client_.impl()),
685+ client(client_),
686 next(NULL),
687 prev(NULL),
688 context(NULL),
689 con(NULL),
690 recv(NULL),
691- func(client_.impl()->actions),
692+ func(client_->actions),
693 result_rc(GEARMAN_UNKNOWN_STATE),
694 _result_ptr(NULL),
695 unique_length(0),
696@@ -125,14 +125,14 @@
697
698 // Add the task to the client
699 {
700- if (client_.impl()->task_list)
701+ if (client_->task_list)
702 {
703- client_.impl()->task_list->impl()->prev= _shell;
704+ client_->task_list->impl()->prev= _shell;
705 }
706- next= client_.impl()->task_list;
707+ next= client_->task_list;
708 prev= NULL;
709- client_.impl()->task_list= _shell;
710- client_.impl()->task_count++;
711+ client_->task_list= _shell;
712+ client_->task_count++;
713 }
714
715 _shell->impl(this);
716
717=== modified file 'libgearman/job.cc'
718--- libgearman/job.cc 2013-07-05 22:06:45 +0000
719+++ libgearman/job.cc 2013-07-07 00:33:27 +0000
720@@ -77,34 +77,35 @@
721 bool init()
722 {
723 client= gearman_client_create(NULL);
724- if (not client)
725- {
726- return false;
727- }
728-
729- if (universal._namespace)
730- {
731- gearman_client_set_namespace(client,
732- gearman_string_value(universal._namespace),
733- gearman_string_length(universal._namespace));
734- }
735-
736- for (gearman_connection_st *con= universal.con_list; con; con= con->next_connection())
737- {
738- if (gearman_failed(client->impl()->add_server(con->_host, con->_service)))
739- {
740- return false;
741- }
742- }
743-
744- return true;
745+ if (client)
746+ {
747+
748+ if (universal._namespace)
749+ {
750+ gearman_client_set_namespace(client,
751+ gearman_string_value(universal._namespace),
752+ gearman_string_length(universal._namespace));
753+ }
754+
755+ for (gearman_connection_st *con= universal.con_list; con; con= con->next_connection())
756+ {
757+ if (gearman_failed(client->impl()->add_server(con->_host, con->_service)))
758+ {
759+ return false;
760+ }
761+ }
762+
763+ return true;
764+ }
765+
766+ return false;
767 }
768
769 bool add(gearman_argument_t &arguments)
770 {
771 gearman_string_t function= gearman_string(reducer_function);
772 gearman_unique_t unique= gearman_unique_make(0, 0);
773- gearman_task_st *task= add_task(*client,
774+ gearman_task_st *task= add_task(*(client->impl()),
775 NULL,
776 GEARMAN_COMMAND_SUBMIT_JOB,
777 function,
778
779=== modified file 'libgearman/task.cc'
780--- libgearman/task.cc 2013-07-06 17:53:34 +0000
781+++ libgearman/task.cc 2013-07-07 00:33:27 +0000
782@@ -54,7 +54,7 @@
783 * Public Definitions
784 */
785
786-gearman_task_st *gearman_task_internal_create(gearman_client_st& client, gearman_task_st *task_shell)
787+gearman_task_st *gearman_task_internal_create(Client* client, gearman_task_st *task_shell)
788 {
789 Task* task= new (std::nothrow) Task(client, task_shell);
790 if (task)
791@@ -62,7 +62,7 @@
792 return task->shell();
793 }
794
795- gearman_perror(client.impl()->universal, "gearman_task_st new");
796+ gearman_perror(client->universal, "gearman_task_st new");
797 gearman_task_free(task_shell);
798
799 return NULL;
800
801=== modified file 'libgearman/task.hpp'
802--- libgearman/task.hpp 2013-07-06 17:53:34 +0000
803+++ libgearman/task.hpp 2013-07-07 00:33:27 +0000
804@@ -46,7 +46,7 @@
805 * @return On success, a pointer to the (possibly allocated) structure. On
806 * failure this will be NULL.
807 */
808-gearman_task_st *gearman_task_internal_create(gearman_client_st& client,
809+gearman_task_st *gearman_task_internal_create(Client* client,
810 gearman_task_st *task);
811
812 void gearman_task_free(Task* task);

Subscribers

People subscribed via source and target branches

to all changes: