Merge lp:~brianaker/gearmand/client_impl_cleanup into lp:gearmand
- client_impl_cleanup
- Merge into 1.2
Proposed by
Brian Aker
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tangent Trunk | Pending | ||
Review via email: mp+173340@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/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 | 119 | 119 | ||
6 | 120 | } // namespace | 120 | } // namespace |
7 | 121 | 121 | ||
9 | 122 | gearman_task_st *add_task(gearman_client_st& client, | 122 | gearman_task_st *add_task(Client& client, |
10 | 123 | void *context, | 123 | void *context, |
11 | 124 | gearman_command_t command, | 124 | gearman_command_t command, |
12 | 125 | const gearman_string_t &function, | 125 | const gearman_string_t &function, |
13 | @@ -131,7 +131,7 @@ | |||
14 | 131 | return add_task(client, NULL, context, command, function, unique, workload, when, actions); | 131 | return add_task(client, NULL, context, command, function, unique, workload, when, actions); |
15 | 132 | } | 132 | } |
16 | 133 | 133 | ||
18 | 134 | gearman_task_st *add_task_ptr(gearman_client_st& client, | 134 | gearman_task_st *add_task_ptr(Client& client, |
19 | 135 | gearman_task_st *task, | 135 | gearman_task_st *task, |
20 | 136 | void *context, | 136 | void *context, |
21 | 137 | gearman_command_t command, | 137 | gearman_command_t command, |
22 | @@ -149,7 +149,7 @@ | |||
23 | 149 | task= add_task(client, task, context, command, function, local_unique, workload, when, actions); | 149 | task= add_task(client, task, context, command, function, local_unique, workload, when, actions); |
24 | 150 | if (task == NULL) | 150 | if (task == NULL) |
25 | 151 | { | 151 | { |
27 | 152 | ret_ptr= client.impl()->universal.error_code(); | 152 | ret_ptr= client.universal.error_code(); |
28 | 153 | return NULL; | 153 | return NULL; |
29 | 154 | } | 154 | } |
30 | 155 | 155 | ||
31 | @@ -158,7 +158,7 @@ | |||
32 | 158 | return task; | 158 | return task; |
33 | 159 | } | 159 | } |
34 | 160 | 160 | ||
36 | 161 | gearman_task_st *add_task(gearman_client_st& client, | 161 | gearman_task_st *add_task(Client& client, |
37 | 162 | gearman_task_st *task_shell, | 162 | gearman_task_st *task_shell, |
38 | 163 | void *context, | 163 | void *context, |
39 | 164 | gearman_command_t command, | 164 | gearman_command_t command, |
40 | @@ -172,11 +172,11 @@ | |||
41 | 172 | { | 172 | { |
42 | 173 | if (gearman_size(function) > GEARMAN_FUNCTION_MAX_SIZE) | 173 | if (gearman_size(function) > GEARMAN_FUNCTION_MAX_SIZE) |
43 | 174 | { | 174 | { |
45 | 175 | gearman_error(client.impl()->universal, GEARMAN_INVALID_ARGUMENT, "function name longer then GEARMAN_MAX_FUNCTION_SIZE"); | 175 | gearman_error(client.universal, GEARMAN_INVALID_ARGUMENT, "function name longer then GEARMAN_MAX_FUNCTION_SIZE"); |
46 | 176 | } | 176 | } |
47 | 177 | else | 177 | else |
48 | 178 | { | 178 | { |
50 | 179 | gearman_error(client.impl()->universal, GEARMAN_INVALID_ARGUMENT, "invalid function"); | 179 | gearman_error(client.universal, GEARMAN_INVALID_ARGUMENT, "invalid function"); |
51 | 180 | } | 180 | } |
52 | 181 | 181 | ||
53 | 182 | return NULL; | 182 | return NULL; |
54 | @@ -184,21 +184,21 @@ | |||
55 | 184 | 184 | ||
56 | 185 | if (gearman_size(unique) > GEARMAN_MAX_UNIQUE_SIZE) | 185 | if (gearman_size(unique) > GEARMAN_MAX_UNIQUE_SIZE) |
57 | 186 | { | 186 | { |
59 | 187 | gearman_error(client.impl()->universal, GEARMAN_INVALID_ARGUMENT, "unique name longer then GEARMAN_MAX_UNIQUE_SIZE"); | 187 | gearman_error(client.universal, GEARMAN_INVALID_ARGUMENT, "unique name longer then GEARMAN_MAX_UNIQUE_SIZE"); |
60 | 188 | 188 | ||
61 | 189 | return NULL; | 189 | return NULL; |
62 | 190 | } | 190 | } |
63 | 191 | 191 | ||
64 | 192 | if ((gearman_size(workload) && gearman_c_str(workload) == NULL) or (gearman_size(workload) == 0 && gearman_c_str(workload))) | 192 | if ((gearman_size(workload) && gearman_c_str(workload) == NULL) or (gearman_size(workload) == 0 && gearman_c_str(workload))) |
65 | 193 | { | 193 | { |
67 | 194 | gearman_error(client.impl()->universal, GEARMAN_INVALID_ARGUMENT, "invalid workload"); | 194 | gearman_error(client.universal, GEARMAN_INVALID_ARGUMENT, "invalid workload"); |
68 | 195 | return NULL; | 195 | return NULL; |
69 | 196 | } | 196 | } |
70 | 197 | 197 | ||
72 | 198 | task_shell= gearman_task_internal_create(client, task_shell); | 198 | task_shell= gearman_task_internal_create(&client, task_shell); |
73 | 199 | if (task_shell == NULL or task_shell->impl() == NULL) | 199 | if (task_shell == NULL or task_shell->impl() == NULL) |
74 | 200 | { | 200 | { |
76 | 201 | assert(client.impl()->universal.error()); | 201 | assert(client.universal.error()); |
77 | 202 | return NULL; | 202 | return NULL; |
78 | 203 | } | 203 | } |
79 | 204 | assert(task_shell->impl()->client); | 204 | assert(task_shell->impl()->client); |
80 | @@ -224,7 +224,7 @@ | |||
81 | 224 | } | 224 | } |
82 | 225 | else | 225 | else |
83 | 226 | { | 226 | { |
85 | 227 | if (client.impl()->options.generate_unique or is_background(command)) | 227 | if (client.options.generate_unique or is_background(command)) |
86 | 228 | { | 228 | { |
87 | 229 | if (safe_uuid_generate(task->unique, task->unique_length) == -1) | 229 | if (safe_uuid_generate(task->unique, task->unique_length) == -1) |
88 | 230 | { | 230 | { |
89 | @@ -324,8 +324,8 @@ | |||
90 | 324 | 324 | ||
91 | 325 | if (gearman_success(rc)) | 325 | if (gearman_success(rc)) |
92 | 326 | { | 326 | { |
95 | 327 | client.impl()->new_tasks++; | 327 | client.new_tasks++; |
96 | 328 | client.impl()->running_tasks++; | 328 | client.running_tasks++; |
97 | 329 | task->options.send_in_use= true; | 329 | task->options.send_in_use= true; |
98 | 330 | 330 | ||
99 | 331 | return task->shell(); | 331 | return task->shell(); |
100 | @@ -336,7 +336,7 @@ | |||
101 | 336 | return NULL; | 336 | return NULL; |
102 | 337 | } | 337 | } |
103 | 338 | 338 | ||
105 | 339 | gearman_task_st *add_reducer_task(gearman_client_st *client, | 339 | gearman_task_st *add_reducer_task(Client* client, |
106 | 340 | gearman_command_t command, | 340 | gearman_command_t command, |
107 | 341 | const gearman_job_priority_t, | 341 | const gearman_job_priority_t, |
108 | 342 | const gearman_string_t &function, | 342 | const gearman_string_t &function, |
109 | @@ -354,11 +354,11 @@ | |||
110 | 354 | { | 354 | { |
111 | 355 | if (gearman_size(function) > GEARMAN_FUNCTION_MAX_SIZE) | 355 | if (gearman_size(function) > GEARMAN_FUNCTION_MAX_SIZE) |
112 | 356 | { | 356 | { |
114 | 357 | gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "function name longer then GEARMAN_MAX_FUNCTION_SIZE"); | 357 | gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "function name longer then GEARMAN_MAX_FUNCTION_SIZE"); |
115 | 358 | } | 358 | } |
116 | 359 | else | 359 | else |
117 | 360 | { | 360 | { |
119 | 361 | gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "invalid function"); | 361 | gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "invalid function"); |
120 | 362 | } | 362 | } |
121 | 363 | 363 | ||
122 | 364 | return NULL; | 364 | return NULL; |
123 | @@ -366,21 +366,21 @@ | |||
124 | 366 | 366 | ||
125 | 367 | if (gearman_size(unique) > GEARMAN_MAX_UNIQUE_SIZE) | 367 | if (gearman_size(unique) > GEARMAN_MAX_UNIQUE_SIZE) |
126 | 368 | { | 368 | { |
128 | 369 | gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "unique name longer then GEARMAN_MAX_UNIQUE_SIZE"); | 369 | gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "unique name longer then GEARMAN_MAX_UNIQUE_SIZE"); |
129 | 370 | 370 | ||
130 | 371 | return NULL; | 371 | return NULL; |
131 | 372 | } | 372 | } |
132 | 373 | 373 | ||
133 | 374 | if ((gearman_size(workload) and not gearman_c_str(workload)) or (gearman_size(workload) == 0 && gearman_c_str(workload))) | 374 | if ((gearman_size(workload) and not gearman_c_str(workload)) or (gearman_size(workload) == 0 && gearman_c_str(workload))) |
134 | 375 | { | 375 | { |
136 | 376 | gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "invalid workload"); | 376 | gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "invalid workload"); |
137 | 377 | return NULL; | 377 | return NULL; |
138 | 378 | } | 378 | } |
139 | 379 | 379 | ||
141 | 380 | gearman_task_st *task_shell= gearman_task_internal_create(*client, NULL); | 380 | gearman_task_st *task_shell= gearman_task_internal_create(client, NULL); |
142 | 381 | if (task_shell == NULL) | 381 | if (task_shell == NULL) |
143 | 382 | { | 382 | { |
145 | 383 | assert(client->impl()->universal.error_code()); | 383 | assert(client->universal.error_code()); |
146 | 384 | return NULL; | 384 | return NULL; |
147 | 385 | } | 385 | } |
148 | 386 | 386 | ||
149 | @@ -392,11 +392,11 @@ | |||
150 | 392 | @todo fix it so that NULL is done by default by the API not by happenstance. | 392 | @todo fix it so that NULL is done by default by the API not by happenstance. |
151 | 393 | */ | 393 | */ |
152 | 394 | char function_buffer[1024]; | 394 | char function_buffer[1024]; |
154 | 395 | if (client->impl()->universal._namespace) | 395 | if (client->universal._namespace) |
155 | 396 | { | 396 | { |
156 | 397 | char *ptr= function_buffer; | 397 | char *ptr= function_buffer; |
159 | 398 | memcpy(ptr, gearman_string_value(client->impl()->universal._namespace), gearman_string_length(client->impl()->universal._namespace)); | 398 | memcpy(ptr, gearman_string_value(client->universal._namespace), gearman_string_length(client->universal._namespace)); |
160 | 399 | ptr+= gearman_string_length(client->impl()->universal._namespace); | 399 | ptr+= gearman_string_length(client->universal._namespace); |
161 | 400 | 400 | ||
162 | 401 | memcpy(ptr, gearman_c_str(function), gearman_size(function) +1); | 401 | memcpy(ptr, gearman_c_str(function), gearman_size(function) +1); |
163 | 402 | ptr+= gearman_size(function); | 402 | ptr+= gearman_size(function); |
164 | @@ -426,7 +426,7 @@ | |||
165 | 426 | } | 426 | } |
166 | 427 | else | 427 | else |
167 | 428 | { | 428 | { |
169 | 429 | if (client->impl()->options.generate_unique or is_background(command)) | 429 | if (client->options.generate_unique or is_background(command)) |
170 | 430 | { | 430 | { |
171 | 431 | safe_uuid_generate(task->unique, task->unique_length); | 431 | safe_uuid_generate(task->unique, task->unique_length); |
172 | 432 | } | 432 | } |
173 | @@ -444,11 +444,11 @@ | |||
174 | 444 | "Command was not appropriate for request"); | 444 | "Command was not appropriate for request"); |
175 | 445 | 445 | ||
176 | 446 | char reducer_buffer[1024]; | 446 | char reducer_buffer[1024]; |
178 | 447 | if (client->impl()->universal._namespace) | 447 | if (client->universal._namespace) |
179 | 448 | { | 448 | { |
180 | 449 | char *ptr= reducer_buffer; | 449 | char *ptr= reducer_buffer; |
183 | 450 | memcpy(ptr, gearman_string_value(client->impl()->universal._namespace), gearman_string_length(client->impl()->universal._namespace)); | 450 | memcpy(ptr, gearman_string_value(client->universal._namespace), gearman_string_length(client->universal._namespace)); |
184 | 451 | ptr+= gearman_string_length(client->impl()->universal._namespace); | 451 | ptr+= gearman_string_length(client->universal._namespace); |
185 | 452 | 452 | ||
186 | 453 | memcpy(ptr, gearman_c_str(reducer), gearman_size(reducer) +1); | 453 | memcpy(ptr, gearman_c_str(reducer), gearman_size(reducer) +1); |
187 | 454 | ptr+= gearman_size(reducer); | 454 | ptr+= gearman_size(reducer); |
188 | @@ -473,18 +473,18 @@ | |||
189 | 473 | args_size[4]= gearman_size(workload); | 473 | args_size[4]= gearman_size(workload); |
190 | 474 | 474 | ||
191 | 475 | gearman_return_t rc; | 475 | gearman_return_t rc; |
193 | 476 | if (gearman_success(rc= gearman_packet_create_args(client->impl()->universal, task->send, | 476 | if (gearman_success(rc= gearman_packet_create_args(client->universal, task->send, |
194 | 477 | GEARMAN_MAGIC_REQUEST, command, | 477 | GEARMAN_MAGIC_REQUEST, command, |
195 | 478 | args, args_size, | 478 | args, args_size, |
196 | 479 | 5))) | 479 | 5))) |
197 | 480 | { | 480 | { |
200 | 481 | client->impl()->new_tasks++; | 481 | client->new_tasks++; |
201 | 482 | client->impl()->running_tasks++; | 482 | client->running_tasks++; |
202 | 483 | task->options.send_in_use= true; | 483 | task->options.send_in_use= true; |
203 | 484 | } | 484 | } |
204 | 485 | else | 485 | else |
205 | 486 | { | 486 | { |
207 | 487 | gearman_gerror(client->impl()->universal, rc); | 487 | gearman_gerror(client->universal, rc); |
208 | 488 | gearman_task_free(task); | 488 | gearman_task_free(task); |
209 | 489 | task= NULL; | 489 | task= NULL; |
210 | 490 | } | 490 | } |
211 | 491 | 491 | ||
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 | 42 | 42 | ||
217 | 43 | #pragma once | 43 | #pragma once |
218 | 44 | 44 | ||
220 | 45 | gearman_task_st *add_task(gearman_client_st& client, | 45 | gearman_task_st *add_task(Client& client, |
221 | 46 | void *context, | 46 | void *context, |
222 | 47 | gearman_command_t command, | 47 | gearman_command_t command, |
223 | 48 | const gearman_string_t &function, | 48 | const gearman_string_t &function, |
224 | @@ -51,7 +51,7 @@ | |||
225 | 51 | time_t when, | 51 | time_t when, |
226 | 52 | const gearman_actions_t &actions); | 52 | const gearman_actions_t &actions); |
227 | 53 | 53 | ||
229 | 54 | gearman_task_st *add_task_ptr(gearman_client_st& client, | 54 | gearman_task_st *add_task_ptr(Client& client, |
230 | 55 | gearman_task_st *task, | 55 | gearman_task_st *task, |
231 | 56 | void *context, | 56 | void *context, |
232 | 57 | gearman_command_t command, | 57 | gearman_command_t command, |
233 | @@ -62,7 +62,7 @@ | |||
234 | 62 | gearman_return_t& ret_ptr, | 62 | gearman_return_t& ret_ptr, |
235 | 63 | const gearman_actions_t &actions); | 63 | const gearman_actions_t &actions); |
236 | 64 | 64 | ||
238 | 65 | gearman_task_st *add_task(gearman_client_st& client, | 65 | gearman_task_st *add_task(Client& client, |
239 | 66 | gearman_task_st *task, | 66 | gearman_task_st *task, |
240 | 67 | void *context, | 67 | void *context, |
241 | 68 | gearman_command_t command, | 68 | gearman_command_t command, |
242 | @@ -72,7 +72,7 @@ | |||
243 | 72 | time_t when, | 72 | time_t when, |
244 | 73 | const gearman_actions_t &actions); | 73 | const gearman_actions_t &actions); |
245 | 74 | 74 | ||
247 | 75 | gearman_task_st *add_reducer_task(gearman_client_st *client, | 75 | gearman_task_st *add_reducer_task(Client *client, |
248 | 76 | gearman_command_t command, | 76 | gearman_command_t command, |
249 | 77 | const gearman_job_priority_t priority, | 77 | const gearman_job_priority_t priority, |
250 | 78 | const gearman_string_t &function, | 78 | const gearman_string_t &function, |
251 | 79 | 79 | ||
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 | 125 | gearman_task_st do_task; | 125 | gearman_task_st do_task; |
257 | 126 | { | 126 | { |
258 | 127 | client->universal.options.no_new_data= true; | 127 | client->universal.options.no_new_data= true; |
260 | 128 | gearman_task_st *do_task_ptr= add_task(*(client->shell()), &do_task, NULL, command, | 128 | gearman_task_st *do_task_ptr= add_task(*client, &do_task, NULL, command, |
261 | 129 | function, | 129 | function, |
262 | 130 | local_unique, | 130 | local_unique, |
263 | 131 | workload, | 131 | workload, |
264 | @@ -237,7 +237,7 @@ | |||
265 | 237 | gearman_task_st do_task; | 237 | gearman_task_st do_task; |
266 | 238 | { | 238 | { |
267 | 239 | client->universal.options.no_new_data= true; | 239 | client->universal.options.no_new_data= true; |
269 | 240 | gearman_task_st* do_task_ptr= add_task(*client_shell, &do_task, | 240 | gearman_task_st* do_task_ptr= add_task(*client, &do_task, |
270 | 241 | client, | 241 | client, |
271 | 242 | command, | 242 | command, |
272 | 243 | function, | 243 | function, |
273 | @@ -826,7 +826,7 @@ | |||
274 | 826 | gearman_status_t status; | 826 | gearman_status_t status; |
275 | 827 | gearman_init(status); | 827 | gearman_init(status); |
276 | 828 | 828 | ||
278 | 829 | if (client == NULL) | 829 | if (client == NULL or client->impl() == NULL) |
279 | 830 | { | 830 | { |
280 | 831 | gearman_status_set_return(status, GEARMAN_INVALID_ARGUMENT); | 831 | gearman_status_set_return(status, GEARMAN_INVALID_ARGUMENT); |
281 | 832 | return status; | 832 | return status; |
282 | @@ -889,7 +889,7 @@ | |||
283 | 889 | return status; | 889 | return status; |
284 | 890 | } | 890 | } |
285 | 891 | 891 | ||
287 | 892 | gearman_return_t gearman_client_job_status(gearman_client_st *client, | 892 | gearman_return_t gearman_client_job_status(gearman_client_st *client_shell, |
288 | 893 | const gearman_job_handle_t job_handle, | 893 | const gearman_job_handle_t job_handle, |
289 | 894 | bool *is_known, bool *is_running, | 894 | bool *is_known, bool *is_running, |
290 | 895 | uint32_t *numerator, | 895 | uint32_t *numerator, |
291 | @@ -897,16 +897,18 @@ | |||
292 | 897 | { | 897 | { |
293 | 898 | gearman_return_t ret; | 898 | gearman_return_t ret; |
294 | 899 | 899 | ||
296 | 900 | if (client == NULL) | 900 | if (client_shell == NULL or client_shell->impl() == NULL) |
297 | 901 | { | 901 | { |
298 | 902 | return GEARMAN_INVALID_ARGUMENT; | 902 | return GEARMAN_INVALID_ARGUMENT; |
299 | 903 | } | 903 | } |
300 | 904 | 904 | ||
302 | 905 | client->impl()->universal.reset_error(); | 905 | Client* client= client_shell->impl(); |
303 | 906 | |||
304 | 907 | client->universal.reset_error(); | ||
305 | 906 | 908 | ||
306 | 907 | gearman_task_st do_task; | 909 | gearman_task_st do_task; |
307 | 908 | { | 910 | { |
309 | 909 | gearman_task_st *do_task_ptr= gearman_client_add_task_status(client, &do_task, client, | 911 | gearman_task_st *do_task_ptr= gearman_client_add_task_status(client_shell, &do_task, client, |
310 | 910 | job_handle, &ret); | 912 | job_handle, &ret); |
311 | 911 | if (gearman_failed(ret)) | 913 | if (gearman_failed(ret)) |
312 | 912 | { | 914 | { |
313 | @@ -918,7 +920,7 @@ | |||
314 | 918 | 920 | ||
315 | 919 | gearman_task_clear_fn(&do_task); | 921 | gearman_task_clear_fn(&do_task); |
316 | 920 | 922 | ||
318 | 921 | ret= gearman_client_run_block_tasks(client, &do_task); | 923 | ret= gearman_client_run_block_tasks(client_shell, &do_task); |
319 | 922 | 924 | ||
320 | 923 | // @note we don't know if our task was run or not, we just know something | 925 | // @note we don't know if our task was run or not, we just know something |
321 | 924 | // happened. | 926 | // happened. |
322 | @@ -1049,13 +1051,13 @@ | |||
323 | 1049 | ret_ptr= &unused; | 1051 | ret_ptr= &unused; |
324 | 1050 | } | 1052 | } |
325 | 1051 | 1053 | ||
327 | 1052 | if (client == NULL) | 1054 | if (client == NULL or client->impl() == NULL) |
328 | 1053 | { | 1055 | { |
329 | 1054 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; | 1056 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; |
330 | 1055 | return NULL; | 1057 | return NULL; |
331 | 1056 | } | 1058 | } |
332 | 1057 | 1059 | ||
334 | 1058 | return add_task_ptr(*client, task, | 1060 | return add_task_ptr(*(client->impl()), task, |
335 | 1059 | context, GEARMAN_COMMAND_SUBMIT_JOB, | 1061 | context, GEARMAN_COMMAND_SUBMIT_JOB, |
336 | 1060 | function, | 1062 | function, |
337 | 1061 | unique, | 1063 | unique, |
338 | @@ -1079,13 +1081,13 @@ | |||
339 | 1079 | ret_ptr= &unused; | 1081 | ret_ptr= &unused; |
340 | 1080 | } | 1082 | } |
341 | 1081 | 1083 | ||
343 | 1082 | if (client == NULL) | 1084 | if (client == NULL or client->impl() == NULL) |
344 | 1083 | { | 1085 | { |
345 | 1084 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; | 1086 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; |
346 | 1085 | return NULL; | 1087 | return NULL; |
347 | 1086 | } | 1088 | } |
348 | 1087 | 1089 | ||
350 | 1088 | return add_task_ptr(*client, task, context, | 1090 | return add_task_ptr(*(client->impl()), task, context, |
351 | 1089 | GEARMAN_COMMAND_SUBMIT_JOB_HIGH, | 1091 | GEARMAN_COMMAND_SUBMIT_JOB_HIGH, |
352 | 1090 | function, | 1092 | function, |
353 | 1091 | unique, | 1093 | unique, |
354 | @@ -1109,13 +1111,13 @@ | |||
355 | 1109 | ret_ptr= &unused; | 1111 | ret_ptr= &unused; |
356 | 1110 | } | 1112 | } |
357 | 1111 | 1113 | ||
359 | 1112 | if (client == NULL) | 1114 | if (client == NULL or client->impl() == NULL) |
360 | 1113 | { | 1115 | { |
361 | 1114 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; | 1116 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; |
362 | 1115 | return NULL; | 1117 | return NULL; |
363 | 1116 | } | 1118 | } |
364 | 1117 | 1119 | ||
366 | 1118 | return add_task_ptr(*client, task, context, GEARMAN_COMMAND_SUBMIT_JOB_LOW, | 1120 | return add_task_ptr(*(client->impl()), task, context, GEARMAN_COMMAND_SUBMIT_JOB_LOW, |
367 | 1119 | function, | 1121 | function, |
368 | 1120 | unique, | 1122 | unique, |
369 | 1121 | workload, workload_size, | 1123 | workload, workload_size, |
370 | @@ -1138,13 +1140,13 @@ | |||
371 | 1138 | ret_ptr= &unused; | 1140 | ret_ptr= &unused; |
372 | 1139 | } | 1141 | } |
373 | 1140 | 1142 | ||
375 | 1141 | if (client == NULL) | 1143 | if (client == NULL or client->impl() == NULL) |
376 | 1142 | { | 1144 | { |
377 | 1143 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; | 1145 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; |
378 | 1144 | return NULL; | 1146 | return NULL; |
379 | 1145 | } | 1147 | } |
380 | 1146 | 1148 | ||
382 | 1147 | return add_task_ptr(*client, task, context, GEARMAN_COMMAND_SUBMIT_JOB_BG, | 1149 | return add_task_ptr(*(client->impl()), task, context, GEARMAN_COMMAND_SUBMIT_JOB_BG, |
383 | 1148 | function, | 1150 | function, |
384 | 1149 | unique, | 1151 | unique, |
385 | 1150 | workload, workload_size, | 1152 | workload, workload_size, |
386 | @@ -1168,13 +1170,13 @@ | |||
387 | 1168 | ret_ptr= &unused; | 1170 | ret_ptr= &unused; |
388 | 1169 | } | 1171 | } |
389 | 1170 | 1172 | ||
391 | 1171 | if (client == NULL) | 1173 | if (client == NULL or client->impl() == NULL) |
392 | 1172 | { | 1174 | { |
393 | 1173 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; | 1175 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; |
394 | 1174 | return NULL; | 1176 | return NULL; |
395 | 1175 | } | 1177 | } |
396 | 1176 | 1178 | ||
398 | 1177 | return add_task_ptr(*client, task, context, | 1179 | return add_task_ptr(*(client->impl()), task, context, |
399 | 1178 | GEARMAN_COMMAND_SUBMIT_JOB_HIGH_BG, | 1180 | GEARMAN_COMMAND_SUBMIT_JOB_HIGH_BG, |
400 | 1179 | function, | 1181 | function, |
401 | 1180 | unique, | 1182 | unique, |
402 | @@ -1198,13 +1200,13 @@ | |||
403 | 1198 | ret_ptr= &unused; | 1200 | ret_ptr= &unused; |
404 | 1199 | } | 1201 | } |
405 | 1200 | 1202 | ||
407 | 1201 | if (client == NULL) | 1203 | if (client == NULL or client->impl() == NULL) |
408 | 1202 | { | 1204 | { |
409 | 1203 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; | 1205 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; |
410 | 1204 | return NULL; | 1206 | return NULL; |
411 | 1205 | } | 1207 | } |
412 | 1206 | 1208 | ||
414 | 1207 | return add_task_ptr(*client, task, context, | 1209 | return add_task_ptr(*(client->impl()), task, context, |
415 | 1208 | GEARMAN_COMMAND_SUBMIT_JOB_LOW_BG, | 1210 | GEARMAN_COMMAND_SUBMIT_JOB_LOW_BG, |
416 | 1209 | function, | 1211 | function, |
417 | 1210 | unique, | 1212 | unique, |
418 | @@ -1215,7 +1217,7 @@ | |||
419 | 1215 | 1217 | ||
420 | 1216 | } | 1218 | } |
421 | 1217 | 1219 | ||
423 | 1218 | gearman_task_st *gearman_client_add_task_status(gearman_client_st *client, | 1220 | gearman_task_st *gearman_client_add_task_status(gearman_client_st *client_shell, |
424 | 1219 | gearman_task_st *task_shell, | 1221 | gearman_task_st *task_shell, |
425 | 1220 | void *context, | 1222 | void *context, |
426 | 1221 | const gearman_job_handle_t job_handle, | 1223 | const gearman_job_handle_t job_handle, |
427 | @@ -1230,15 +1232,16 @@ | |||
428 | 1230 | ret_ptr= &unused; | 1232 | ret_ptr= &unused; |
429 | 1231 | } | 1233 | } |
430 | 1232 | 1234 | ||
432 | 1233 | if (client == NULL) | 1235 | if (client_shell == NULL or client_shell->impl() == NULL) |
433 | 1234 | { | 1236 | { |
434 | 1235 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; | 1237 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; |
435 | 1236 | return NULL; | 1238 | return NULL; |
436 | 1237 | } | 1239 | } |
437 | 1240 | Client* client= client_shell->impl(); | ||
438 | 1238 | 1241 | ||
440 | 1239 | if ((task_shell= gearman_task_internal_create(*client, task_shell)) == NULL) | 1242 | if ((task_shell= gearman_task_internal_create(client, task_shell)) == NULL) |
441 | 1240 | { | 1243 | { |
443 | 1241 | *ret_ptr= gearman_client_error_code(client); | 1244 | *ret_ptr= gearman_client_error_code(client_shell); |
444 | 1242 | return NULL; | 1245 | return NULL; |
445 | 1243 | } | 1246 | } |
446 | 1244 | 1247 | ||
447 | @@ -1249,14 +1252,14 @@ | |||
448 | 1249 | 1252 | ||
449 | 1250 | args[0]= job_handle; | 1253 | args[0]= job_handle; |
450 | 1251 | args_size[0]= strlen(job_handle); | 1254 | args_size[0]= strlen(job_handle); |
452 | 1252 | gearman_return_t rc= gearman_packet_create_args(client->impl()->universal, task->send, | 1255 | gearman_return_t rc= gearman_packet_create_args(client->universal, task->send, |
453 | 1253 | GEARMAN_MAGIC_REQUEST, | 1256 | GEARMAN_MAGIC_REQUEST, |
454 | 1254 | GEARMAN_COMMAND_GET_STATUS, | 1257 | GEARMAN_COMMAND_GET_STATUS, |
455 | 1255 | args, args_size, 1); | 1258 | args, args_size, 1); |
456 | 1256 | if (gearman_success(rc)) | 1259 | if (gearman_success(rc)) |
457 | 1257 | { | 1260 | { |
460 | 1258 | client->impl()->new_tasks++; | 1261 | client->new_tasks++; |
461 | 1259 | client->impl()->running_tasks++; | 1262 | client->running_tasks++; |
462 | 1260 | task->options.send_in_use= true; | 1263 | task->options.send_in_use= true; |
463 | 1261 | } | 1264 | } |
464 | 1262 | *ret_ptr= rc; | 1265 | *ret_ptr= rc; |
465 | @@ -1264,7 +1267,7 @@ | |||
466 | 1264 | return task_shell; | 1267 | return task_shell; |
467 | 1265 | } | 1268 | } |
468 | 1266 | 1269 | ||
470 | 1267 | gearman_task_st *gearman_client_add_task_status_by_unique(gearman_client_st *client, | 1270 | gearman_task_st *gearman_client_add_task_status_by_unique(gearman_client_st *client_shell, |
471 | 1268 | gearman_task_st *task_shell, | 1271 | gearman_task_st *task_shell, |
472 | 1269 | const char *unique_handle, | 1272 | const char *unique_handle, |
473 | 1270 | gearman_return_t *ret_ptr) | 1273 | gearman_return_t *ret_ptr) |
474 | @@ -1278,11 +1281,12 @@ | |||
475 | 1278 | ret_ptr= &unused; | 1281 | ret_ptr= &unused; |
476 | 1279 | } | 1282 | } |
477 | 1280 | 1283 | ||
479 | 1281 | if (client == NULL) | 1284 | if (client_shell == NULL or client_shell->impl() == NULL) |
480 | 1282 | { | 1285 | { |
481 | 1283 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; | 1286 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; |
482 | 1284 | return NULL; | 1287 | return NULL; |
483 | 1285 | } | 1288 | } |
484 | 1289 | Client* client= client_shell->impl(); | ||
485 | 1286 | 1290 | ||
486 | 1287 | if (unique_handle == NULL) | 1291 | if (unique_handle == NULL) |
487 | 1288 | { | 1292 | { |
488 | @@ -1297,9 +1301,9 @@ | |||
489 | 1297 | return NULL; | 1301 | return NULL; |
490 | 1298 | } | 1302 | } |
491 | 1299 | 1303 | ||
493 | 1300 | if ((task_shell= gearman_task_internal_create(*client, task_shell)) == NULL) | 1304 | if ((task_shell= gearman_task_internal_create(client, task_shell)) == NULL) |
494 | 1301 | { | 1305 | { |
496 | 1302 | *ret_ptr= gearman_client_error_code(client); | 1306 | *ret_ptr= gearman_client_error_code(client_shell); |
497 | 1303 | return NULL; | 1307 | return NULL; |
498 | 1304 | } | 1308 | } |
499 | 1305 | 1309 | ||
500 | @@ -1311,14 +1315,14 @@ | |||
501 | 1311 | 1315 | ||
502 | 1312 | args[0]= task->unique; | 1316 | args[0]= task->unique; |
503 | 1313 | args_size[0]= task->unique_length; | 1317 | args_size[0]= task->unique_length; |
505 | 1314 | gearman_return_t rc= gearman_packet_create_args(client->impl()->universal, task->send, | 1318 | gearman_return_t rc= gearman_packet_create_args(client->universal, task->send, |
506 | 1315 | GEARMAN_MAGIC_REQUEST, | 1319 | GEARMAN_MAGIC_REQUEST, |
507 | 1316 | GEARMAN_COMMAND_GET_STATUS_UNIQUE, | 1320 | GEARMAN_COMMAND_GET_STATUS_UNIQUE, |
508 | 1317 | args, args_size, 1); | 1321 | args, args_size, 1); |
509 | 1318 | if (gearman_success(rc)) | 1322 | if (gearman_success(rc)) |
510 | 1319 | { | 1323 | { |
513 | 1320 | client->impl()->new_tasks++; | 1324 | client->new_tasks++; |
514 | 1321 | client->impl()->running_tasks++; | 1325 | client->running_tasks++; |
515 | 1322 | task->options.send_in_use= true; | 1326 | task->options.send_in_use= true; |
516 | 1323 | } | 1327 | } |
517 | 1324 | *ret_ptr= rc; | 1328 | *ret_ptr= rc; |
518 | 1325 | 1329 | ||
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 | 71 | ret_ptr= &unused; | 71 | ret_ptr= &unused; |
524 | 72 | } | 72 | } |
525 | 73 | 73 | ||
527 | 74 | if (client == NULL) | 74 | if (client == NULL or client->impl() == NULL) |
528 | 75 | { | 75 | { |
529 | 76 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; | 76 | *ret_ptr= GEARMAN_INVALID_ARGUMENT; |
530 | 77 | return NULL; | 77 | return NULL; |
531 | 78 | } | 78 | } |
532 | 79 | 79 | ||
533 | 80 | { | 80 | { |
535 | 81 | gearman_task_st *do_task_ptr= add_task(*client, &do_task, NULL, command, | 81 | gearman_task_st *do_task_ptr= add_task(*(client->impl()), &do_task, NULL, command, |
536 | 82 | function, | 82 | function, |
537 | 83 | local_unique, | 83 | local_unique, |
538 | 84 | workload, | 84 | workload, |
539 | @@ -144,14 +144,14 @@ | |||
540 | 144 | gearman_string_t &workload, | 144 | gearman_string_t &workload, |
541 | 145 | gearman_job_handle_t job_handle) | 145 | gearman_job_handle_t job_handle) |
542 | 146 | { | 146 | { |
544 | 147 | if (client == NULL) | 147 | if (client == NULL or client->impl() == NULL) |
545 | 148 | { | 148 | { |
546 | 149 | return GEARMAN_INVALID_ARGUMENT; | 149 | return GEARMAN_INVALID_ARGUMENT; |
547 | 150 | } | 150 | } |
548 | 151 | 151 | ||
549 | 152 | gearman_task_st do_task; | 152 | gearman_task_st do_task; |
550 | 153 | { | 153 | { |
552 | 154 | gearman_task_st *do_task_ptr= add_task(*client, &do_task, | 154 | gearman_task_st *do_task_ptr= add_task(*(client->impl()), &do_task, |
553 | 155 | client, | 155 | client, |
554 | 156 | command, | 156 | command, |
555 | 157 | function, | 157 | function, |
556 | 158 | 158 | ||
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 | 70 | 70 | ||
562 | 71 | 71 | ||
563 | 72 | 72 | ||
565 | 73 | gearman_task_st *gearman_execute(gearman_client_st *client, | 73 | gearman_task_st *gearman_execute(gearman_client_st *client_shell, |
566 | 74 | const char *function_name, size_t function_length, | 74 | const char *function_name, size_t function_length, |
567 | 75 | const char *unique_str, size_t unique_length, | 75 | const char *unique_str, size_t unique_length, |
568 | 76 | gearman_task_attr_t *task_attr, | 76 | gearman_task_attr_t *task_attr, |
569 | 77 | gearman_argument_t *arguments, | 77 | gearman_argument_t *arguments, |
570 | 78 | void *context) | 78 | void *context) |
571 | 79 | { | 79 | { |
573 | 80 | if (client == NULL) | 80 | if (client_shell == NULL or client_shell->impl() == NULL) |
574 | 81 | { | 81 | { |
575 | 82 | return NULL; | 82 | return NULL; |
576 | 83 | } | 83 | } |
577 | 84 | 84 | ||
578 | 85 | Client* client= client_shell->impl(); | ||
579 | 86 | |||
580 | 85 | gearman_argument_t null_arg= gearman_argument_make(0, 0, 0, 0); | 87 | gearman_argument_t null_arg= gearman_argument_make(0, 0, 0, 0); |
581 | 86 | if (arguments == NULL) | 88 | if (arguments == NULL) |
582 | 87 | { | 89 | { |
583 | @@ -90,7 +92,7 @@ | |||
584 | 90 | 92 | ||
585 | 91 | if (function_name == NULL or function_length == 0) | 93 | if (function_name == NULL or function_length == 0) |
586 | 92 | { | 94 | { |
588 | 93 | gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "function_name was NULL"); | 95 | gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "function_name was NULL"); |
589 | 94 | return NULL; | 96 | return NULL; |
590 | 95 | } | 97 | } |
591 | 96 | gearman_string_t function= { function_name, function_length }; | 98 | gearman_string_t function= { function_name, function_length }; |
592 | @@ -149,18 +151,18 @@ | |||
593 | 149 | 151 | ||
594 | 150 | if (task == NULL) | 152 | if (task == NULL) |
595 | 151 | { | 153 | { |
597 | 152 | gearman_universal_error_code(client->impl()->universal); | 154 | gearman_universal_error_code(client->universal); |
598 | 153 | 155 | ||
599 | 154 | return NULL; | 156 | return NULL; |
600 | 155 | } | 157 | } |
601 | 156 | 158 | ||
602 | 157 | task->impl()->type= GEARMAN_TASK_KIND_EXECUTE; | 159 | task->impl()->type= GEARMAN_TASK_KIND_EXECUTE; |
604 | 158 | gearman_client_run_tasks(client); | 160 | gearman_client_run_tasks(client->shell()); |
605 | 159 | 161 | ||
606 | 160 | return task; | 162 | return task; |
607 | 161 | } | 163 | } |
608 | 162 | 164 | ||
610 | 163 | gearman_task_st *gearman_execute_by_partition(gearman_client_st *client, | 165 | gearman_task_st *gearman_execute_by_partition(gearman_client_st *client_shell, |
611 | 164 | const char *partition_function, const size_t partition_function_length, | 166 | const char *partition_function, const size_t partition_function_length, |
612 | 165 | const char *function_name, const size_t function_name_length, | 167 | const char *function_name, const size_t function_name_length, |
613 | 166 | const char *unique_str, const size_t unique_length, | 168 | const char *unique_str, const size_t unique_length, |
614 | @@ -168,25 +170,27 @@ | |||
615 | 168 | gearman_argument_t *arguments, | 170 | gearman_argument_t *arguments, |
616 | 169 | void *context) | 171 | void *context) |
617 | 170 | { | 172 | { |
619 | 171 | if (client == NULL) | 173 | if (client_shell == NULL or client_shell->impl() == NULL) |
620 | 172 | { | 174 | { |
621 | 173 | errno= EINVAL; | 175 | errno= EINVAL; |
622 | 174 | return NULL; | 176 | return NULL; |
623 | 175 | } | 177 | } |
624 | 176 | 178 | ||
625 | 179 | Client* client= client_shell->impl(); | ||
626 | 180 | |||
627 | 177 | if ((partition_function == NULL) or (partition_function_length == 0)) | 181 | if ((partition_function == NULL) or (partition_function_length == 0)) |
628 | 178 | { | 182 | { |
630 | 179 | gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "partition_function was NULL"); | 183 | gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "partition_function was NULL"); |
631 | 180 | return NULL; | 184 | return NULL; |
632 | 181 | } | 185 | } |
633 | 182 | 186 | ||
634 | 183 | if ((function_name == NULL) or (function_name_length == 0)) | 187 | if ((function_name == NULL) or (function_name_length == 0)) |
635 | 184 | { | 188 | { |
637 | 185 | gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "function_name was NULL"); | 189 | gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "function_name was NULL"); |
638 | 186 | return NULL; | 190 | return NULL; |
639 | 187 | } | 191 | } |
640 | 188 | 192 | ||
642 | 189 | universal_reset_error(client->impl()->universal); | 193 | universal_reset_error(client->universal); |
643 | 190 | 194 | ||
644 | 191 | gearman_task_st *task= NULL; | 195 | gearman_task_st *task= NULL; |
645 | 192 | gearman_string_t partition= { partition_function, partition_function_length }; | 196 | gearman_string_t partition= { partition_function, partition_function_length }; |
646 | @@ -211,7 +215,7 @@ | |||
647 | 211 | break; | 215 | break; |
648 | 212 | 216 | ||
649 | 213 | case GEARMAN_TASK_ATTR_EPOCH: | 217 | case GEARMAN_TASK_ATTR_EPOCH: |
651 | 214 | gearman_error(client->impl()->universal, GEARMAN_INVALID_ARGUMENT, "EPOCH is not currently supported for gearman_client_execute_reduce()"); | 218 | gearman_error(client->universal, GEARMAN_INVALID_ARGUMENT, "EPOCH is not currently supported for gearman_client_execute_reduce()"); |
652 | 215 | return NULL; | 219 | return NULL; |
653 | 216 | #if 0 | 220 | #if 0 |
654 | 217 | task= add_task(client, | 221 | task= add_task(client, |
655 | @@ -262,9 +266,9 @@ | |||
656 | 262 | 266 | ||
657 | 263 | do { | 267 | do { |
658 | 264 | gearman_return_t rc; | 268 | gearman_return_t rc; |
660 | 265 | if (gearman_failed(rc= gearman_client_run_tasks(client))) | 269 | if (gearman_failed(rc= gearman_client_run_tasks(client->shell()))) |
661 | 266 | { | 270 | { |
663 | 267 | gearman_gerror(client->impl()->universal, rc); | 271 | gearman_gerror(client->universal, rc); |
664 | 268 | gearman_task_free(task); | 272 | gearman_task_free(task); |
665 | 269 | return NULL; | 273 | return NULL; |
666 | 270 | } | 274 | } |
667 | 271 | 275 | ||
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 | 89 | return _shell; | 89 | return _shell; |
673 | 90 | } | 90 | } |
674 | 91 | 91 | ||
676 | 92 | Task(gearman_client_st& client_, gearman_task_st* shell_) : | 92 | Task(Client* client_, gearman_task_st* shell_) : |
677 | 93 | type(GEARMAN_TASK_KIND_ADD_TASK), | 93 | type(GEARMAN_TASK_KIND_ADD_TASK), |
678 | 94 | state(GEARMAN_TASK_STATE_NEW), | 94 | state(GEARMAN_TASK_STATE_NEW), |
679 | 95 | magic_(TASK_MAGIC), | 95 | magic_(TASK_MAGIC), |
680 | @@ -97,13 +97,13 @@ | |||
681 | 97 | numerator(0), | 97 | numerator(0), |
682 | 98 | denominator(0), | 98 | denominator(0), |
683 | 99 | client_count(0), | 99 | client_count(0), |
685 | 100 | client(client_.impl()), | 100 | client(client_), |
686 | 101 | next(NULL), | 101 | next(NULL), |
687 | 102 | prev(NULL), | 102 | prev(NULL), |
688 | 103 | context(NULL), | 103 | context(NULL), |
689 | 104 | con(NULL), | 104 | con(NULL), |
690 | 105 | recv(NULL), | 105 | recv(NULL), |
692 | 106 | func(client_.impl()->actions), | 106 | func(client_->actions), |
693 | 107 | result_rc(GEARMAN_UNKNOWN_STATE), | 107 | result_rc(GEARMAN_UNKNOWN_STATE), |
694 | 108 | _result_ptr(NULL), | 108 | _result_ptr(NULL), |
695 | 109 | unique_length(0), | 109 | unique_length(0), |
696 | @@ -125,14 +125,14 @@ | |||
697 | 125 | 125 | ||
698 | 126 | // Add the task to the client | 126 | // Add the task to the client |
699 | 127 | { | 127 | { |
701 | 128 | if (client_.impl()->task_list) | 128 | if (client_->task_list) |
702 | 129 | { | 129 | { |
704 | 130 | client_.impl()->task_list->impl()->prev= _shell; | 130 | client_->task_list->impl()->prev= _shell; |
705 | 131 | } | 131 | } |
707 | 132 | next= client_.impl()->task_list; | 132 | next= client_->task_list; |
708 | 133 | prev= NULL; | 133 | prev= NULL; |
711 | 134 | client_.impl()->task_list= _shell; | 134 | client_->task_list= _shell; |
712 | 135 | client_.impl()->task_count++; | 135 | client_->task_count++; |
713 | 136 | } | 136 | } |
714 | 137 | 137 | ||
715 | 138 | _shell->impl(this); | 138 | _shell->impl(this); |
716 | 139 | 139 | ||
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 | 77 | bool init() | 77 | bool init() |
722 | 78 | { | 78 | { |
723 | 79 | client= gearman_client_create(NULL); | 79 | client= gearman_client_create(NULL); |
745 | 80 | if (not client) | 80 | if (client) |
746 | 81 | { | 81 | { |
747 | 82 | return false; | 82 | |
748 | 83 | } | 83 | if (universal._namespace) |
749 | 84 | 84 | { | |
750 | 85 | if (universal._namespace) | 85 | gearman_client_set_namespace(client, |
751 | 86 | { | 86 | gearman_string_value(universal._namespace), |
752 | 87 | gearman_client_set_namespace(client, | 87 | gearman_string_length(universal._namespace)); |
753 | 88 | gearman_string_value(universal._namespace), | 88 | } |
754 | 89 | gearman_string_length(universal._namespace)); | 89 | |
755 | 90 | } | 90 | for (gearman_connection_st *con= universal.con_list; con; con= con->next_connection()) |
756 | 91 | 91 | { | |
757 | 92 | for (gearman_connection_st *con= universal.con_list; con; con= con->next_connection()) | 92 | if (gearman_failed(client->impl()->add_server(con->_host, con->_service))) |
758 | 93 | { | 93 | { |
759 | 94 | if (gearman_failed(client->impl()->add_server(con->_host, con->_service))) | 94 | return false; |
760 | 95 | { | 95 | } |
761 | 96 | return false; | 96 | } |
762 | 97 | } | 97 | |
763 | 98 | } | 98 | return true; |
764 | 99 | 99 | } | |
765 | 100 | return true; | 100 | |
766 | 101 | return false; | ||
767 | 101 | } | 102 | } |
768 | 102 | 103 | ||
769 | 103 | bool add(gearman_argument_t &arguments) | 104 | bool add(gearman_argument_t &arguments) |
770 | 104 | { | 105 | { |
771 | 105 | gearman_string_t function= gearman_string(reducer_function); | 106 | gearman_string_t function= gearman_string(reducer_function); |
772 | 106 | gearman_unique_t unique= gearman_unique_make(0, 0); | 107 | gearman_unique_t unique= gearman_unique_make(0, 0); |
774 | 107 | gearman_task_st *task= add_task(*client, | 108 | gearman_task_st *task= add_task(*(client->impl()), |
775 | 108 | NULL, | 109 | NULL, |
776 | 109 | GEARMAN_COMMAND_SUBMIT_JOB, | 110 | GEARMAN_COMMAND_SUBMIT_JOB, |
777 | 110 | function, | 111 | function, |
778 | 111 | 112 | ||
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 | 54 | * Public Definitions | 54 | * Public Definitions |
784 | 55 | */ | 55 | */ |
785 | 56 | 56 | ||
787 | 57 | gearman_task_st *gearman_task_internal_create(gearman_client_st& client, gearman_task_st *task_shell) | 57 | gearman_task_st *gearman_task_internal_create(Client* client, gearman_task_st *task_shell) |
788 | 58 | { | 58 | { |
789 | 59 | Task* task= new (std::nothrow) Task(client, task_shell); | 59 | Task* task= new (std::nothrow) Task(client, task_shell); |
790 | 60 | if (task) | 60 | if (task) |
791 | @@ -62,7 +62,7 @@ | |||
792 | 62 | return task->shell(); | 62 | return task->shell(); |
793 | 63 | } | 63 | } |
794 | 64 | 64 | ||
796 | 65 | gearman_perror(client.impl()->universal, "gearman_task_st new"); | 65 | gearman_perror(client->universal, "gearman_task_st new"); |
797 | 66 | gearman_task_free(task_shell); | 66 | gearman_task_free(task_shell); |
798 | 67 | 67 | ||
799 | 68 | return NULL; | 68 | return NULL; |
800 | 69 | 69 | ||
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 | 46 | * @return On success, a pointer to the (possibly allocated) structure. On | 46 | * @return On success, a pointer to the (possibly allocated) structure. On |
806 | 47 | * failure this will be NULL. | 47 | * failure this will be NULL. |
807 | 48 | */ | 48 | */ |
809 | 49 | gearman_task_st *gearman_task_internal_create(gearman_client_st& client, | 49 | gearman_task_st *gearman_task_internal_create(Client* client, |
810 | 50 | gearman_task_st *task); | 50 | gearman_task_st *task); |
811 | 51 | 51 | ||
812 | 52 | void gearman_task_free(Task* task); | 52 | void gearman_task_free(Task* task); |