Status: | Superseded | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Proposed branch: | lp:~eday/gearmand/fixes | ||||||||||||||||||||||||||||
Merge into: | lp:gearmand/1.0 | ||||||||||||||||||||||||||||
Diff against target: |
4072 lines 67 files modified
ChangeLog (+8/-0) benchmark/blobslap_worker.c (+5/-5) bin/gearman.c (+5/-5) configure.ac (+3/-3) docs/Doxyfile.api (+32/-4) docs/Doxyfile.dev (+31/-1) examples/reverse_worker.c (+5/-5) examples/wc_worker.c (+3/-3) gearmand/gearmand.c (+7/-0) libgearman-server/client.h (+4/-2) libgearman-server/common.h (+5/-3) libgearman-server/conf.h (+3/-2) libgearman-server/conf_module.h (+3/-2) libgearman-server/conn.c (+1/-1) libgearman-server/conn.h (+4/-2) libgearman-server/constants.h (+31/-19) libgearman-server/function.h (+4/-2) libgearman-server/gearmand.c (+5/-0) libgearman-server/gearmand.h (+13/-2) libgearman-server/gearmand_con.c (+2/-2) libgearman-server/gearmand_con.h (+6/-3) libgearman-server/gearmand_thread.h (+5/-2) libgearman-server/job.c (+24/-13) libgearman-server/job.h (+4/-2) libgearman-server/packet.c (+2/-2) libgearman-server/packet.h (+4/-2) libgearman-server/protocol_http.c (+7/-10) libgearman-server/protocol_http.h (+6/-2) libgearman-server/queue_libdrizzle.c (+4/-8) libgearman-server/queue_libdrizzle.h (+2/-2) libgearman-server/queue_libmemcached.c (+4/-8) libgearman-server/queue_libmemcached.h (+2/-2) libgearman-server/queue_libpq.c (+4/-8) libgearman-server/queue_libpq.h (+2/-2) libgearman-server/queue_libsqlite3.c (+4/-8) libgearman-server/queue_libsqlite3.h (+2/-2) libgearman-server/server.c (+9/-2) libgearman-server/server.h (+13/-1) libgearman-server/structs.h (+2/-1) libgearman-server/thread.c (+1/-1) libgearman-server/thread.h (+5/-2) libgearman-server/worker.c (+28/-2) libgearman-server/worker.h (+4/-2) libgearman/Makefile.am (+2/-1) libgearman/client.c (+64/-41) libgearman/client.h (+5/-4) libgearman/common.h (+2/-30) libgearman/conn.c (+52/-53) libgearman/conn.h (+5/-2) libgearman/constants.h (+20/-13) libgearman/gearman.c (+94/-91) libgearman/gearman.h (+45/-33) libgearman/gearman_local.h (+150/-0) libgearman/job.c (+64/-36) libgearman/job.h (+4/-2) libgearman/packet.c (+9/-13) libgearman/packet.h (+5/-2) libgearman/structs.h (+1/-1) libgearman/task.c (+2/-2) libgearman/task.h (+4/-2) libgearman/visibility.h (+4/-2) libgearman/worker.c (+63/-54) libgearman/worker.h (+3/-2) tests/client_test.c (+7/-6) tests/memcached_test.c (+1/-2) tests/sqlite_test.c (+1/-2) tests/worker_test.c (+80/-70) |
||||||||||||||||||||||||||||
To merge this branch: | bzr merge lp:~eday/gearmand/fixes | ||||||||||||||||||||||||||||
Related bugs: |
|
||||||||||||||||||||||||||||
Related blueprints: |
Rework the worker library code for durability
(Undefined)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gearman-developers | Pending | ||
Review via email: mp+14235@code.launchpad.net |
This proposal has been superseded by a proposal from 2009-11-04.
Commit message
Description of the change
To post a comment you must log in.
lp:~eday/gearmand/fixes
updated
- 251. By Eric Day
-
Removed va_args packet add function, replaced with array passing.
- 252. By Eric Day
-
Merged trunk.
- 253. By Eric Day
-
Updated ChangeLog
- 254. By Eric Day
-
Small fixes for release while working with Monty on packaging.
- 255. By Eric Day
-
Fixed job handle compare for work_fail bug, added test case.
- 256. By Eric Day
-
Merged Monty's build fixes.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2009-09-28 17:47:34 +0000 | |||
3 | +++ ChangeLog 2009-11-04 22:14:13 +0000 | |||
4 | @@ -1,3 +1,11 @@ | |||
5 | 1 | 0.11 - 2009-11-03 | ||
6 | 2 | * Added max wakeup-worker option to gearmand. Default is still to wakeup all. | ||
7 | 3 | * API and documentation cleanup. | ||
8 | 4 | * Fixed bug where task context free function was getting called for do() | ||
9 | 5 | functions. This was PECL/Gearman bug #16899 as well. | ||
10 | 6 | * Fixed bug #458912, not flushing with multiple gearmands in client. | ||
11 | 7 | * Fixed PECL/Gearman bug #16847, was actually in C library and not in PHP. | ||
12 | 8 | |||
13 | 1 | 0.10 - 2009-09-28 | 9 | 0.10 - 2009-09-28 |
14 | 2 | * Added timeout option. | 10 | * Added timeout option. |
15 | 3 | * Separated libgearman client/worker library from the server/gearmand code. | 11 | * Separated libgearman client/worker library from the server/gearmand code. |
16 | 4 | 12 | ||
17 | === modified file 'benchmark/blobslap_worker.c' | |||
18 | --- benchmark/blobslap_worker.c 2009-06-14 07:26:30 +0000 | |||
19 | +++ benchmark/blobslap_worker.c 2009-11-04 22:14:13 +0000 | |||
20 | @@ -13,8 +13,8 @@ | |||
21 | 13 | 13 | ||
22 | 14 | #include "benchmark.h" | 14 | #include "benchmark.h" |
23 | 15 | 15 | ||
26 | 16 | static void *worker_fn(gearman_job_st *job, void *cb_arg, size_t *result_size, | 16 | static void *worker_fn(gearman_job_st *job, void *context, |
27 | 17 | gearman_return_t *ret_ptr); | 17 | size_t *result_size, gearman_return_t *ret_ptr); |
28 | 18 | 18 | ||
29 | 19 | static void usage(char *name); | 19 | static void usage(char *name); |
30 | 20 | 20 | ||
31 | @@ -130,10 +130,10 @@ | |||
32 | 130 | return 0; | 130 | return 0; |
33 | 131 | } | 131 | } |
34 | 132 | 132 | ||
37 | 133 | static void *worker_fn(gearman_job_st *job, void *cb_arg, size_t *result_size, | 133 | static void *worker_fn(gearman_job_st *job, void *context, |
38 | 134 | gearman_return_t *ret_ptr) | 134 | size_t *result_size, gearman_return_t *ret_ptr) |
39 | 135 | { | 135 | { |
41 | 136 | gearman_benchmark_st *benchmark= (gearman_benchmark_st *)cb_arg; | 136 | gearman_benchmark_st *benchmark= (gearman_benchmark_st *)context; |
42 | 137 | 137 | ||
43 | 138 | (void)result_size; | 138 | (void)result_size; |
44 | 139 | 139 | ||
45 | 140 | 140 | ||
46 | === modified file 'bin/gearman.c' | |||
47 | --- bin/gearman.c 2009-09-28 17:47:34 +0000 | |||
48 | +++ bin/gearman.c 2009-11-04 22:14:13 +0000 | |||
49 | @@ -92,8 +92,8 @@ | |||
50 | 92 | /** | 92 | /** |
51 | 93 | * Callback function when worker gets a job. | 93 | * Callback function when worker gets a job. |
52 | 94 | */ | 94 | */ |
55 | 95 | static void *_worker_cb(gearman_job_st *job, void *cb_arg, size_t *result_size, | 95 | static void *_worker_cb(gearman_job_st *job, void *context, |
56 | 96 | gearman_return_t *ret_ptr); | 96 | size_t *result_size, gearman_return_t *ret_ptr); |
57 | 97 | 97 | ||
58 | 98 | /** | 98 | /** |
59 | 99 | * Read workload chunk from a file descriptor and put into allocated memory. | 99 | * Read workload chunk from a file descriptor and put into allocated memory. |
60 | @@ -460,10 +460,10 @@ | |||
61 | 460 | gearman_worker_free(&worker); | 460 | gearman_worker_free(&worker); |
62 | 461 | } | 461 | } |
63 | 462 | 462 | ||
66 | 463 | static void *_worker_cb(gearman_job_st *job, void *cb_arg, size_t *result_size, | 463 | static void *_worker_cb(gearman_job_st *job, void *context, |
67 | 464 | gearman_return_t *ret_ptr) | 464 | size_t *result_size, gearman_return_t *ret_ptr) |
68 | 465 | { | 465 | { |
70 | 466 | gearman_args_st *args= (gearman_args_st *)cb_arg; | 466 | gearman_args_st *args= (gearman_args_st *)context; |
71 | 467 | int in_fds[2]; | 467 | int in_fds[2]; |
72 | 468 | int out_fds[2]; | 468 | int out_fds[2]; |
73 | 469 | char *result= NULL; | 469 | char *result= NULL; |
74 | 470 | 470 | ||
75 | === modified file 'configure.ac' | |||
76 | --- configure.ac 2009-09-30 06:07:17 +0000 | |||
77 | +++ configure.ac 2009-11-04 22:14:13 +0000 | |||
78 | @@ -6,7 +6,7 @@ | |||
79 | 6 | # the COPYING file in this directory for full text. | 6 | # the COPYING file in this directory for full text. |
80 | 7 | 7 | ||
81 | 8 | AC_PREREQ(2.59) | 8 | AC_PREREQ(2.59) |
83 | 9 | AC_INIT([gearmand],[0.10],[https://launchpad.net/gearmand]) | 9 | AC_INIT([gearmand],[0.11],[https://launchpad.net/gearmand]) |
84 | 10 | AC_CONFIG_SRCDIR(libgearman/gearman.c) | 10 | AC_CONFIG_SRCDIR(libgearman/gearman.c) |
85 | 11 | AC_CONFIG_AUX_DIR(config) | 11 | AC_CONFIG_AUX_DIR(config) |
86 | 12 | AC_CONFIG_HEADERS([config.h]) | 12 | AC_CONFIG_HEADERS([config.h]) |
87 | @@ -14,7 +14,7 @@ | |||
88 | 14 | 14 | ||
89 | 15 | PANDORA_CANONICAL_TARGET(require-cxx) | 15 | PANDORA_CANONICAL_TARGET(require-cxx) |
90 | 16 | 16 | ||
92 | 17 | GEARMAN_LIBRARY_VERSION=2:0:0 | 17 | GEARMAN_LIBRARY_VERSION=2:1:0 |
93 | 18 | # | | | | 18 | # | | | |
94 | 19 | # +------+ | +---+ | 19 | # +------+ | +---+ |
95 | 20 | # | | | | 20 | # | | | |
96 | @@ -28,7 +28,7 @@ | |||
97 | 28 | # +- increment if interfaces have been added, removed or changed | 28 | # +- increment if interfaces have been added, removed or changed |
98 | 29 | AC_SUBST(GEARMAN_LIBRARY_VERSION) | 29 | AC_SUBST(GEARMAN_LIBRARY_VERSION) |
99 | 30 | 30 | ||
101 | 31 | GEARMAN_SERVER_LIBRARY_VERSION=0:0:0 | 31 | GEARMAN_SERVER_LIBRARY_VERSION=0:1:0 |
102 | 32 | # | | | | 32 | # | | | |
103 | 33 | # +------+ | +---+ | 33 | # +------+ | +---+ |
104 | 34 | # | | | | 34 | # | | | |
105 | 35 | 35 | ||
106 | === modified file 'docs/Doxyfile.api' | |||
107 | --- docs/Doxyfile.api 2009-09-25 00:04:06 +0000 | |||
108 | +++ docs/Doxyfile.api 2009-11-04 22:14:13 +0000 | |||
109 | @@ -534,7 +534,35 @@ | |||
110 | 534 | # directories like "/usr/src/myproject". Separate the files or directories | 534 | # directories like "/usr/src/myproject". Separate the files or directories |
111 | 535 | # with spaces. | 535 | # with spaces. |
112 | 536 | 536 | ||
114 | 537 | INPUT = docs libgearman libgearman-server examples examples/reverse_client.c examples/reverse_client_bg.c examples/reverse_client_cb.c examples/reverse_worker.c | 537 | INPUT = docs/doxygen.h \ |
115 | 538 | libgearman/constants.h \ | ||
116 | 539 | libgearman/client.h \ | ||
117 | 540 | libgearman/task.h \ | ||
118 | 541 | libgearman/worker.h \ | ||
119 | 542 | libgearman/job.h \ | ||
120 | 543 | libgearman/gearman.h \ | ||
121 | 544 | libgearman/conn.h \ | ||
122 | 545 | libgearman/packet.h \ | ||
123 | 546 | libgearman-server/constants.h \ | ||
124 | 547 | libgearman-server/client.h \ | ||
125 | 548 | libgearman-server/conf.h \ | ||
126 | 549 | libgearman-server/conf_module.h \ | ||
127 | 550 | libgearman-server/conn.h \ | ||
128 | 551 | libgearman-server/function.h \ | ||
129 | 552 | libgearman-server/job.h \ | ||
130 | 553 | libgearman-server/packet.h \ | ||
131 | 554 | libgearman-server/server.h \ | ||
132 | 555 | libgearman-server/thread.h \ | ||
133 | 556 | libgearman-server/worker.h \ | ||
134 | 557 | libgearman-server/protocol_http.h \ | ||
135 | 558 | libgearman-server/queue_libdrizzle.h \ | ||
136 | 559 | libgearman-server/queue_libmemcached.h \ | ||
137 | 560 | libgearman-server/queue_libpq.h \ | ||
138 | 561 | libgearman-server/queue_libsqlite3.h \ | ||
139 | 562 | libgearman-server/gearmand.h \ | ||
140 | 563 | libgearman-server/gearmand_con.h \ | ||
141 | 564 | libgearman-server/gearmand_thread.h \ | ||
142 | 565 | examples | ||
143 | 538 | 566 | ||
144 | 539 | # This tag can be used to specify the character encoding of the source files | 567 | # This tag can be used to specify the character encoding of the source files |
145 | 540 | # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is | 568 | # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is |
146 | @@ -551,7 +579,7 @@ | |||
147 | 551 | # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx | 579 | # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx |
148 | 552 | # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 | 580 | # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 |
149 | 553 | 581 | ||
151 | 554 | FILE_PATTERNS = *.h | 582 | FILE_PATTERNS = *.h *.c |
152 | 555 | 583 | ||
153 | 556 | # The RECURSIVE tag can be used to turn specify whether or not subdirectories | 584 | # The RECURSIVE tag can be used to turn specify whether or not subdirectories |
154 | 557 | # should be searched for input files as well. Possible values are YES and NO. | 585 | # should be searched for input files as well. Possible values are YES and NO. |
155 | @@ -563,7 +591,7 @@ | |||
156 | 563 | # excluded from the INPUT source files. This way you can easily exclude a | 591 | # excluded from the INPUT source files. This way you can easily exclude a |
157 | 564 | # subdirectory from a directory tree whose root is specified with the INPUT tag. | 592 | # subdirectory from a directory tree whose root is specified with the INPUT tag. |
158 | 565 | 593 | ||
160 | 566 | EXCLUDE = libgearman/common.h libgearman/structs.h libgearman-server/common.h libgearman-server/structs.h | 594 | EXCLUDE = |
161 | 567 | 595 | ||
162 | 568 | # The EXCLUDE_SYMLINKS tag can be used select whether or not files or | 596 | # The EXCLUDE_SYMLINKS tag can be used select whether or not files or |
163 | 569 | # directories that are symbolic links (a Unix filesystem feature) are excluded | 597 | # directories that are symbolic links (a Unix filesystem feature) are excluded |
164 | @@ -747,7 +775,7 @@ | |||
165 | 747 | # each generated HTML page. If it is left blank doxygen will generate a | 775 | # each generated HTML page. If it is left blank doxygen will generate a |
166 | 748 | # standard footer. | 776 | # standard footer. |
167 | 749 | 777 | ||
169 | 750 | HTML_FOOTER = | 778 | HTML_FOOTER = |
170 | 751 | 779 | ||
171 | 752 | # The HTML_STYLESHEET tag can be used to specify a user-defined cascading | 780 | # The HTML_STYLESHEET tag can be used to specify a user-defined cascading |
172 | 753 | # style sheet that is used by each HTML page. It can be used to | 781 | # style sheet that is used by each HTML page. It can be used to |
173 | 754 | 782 | ||
174 | === modified file 'docs/Doxyfile.dev' | |||
175 | --- docs/Doxyfile.dev 2009-09-25 00:04:06 +0000 | |||
176 | +++ docs/Doxyfile.dev 2009-11-04 22:14:13 +0000 | |||
177 | @@ -534,7 +534,37 @@ | |||
178 | 534 | # directories like "/usr/src/myproject". Separate the files or directories | 534 | # directories like "/usr/src/myproject". Separate the files or directories |
179 | 535 | # with spaces. | 535 | # with spaces. |
180 | 536 | 536 | ||
182 | 537 | INPUT = docs libgearman libgearman-server examples | 537 | INPUT = docs/doxygen.h \ |
183 | 538 | libgearman/constants.h \ | ||
184 | 539 | libgearman/client.h \ | ||
185 | 540 | libgearman/task.h \ | ||
186 | 541 | libgearman/worker.h \ | ||
187 | 542 | libgearman/job.h \ | ||
188 | 543 | libgearman/gearman.h \ | ||
189 | 544 | libgearman/conn.h \ | ||
190 | 545 | libgearman/packet.h \ | ||
191 | 546 | libgearman \ | ||
192 | 547 | libgearman-server/constants.h \ | ||
193 | 548 | libgearman-server/client.h \ | ||
194 | 549 | libgearman-server/conf.h \ | ||
195 | 550 | libgearman-server/conf_module.h \ | ||
196 | 551 | libgearman-server/conn.h \ | ||
197 | 552 | libgearman-server/function.h \ | ||
198 | 553 | libgearman-server/job.h \ | ||
199 | 554 | libgearman-server/packet.h \ | ||
200 | 555 | libgearman-server/server.h \ | ||
201 | 556 | libgearman-server/thread.h \ | ||
202 | 557 | libgearman-server/worker.h \ | ||
203 | 558 | libgearman-server/protocol_http.h \ | ||
204 | 559 | libgearman-server/queue_libdrizzle.h \ | ||
205 | 560 | libgearman-server/queue_libmemcached.h \ | ||
206 | 561 | libgearman-server/queue_libpq.h \ | ||
207 | 562 | libgearman-server/queue_libsqlite3.h \ | ||
208 | 563 | libgearman-server/gearmand.h \ | ||
209 | 564 | libgearman-server/gearmand_con.h \ | ||
210 | 565 | libgearman-server/gearmand_thread.h \ | ||
211 | 566 | libgearman-server \ | ||
212 | 567 | examples | ||
213 | 538 | 568 | ||
214 | 539 | # This tag can be used to specify the character encoding of the source files | 569 | # This tag can be used to specify the character encoding of the source files |
215 | 540 | # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is | 570 | # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is |
216 | 541 | 571 | ||
217 | === modified file 'examples/reverse_worker.c' | |||
218 | --- examples/reverse_worker.c 2009-09-28 17:47:34 +0000 | |||
219 | +++ examples/reverse_worker.c 2009-11-04 22:14:13 +0000 | |||
220 | @@ -27,8 +27,8 @@ | |||
221 | 27 | REVERSE_WORKER_OPTIONS_UNIQUE= (1 << 2) | 27 | REVERSE_WORKER_OPTIONS_UNIQUE= (1 << 2) |
222 | 28 | } reverse_worker_options_t; | 28 | } reverse_worker_options_t; |
223 | 29 | 29 | ||
226 | 30 | static void *reverse(gearman_job_st *job, void *cb_arg, size_t *result_size, | 30 | static void *reverse(gearman_job_st *job, void *context, |
227 | 31 | gearman_return_t *ret_ptr); | 31 | size_t *result_size, gearman_return_t *ret_ptr); |
228 | 32 | 32 | ||
229 | 33 | static void usage(char *name); | 33 | static void usage(char *name); |
230 | 34 | 34 | ||
231 | @@ -136,10 +136,10 @@ | |||
232 | 136 | return 0; | 136 | return 0; |
233 | 137 | } | 137 | } |
234 | 138 | 138 | ||
237 | 139 | static void *reverse(gearman_job_st *job, void *cb_arg, size_t *result_size, | 139 | static void *reverse(gearman_job_st *job, void *context, |
238 | 140 | gearman_return_t *ret_ptr) | 140 | size_t *result_size, gearman_return_t *ret_ptr) |
239 | 141 | { | 141 | { |
241 | 142 | reverse_worker_options_t options= *((reverse_worker_options_t *)cb_arg); | 142 | reverse_worker_options_t options= *((reverse_worker_options_t *)context); |
242 | 143 | const uint8_t *workload; | 143 | const uint8_t *workload; |
243 | 144 | uint8_t *result; | 144 | uint8_t *result; |
244 | 145 | size_t x; | 145 | size_t x; |
245 | 146 | 146 | ||
246 | === modified file 'examples/wc_worker.c' | |||
247 | --- examples/wc_worker.c 2009-06-14 07:26:30 +0000 | |||
248 | +++ examples/wc_worker.c 2009-11-04 22:14:14 +0000 | |||
249 | @@ -19,7 +19,7 @@ | |||
250 | 19 | 19 | ||
251 | 20 | #include <libgearman/gearman.h> | 20 | #include <libgearman/gearman.h> |
252 | 21 | 21 | ||
254 | 22 | static void *wc(gearman_job_st *job, void *cb_arg, size_t *result_size, | 22 | static void *wc(gearman_job_st *job, void *context, size_t *result_size, |
255 | 23 | gearman_return_t *ret_ptr); | 23 | gearman_return_t *ret_ptr); |
256 | 24 | 24 | ||
257 | 25 | static void usage(char *name); | 25 | static void usage(char *name); |
258 | @@ -97,14 +97,14 @@ | |||
259 | 97 | return 0; | 97 | return 0; |
260 | 98 | } | 98 | } |
261 | 99 | 99 | ||
263 | 100 | static void *wc(gearman_job_st *job, void *cb_arg, size_t *result_size, | 100 | static void *wc(gearman_job_st *job, void *context, size_t *result_size, |
264 | 101 | gearman_return_t *ret_ptr) | 101 | gearman_return_t *ret_ptr) |
265 | 102 | { | 102 | { |
266 | 103 | const uint8_t *workload; | 103 | const uint8_t *workload; |
267 | 104 | uint8_t *result; | 104 | uint8_t *result; |
268 | 105 | size_t x; | 105 | size_t x; |
269 | 106 | uint64_t count= 0; | 106 | uint64_t count= 0; |
271 | 107 | (void)cb_arg; | 107 | (void)context; |
272 | 108 | 108 | ||
273 | 109 | workload= gearman_job_workload(job); | 109 | workload= gearman_job_workload(job); |
274 | 110 | *result_size= gearman_job_workload_size(job); | 110 | *result_size= gearman_job_workload_size(job); |
275 | 111 | 111 | ||
276 | === modified file 'gearmand/gearmand.c' | |||
277 | --- gearmand/gearmand.c 2009-09-24 23:43:15 +0000 | |||
278 | +++ gearmand/gearmand.c 2009-11-04 22:14:14 +0000 | |||
279 | @@ -102,6 +102,7 @@ | |||
280 | 102 | int backlog= GEARMAND_LISTEN_BACKLOG; | 102 | int backlog= GEARMAND_LISTEN_BACKLOG; |
281 | 103 | rlim_t fds= 0; | 103 | rlim_t fds= 0; |
282 | 104 | uint8_t job_retries= 0; | 104 | uint8_t job_retries= 0; |
283 | 105 | uint8_t worker_wakeup= 0; | ||
284 | 105 | in_port_t port= 0; | 106 | in_port_t port= 0; |
285 | 106 | const char *host= NULL; | 107 | const char *host= NULL; |
286 | 107 | const char *pid_file= NULL; | 108 | const char *pid_file= NULL; |
287 | @@ -157,6 +158,9 @@ | |||
288 | 157 | MCO("user", 'u', "USER", "Switch to given user after startup.") | 158 | MCO("user", 'u', "USER", "Switch to given user after startup.") |
289 | 158 | MCO("verbose", 'v', NULL, "Increase verbosity level by one.") | 159 | MCO("verbose", 'v', NULL, "Increase verbosity level by one.") |
290 | 159 | MCO("version", 'V', NULL, "Display the version of gearmand and exit.") | 160 | MCO("version", 'V', NULL, "Display the version of gearmand and exit.") |
291 | 161 | MCO("worker-wakeup", 'w', "WORKERS", | ||
292 | 162 | "Number of workers to wakeup for each job received. The default is to " | ||
293 | 163 | "wakeup all avaiable workers.") | ||
294 | 160 | 164 | ||
295 | 161 | /* Make sure none of the gearman_conf_module_add_option calls failed. */ | 165 | /* Make sure none of the gearman_conf_module_add_option calls failed. */ |
296 | 162 | if (gearman_conf_return(&conf) != GEARMAN_SUCCESS) | 166 | if (gearman_conf_return(&conf) != GEARMAN_SUCCESS) |
297 | @@ -280,6 +284,8 @@ | |||
298 | 280 | verbose++; | 284 | verbose++; |
299 | 281 | else if (!strcmp(name, "version")) | 285 | else if (!strcmp(name, "version")) |
300 | 282 | printf("\ngearmand %s - %s\n", gearman_version(), gearman_bugreport()); | 286 | printf("\ngearmand %s - %s\n", gearman_version(), gearman_bugreport()); |
301 | 287 | else if (!strcmp(name, "worker-wakeup")) | ||
302 | 288 | worker_wakeup= (uint8_t)atoi(value); | ||
303 | 283 | else | 289 | else |
304 | 284 | { | 290 | { |
305 | 285 | fprintf(stderr, "gearmand: Unknown option:%s\n", name); | 291 | fprintf(stderr, "gearmand: Unknown option:%s\n", name); |
306 | @@ -331,6 +337,7 @@ | |||
307 | 331 | gearmand_set_backlog(_gearmand, backlog); | 337 | gearmand_set_backlog(_gearmand, backlog); |
308 | 332 | gearmand_set_threads(_gearmand, threads); | 338 | gearmand_set_threads(_gearmand, threads); |
309 | 333 | gearmand_set_job_retries(_gearmand, job_retries); | 339 | gearmand_set_job_retries(_gearmand, job_retries); |
310 | 340 | gearmand_set_worker_wakeup(_gearmand, worker_wakeup); | ||
311 | 334 | gearmand_set_log_fn(_gearmand, _log, &log_info, verbose); | 341 | gearmand_set_log_fn(_gearmand, _log, &log_info, verbose); |
312 | 335 | 342 | ||
313 | 336 | if (queue_type != NULL) | 343 | if (queue_type != NULL) |
314 | 337 | 344 | ||
315 | === modified file 'libgearman-server/client.h' | |||
316 | --- libgearman-server/client.h 2009-09-24 23:43:15 +0000 | |||
317 | +++ libgearman-server/client.h 2009-11-04 22:14:14 +0000 | |||
318 | @@ -8,7 +8,7 @@ | |||
319 | 8 | 8 | ||
320 | 9 | /** | 9 | /** |
321 | 10 | * @file | 10 | * @file |
323 | 11 | * @brief Server client declarations | 11 | * @brief Client Declarations |
324 | 12 | */ | 12 | */ |
325 | 13 | 13 | ||
326 | 14 | #ifndef __GEARMAN_SERVER_CLIENT_H__ | 14 | #ifndef __GEARMAN_SERVER_CLIENT_H__ |
327 | @@ -19,10 +19,12 @@ | |||
328 | 19 | #endif | 19 | #endif |
329 | 20 | 20 | ||
330 | 21 | /** | 21 | /** |
332 | 22 | * @addtogroup gearman_server_client Server Client Handling | 22 | * @addtogroup gearman_server_client Client Declarations |
333 | 23 | * @ingroup gearman_server | 23 | * @ingroup gearman_server |
334 | 24 | * | ||
335 | 24 | * This is a low level interface for gearman server clients. This is used | 25 | * This is a low level interface for gearman server clients. This is used |
336 | 25 | * internally by the server interface, so you probably want to look there first. | 26 | * internally by the server interface, so you probably want to look there first. |
337 | 27 | * | ||
338 | 26 | * @{ | 28 | * @{ |
339 | 27 | */ | 29 | */ |
340 | 28 | 30 | ||
341 | 29 | 31 | ||
342 | === modified file 'libgearman-server/common.h' | |||
343 | --- libgearman-server/common.h 2009-09-24 23:43:15 +0000 | |||
344 | +++ libgearman-server/common.h 2009-11-04 22:14:14 +0000 | |||
345 | @@ -8,7 +8,7 @@ | |||
346 | 8 | 8 | ||
347 | 9 | /** | 9 | /** |
348 | 10 | * @file | 10 | * @file |
350 | 11 | * @brief System include files | 11 | * @brief System Include Files |
351 | 12 | */ | 12 | */ |
352 | 13 | 13 | ||
353 | 14 | #ifndef __GEARMAN_SERVER_COMMON_H__ | 14 | #ifndef __GEARMAN_SERVER_COMMON_H__ |
354 | @@ -106,8 +106,10 @@ | |||
355 | 106 | * Macro to log fatal errors. | 106 | * Macro to log fatal errors. |
356 | 107 | * @ingroup gearman_constants | 107 | * @ingroup gearman_constants |
357 | 108 | */ | 108 | */ |
360 | 109 | #define GEARMAN_FATAL(__gearman, ...) \ | 109 | #define GEARMAN_FATAL(__gearman, ...) { \ |
361 | 110 | GEARMAN_LOG(__gearman, GEARMAN_VERBOSE_FATAL, __VA_ARGS__) | 110 | unlikely ((__gearman)->verbose >= GEARMAN_VERBOSE_FATAL) \ |
362 | 111 | GEARMAN_LOG(__gearman, GEARMAN_VERBOSE_FATAL, __VA_ARGS__) \ | ||
363 | 112 | } | ||
364 | 111 | #define GEARMAN_SERVER_FATAL(__server, ...) \ | 113 | #define GEARMAN_SERVER_FATAL(__server, ...) \ |
365 | 112 | GEARMAN_FATAL((__server)->gearman, __VA_ARGS__) | 114 | GEARMAN_FATAL((__server)->gearman, __VA_ARGS__) |
366 | 113 | 115 | ||
367 | 114 | 116 | ||
368 | === modified file 'libgearman-server/conf.h' | |||
369 | --- libgearman-server/conf.h 2009-09-24 23:43:15 +0000 | |||
370 | +++ libgearman-server/conf.h 2009-11-04 22:14:14 +0000 | |||
371 | @@ -8,7 +8,7 @@ | |||
372 | 8 | 8 | ||
373 | 9 | /** | 9 | /** |
374 | 10 | * @file | 10 | * @file |
376 | 11 | * @brief Gearman conf declarations | 11 | * @brief Configuration Declarations |
377 | 12 | */ | 12 | */ |
378 | 13 | 13 | ||
379 | 14 | #ifndef __GEARMAN_SERVER_CONF_H__ | 14 | #ifndef __GEARMAN_SERVER_CONF_H__ |
380 | @@ -19,7 +19,8 @@ | |||
381 | 19 | #endif | 19 | #endif |
382 | 20 | 20 | ||
383 | 21 | /** | 21 | /** |
385 | 22 | * @addtogroup gearman_conf Gearman Conf Interface | 22 | * @addtogroup gearman_conf Configuration Declarations |
386 | 23 | * @ingroup gearman_server | ||
387 | 23 | * @{ | 24 | * @{ |
388 | 24 | */ | 25 | */ |
389 | 25 | 26 | ||
390 | 26 | 27 | ||
391 | === modified file 'libgearman-server/conf_module.h' | |||
392 | --- libgearman-server/conf_module.h 2009-09-24 23:43:15 +0000 | |||
393 | +++ libgearman-server/conf_module.h 2009-11-04 22:14:14 +0000 | |||
394 | @@ -8,7 +8,7 @@ | |||
395 | 8 | 8 | ||
396 | 9 | /** | 9 | /** |
397 | 10 | * @file | 10 | * @file |
399 | 11 | * @brief Gearman conf module declarations | 11 | * @brief Configuration Module Declarations |
400 | 12 | */ | 12 | */ |
401 | 13 | 13 | ||
402 | 14 | #ifndef __GEARMAN_SERVER_CONF_MODULE_H__ | 14 | #ifndef __GEARMAN_SERVER_CONF_MODULE_H__ |
403 | @@ -19,7 +19,8 @@ | |||
404 | 19 | #endif | 19 | #endif |
405 | 20 | 20 | ||
406 | 21 | /** | 21 | /** |
408 | 22 | * @addtogroup gearman_conf_module Gearman conf module interface | 22 | * @addtogroup gearman_conf_module Configuration Module Declarations |
409 | 23 | * @ingroup gearman_server | ||
410 | 23 | * @{ | 24 | * @{ |
411 | 24 | */ | 25 | */ |
412 | 25 | 26 | ||
413 | 26 | 27 | ||
414 | === modified file 'libgearman-server/conn.c' | |||
415 | --- libgearman-server/conn.c 2009-09-24 23:43:15 +0000 | |||
416 | +++ libgearman-server/conn.c 2009-11-04 22:14:14 +0000 | |||
417 | @@ -66,7 +66,7 @@ | |||
418 | 66 | } | 66 | } |
419 | 67 | } | 67 | } |
420 | 68 | 68 | ||
422 | 69 | if (gearman_con_create(thread->gearman, &(con->con)) == NULL) | 69 | if (gearman_add_con(thread->gearman, &(con->con)) == NULL) |
423 | 70 | { | 70 | { |
424 | 71 | free(con); | 71 | free(con); |
425 | 72 | return NULL; | 72 | return NULL; |
426 | 73 | 73 | ||
427 | === modified file 'libgearman-server/conn.h' | |||
428 | --- libgearman-server/conn.h 2009-09-24 23:43:15 +0000 | |||
429 | +++ libgearman-server/conn.h 2009-11-04 22:14:14 +0000 | |||
430 | @@ -8,7 +8,7 @@ | |||
431 | 8 | 8 | ||
432 | 9 | /** | 9 | /** |
433 | 10 | * @file | 10 | * @file |
435 | 11 | * @brief Server connection declarations | 11 | * @brief Connection Declarations |
436 | 12 | */ | 12 | */ |
437 | 13 | 13 | ||
438 | 14 | #ifndef __GEARMAN_SERVER_CON_H__ | 14 | #ifndef __GEARMAN_SERVER_CON_H__ |
439 | @@ -19,10 +19,12 @@ | |||
440 | 19 | #endif | 19 | #endif |
441 | 20 | 20 | ||
442 | 21 | /** | 21 | /** |
444 | 22 | * @addtogroup gearman_server_con Server Connection Handling | 22 | * @addtogroup gearman_server_con Connection Declarations |
445 | 23 | * @ingroup gearman_server | 23 | * @ingroup gearman_server |
446 | 24 | * | ||
447 | 24 | * This is a low level interface for gearman server connections. This is used | 25 | * This is a low level interface for gearman server connections. This is used |
448 | 25 | * internally by the server interface, so you probably want to look there first. | 26 | * internally by the server interface, so you probably want to look there first. |
449 | 27 | * | ||
450 | 26 | * @{ | 28 | * @{ |
451 | 27 | */ | 29 | */ |
452 | 28 | 30 | ||
453 | 29 | 31 | ||
454 | === modified file 'libgearman-server/constants.h' | |||
455 | --- libgearman-server/constants.h 2009-09-25 00:04:06 +0000 | |||
456 | +++ libgearman-server/constants.h 2009-11-04 22:14:14 +0000 | |||
457 | @@ -19,7 +19,8 @@ | |||
458 | 19 | #endif | 19 | #endif |
459 | 20 | 20 | ||
460 | 21 | /** | 21 | /** |
462 | 22 | * @addtogroup gearman_server_constants Gearman Server Constants | 22 | * @addtogroup gearman_server_constants Constants |
463 | 23 | * @ingroup gearman_server | ||
464 | 23 | * @{ | 24 | * @{ |
465 | 24 | */ | 25 | */ |
466 | 25 | 26 | ||
467 | @@ -38,23 +39,6 @@ | |||
468 | 38 | #define GEARMAN_CONF_MAX_OPTION_SHORT 128 | 39 | #define GEARMAN_CONF_MAX_OPTION_SHORT 128 |
469 | 39 | #define GEARMAN_CONF_DISPLAY_WIDTH 80 | 40 | #define GEARMAN_CONF_DISPLAY_WIDTH 80 |
470 | 40 | 41 | ||
471 | 41 | /* Types. */ | ||
472 | 42 | typedef struct gearman_server_st gearman_server_st; | ||
473 | 43 | typedef struct gearman_server_thread_st gearman_server_thread_st; | ||
474 | 44 | typedef struct gearman_server_con_st gearman_server_con_st; | ||
475 | 45 | typedef struct gearman_server_packet_st gearman_server_packet_st; | ||
476 | 46 | typedef struct gearman_server_function_st gearman_server_function_st; | ||
477 | 47 | typedef struct gearman_server_client_st gearman_server_client_st; | ||
478 | 48 | typedef struct gearman_server_worker_st gearman_server_worker_st; | ||
479 | 49 | typedef struct gearman_server_job_st gearman_server_job_st; | ||
480 | 50 | typedef struct gearmand_st gearmand_st; | ||
481 | 51 | typedef struct gearmand_port_st gearmand_port_st; | ||
482 | 52 | typedef struct gearmand_con_st gearmand_con_st; | ||
483 | 53 | typedef struct gearmand_thread_st gearmand_thread_st; | ||
484 | 54 | typedef struct gearman_conf_st gearman_conf_st; | ||
485 | 55 | typedef struct gearman_conf_option_st gearman_conf_option_st; | ||
486 | 56 | typedef struct gearman_conf_module_st gearman_conf_module_st; | ||
487 | 57 | |||
488 | 58 | /** @} */ | 42 | /** @} */ |
489 | 59 | 43 | ||
490 | 60 | /** | 44 | /** |
491 | @@ -180,10 +164,28 @@ | |||
492 | 180 | 164 | ||
493 | 181 | 165 | ||
494 | 182 | /** | 166 | /** |
496 | 183 | * @addtogroup gearman_server_constants Gearman Server Constants | 167 | * @addtogroup gearman_server_types Types |
497 | 168 | * @ingroup gearman_server | ||
498 | 184 | * @{ | 169 | * @{ |
499 | 185 | */ | 170 | */ |
500 | 186 | 171 | ||
501 | 172 | /* Types. */ | ||
502 | 173 | typedef struct gearman_server_st gearman_server_st; | ||
503 | 174 | typedef struct gearman_server_thread_st gearman_server_thread_st; | ||
504 | 175 | typedef struct gearman_server_con_st gearman_server_con_st; | ||
505 | 176 | typedef struct gearman_server_packet_st gearman_server_packet_st; | ||
506 | 177 | typedef struct gearman_server_function_st gearman_server_function_st; | ||
507 | 178 | typedef struct gearman_server_client_st gearman_server_client_st; | ||
508 | 179 | typedef struct gearman_server_worker_st gearman_server_worker_st; | ||
509 | 180 | typedef struct gearman_server_job_st gearman_server_job_st; | ||
510 | 181 | typedef struct gearmand_st gearmand_st; | ||
511 | 182 | typedef struct gearmand_port_st gearmand_port_st; | ||
512 | 183 | typedef struct gearmand_con_st gearmand_con_st; | ||
513 | 184 | typedef struct gearmand_thread_st gearmand_thread_st; | ||
514 | 185 | typedef struct gearman_conf_st gearman_conf_st; | ||
515 | 186 | typedef struct gearman_conf_option_st gearman_conf_option_st; | ||
516 | 187 | typedef struct gearman_conf_module_st gearman_conf_module_st; | ||
517 | 188 | |||
518 | 187 | /* Function types. */ | 189 | /* Function types. */ |
519 | 188 | typedef void (gearman_server_thread_run_fn)(gearman_server_thread_st *thread, | 190 | typedef void (gearman_server_thread_run_fn)(gearman_server_thread_st *thread, |
520 | 189 | void *context); | 191 | void *context); |
521 | @@ -214,6 +216,16 @@ | |||
522 | 214 | 216 | ||
523 | 215 | /** @} */ | 217 | /** @} */ |
524 | 216 | 218 | ||
525 | 219 | /** | ||
526 | 220 | * @addtogroup gearman_server_protocol Protocol Plugins | ||
527 | 221 | * @ingroup gearman_server | ||
528 | 222 | */ | ||
529 | 223 | |||
530 | 224 | /** | ||
531 | 225 | * @addtogroup gearman_server_queue Queue Plugins | ||
532 | 226 | * @ingroup gearman_server | ||
533 | 227 | */ | ||
534 | 228 | |||
535 | 217 | #ifdef __cplusplus | 229 | #ifdef __cplusplus |
536 | 218 | } | 230 | } |
537 | 219 | #endif | 231 | #endif |
538 | 220 | 232 | ||
539 | === modified file 'libgearman-server/function.h' | |||
540 | --- libgearman-server/function.h 2009-09-24 23:43:15 +0000 | |||
541 | +++ libgearman-server/function.h 2009-11-04 22:14:14 +0000 | |||
542 | @@ -8,7 +8,7 @@ | |||
543 | 8 | 8 | ||
544 | 9 | /** | 9 | /** |
545 | 10 | * @file | 10 | * @file |
547 | 11 | * @brief Server function declarations | 11 | * @brief Function Declarations |
548 | 12 | */ | 12 | */ |
549 | 13 | 13 | ||
550 | 14 | #ifndef __GEARMAN_SERVER_FUNCTION_H__ | 14 | #ifndef __GEARMAN_SERVER_FUNCTION_H__ |
551 | @@ -19,10 +19,12 @@ | |||
552 | 19 | #endif | 19 | #endif |
553 | 20 | 20 | ||
554 | 21 | /** | 21 | /** |
556 | 22 | * @addtogroup gearman_server_function Server Function Handling | 22 | * @addtogroup gearman_server_function Function Declarations |
557 | 23 | * @ingroup gearman_server | 23 | * @ingroup gearman_server |
558 | 24 | * | ||
559 | 24 | * This is a low level interface for gearman server functions. This is used | 25 | * This is a low level interface for gearman server functions. This is used |
560 | 25 | * internally by the server interface, so you probably want to look there first. | 26 | * internally by the server interface, so you probably want to look there first. |
561 | 27 | * | ||
562 | 26 | * @{ | 28 | * @{ |
563 | 27 | */ | 29 | */ |
564 | 28 | 30 | ||
565 | 29 | 31 | ||
566 | === modified file 'libgearman-server/gearmand.c' | |||
567 | --- libgearman-server/gearmand.c 2009-09-24 23:43:15 +0000 | |||
568 | +++ libgearman-server/gearmand.c 2009-11-04 22:14:14 +0000 | |||
569 | @@ -146,6 +146,11 @@ | |||
570 | 146 | gearman_server_set_job_retries(&(gearmand->server), job_retries); | 146 | gearman_server_set_job_retries(&(gearmand->server), job_retries); |
571 | 147 | } | 147 | } |
572 | 148 | 148 | ||
573 | 149 | void gearmand_set_worker_wakeup(gearmand_st *gearmand, uint8_t worker_wakeup) | ||
574 | 150 | { | ||
575 | 151 | gearman_server_set_worker_wakeup(&(gearmand->server), worker_wakeup); | ||
576 | 152 | } | ||
577 | 153 | |||
578 | 149 | void gearmand_set_threads(gearmand_st *gearmand, uint32_t threads) | 154 | void gearmand_set_threads(gearmand_st *gearmand, uint32_t threads) |
579 | 150 | { | 155 | { |
580 | 151 | gearmand->threads= threads; | 156 | gearmand->threads= threads; |
581 | 152 | 157 | ||
582 | === modified file 'libgearman-server/gearmand.h' | |||
583 | --- libgearman-server/gearmand.h 2009-09-24 23:43:15 +0000 | |||
584 | +++ libgearman-server/gearmand.h 2009-11-04 22:14:14 +0000 | |||
585 | @@ -8,7 +8,7 @@ | |||
586 | 8 | 8 | ||
587 | 9 | /** | 9 | /** |
588 | 10 | * @file | 10 | * @file |
590 | 11 | * @brief Gearmand declarations | 11 | * @brief Gearmand Declarations |
591 | 12 | */ | 12 | */ |
592 | 13 | 13 | ||
593 | 14 | #ifndef __GEARMAND_H__ | 14 | #ifndef __GEARMAND_H__ |
594 | @@ -23,8 +23,10 @@ | |||
595 | 23 | #endif | 23 | #endif |
596 | 24 | 24 | ||
597 | 25 | /** | 25 | /** |
599 | 26 | * @addtogroup gearmand Gearmand | 26 | * @addtogroup gearmand Gearmand Declarations |
600 | 27 | * | ||
601 | 27 | * This is a server implementation using the gearman_server interface. | 28 | * This is a server implementation using the gearman_server interface. |
602 | 29 | * | ||
603 | 28 | * @{ | 30 | * @{ |
604 | 29 | */ | 31 | */ |
605 | 30 | 32 | ||
606 | @@ -64,6 +66,15 @@ | |||
607 | 64 | void gearmand_set_job_retries(gearmand_st *gearmand, uint8_t job_retries); | 66 | void gearmand_set_job_retries(gearmand_st *gearmand, uint8_t job_retries); |
608 | 65 | 67 | ||
609 | 66 | /** | 68 | /** |
610 | 69 | * Set maximum number of workers to wake up per job. | ||
611 | 70 | * @param gearmand Server instance structure previously initialized with | ||
612 | 71 | * gearmand_create. | ||
613 | 72 | * @param worker_wakeup Number of workers to wake up. | ||
614 | 73 | */ | ||
615 | 74 | GEARMAN_API | ||
616 | 75 | void gearmand_set_worker_wakeup(gearmand_st *gearmand, uint8_t worker_wakeup); | ||
617 | 76 | |||
618 | 77 | /** | ||
619 | 67 | * Set number of I/O threads for server to use. | 78 | * Set number of I/O threads for server to use. |
620 | 68 | * @param gearmand Server instance structure previously initialized with | 79 | * @param gearmand Server instance structure previously initialized with |
621 | 69 | * gearmand_create. | 80 | * gearmand_create. |
622 | 70 | 81 | ||
623 | === modified file 'libgearman-server/gearmand_con.c' | |||
624 | --- libgearman-server/gearmand_con.c 2009-09-24 23:43:15 +0000 | |||
625 | +++ libgearman-server/gearmand_con.c 2009-11-04 22:14:14 +0000 | |||
626 | @@ -178,9 +178,9 @@ | |||
627 | 178 | } | 178 | } |
628 | 179 | 179 | ||
629 | 180 | gearman_return_t gearmand_con_watch(gearman_con_st *con, short events, | 180 | gearman_return_t gearmand_con_watch(gearman_con_st *con, short events, |
631 | 181 | void *arg __attribute__ ((unused))) | 181 | void *context __attribute__ ((unused))) |
632 | 182 | { | 182 | { |
634 | 183 | (void) arg; | 183 | (void) context; |
635 | 184 | gearmand_con_st *dcon; | 184 | gearmand_con_st *dcon; |
636 | 185 | short set_events= 0; | 185 | short set_events= 0; |
637 | 186 | 186 | ||
638 | 187 | 187 | ||
639 | === modified file 'libgearman-server/gearmand_con.h' | |||
640 | --- libgearman-server/gearmand_con.h 2009-09-24 23:43:15 +0000 | |||
641 | +++ libgearman-server/gearmand_con.h 2009-11-04 22:14:14 +0000 | |||
642 | @@ -8,7 +8,7 @@ | |||
643 | 8 | 8 | ||
644 | 9 | /** | 9 | /** |
645 | 10 | * @file | 10 | * @file |
647 | 11 | * @brief Gearmand Connection Declarations | 11 | * @brief Connection Declarations |
648 | 12 | */ | 12 | */ |
649 | 13 | 13 | ||
650 | 14 | #ifndef __GEARMAND_CON_H__ | 14 | #ifndef __GEARMAND_CON_H__ |
651 | @@ -19,8 +19,11 @@ | |||
652 | 19 | #endif | 19 | #endif |
653 | 20 | 20 | ||
654 | 21 | /** | 21 | /** |
656 | 22 | * @addtogroup gearmand_con Gearmand Connections | 22 | * @addtogroup gearmand_con Connection Declarations |
657 | 23 | * @ingroup gearmand | ||
658 | 24 | * | ||
659 | 23 | * Connection handling for gearmand. | 25 | * Connection handling for gearmand. |
660 | 26 | * | ||
661 | 24 | * @{ | 27 | * @{ |
662 | 25 | */ | 28 | */ |
663 | 26 | 29 | ||
664 | @@ -58,7 +61,7 @@ | |||
665 | 58 | */ | 61 | */ |
666 | 59 | GEARMAN_API | 62 | GEARMAN_API |
667 | 60 | gearman_return_t gearmand_con_watch(gearman_con_st *con, short events, | 63 | gearman_return_t gearmand_con_watch(gearman_con_st *con, short events, |
669 | 61 | void *arg); | 64 | void *context); |
670 | 62 | 65 | ||
671 | 63 | /** @} */ | 66 | /** @} */ |
672 | 64 | 67 | ||
673 | 65 | 68 | ||
674 | === modified file 'libgearman-server/gearmand_thread.h' | |||
675 | --- libgearman-server/gearmand_thread.h 2009-09-24 23:43:15 +0000 | |||
676 | +++ libgearman-server/gearmand_thread.h 2009-11-04 22:14:14 +0000 | |||
677 | @@ -8,7 +8,7 @@ | |||
678 | 8 | 8 | ||
679 | 9 | /** | 9 | /** |
680 | 10 | * @file | 10 | * @file |
682 | 11 | * @brief Gearmand Thread Declarations | 11 | * @brief Thread Declarations |
683 | 12 | */ | 12 | */ |
684 | 13 | 13 | ||
685 | 14 | #ifndef __GEARMAND_THREAD_H__ | 14 | #ifndef __GEARMAND_THREAD_H__ |
686 | @@ -19,8 +19,11 @@ | |||
687 | 19 | #endif | 19 | #endif |
688 | 20 | 20 | ||
689 | 21 | /** | 21 | /** |
691 | 22 | * @addtogroup gearmand_thread Gearmand Threads | 22 | * @addtogroup gearmand_thread Thread Declarations |
692 | 23 | * @ingroup gearmand | ||
693 | 24 | * | ||
694 | 23 | * Thread handling for gearmand. | 25 | * Thread handling for gearmand. |
695 | 26 | * | ||
696 | 24 | * @{ | 27 | * @{ |
697 | 25 | */ | 28 | */ |
698 | 26 | 29 | ||
699 | 27 | 30 | ||
700 | === modified file 'libgearman-server/job.c' | |||
701 | --- libgearman-server/job.c 2009-09-26 17:11:51 +0000 | |||
702 | +++ libgearman-server/job.c 2009-11-04 22:14:14 +0000 | |||
703 | @@ -380,6 +380,7 @@ | |||
704 | 380 | { | 380 | { |
705 | 381 | gearman_server_client_st *client; | 381 | gearman_server_client_st *client; |
706 | 382 | gearman_server_worker_st *worker; | 382 | gearman_server_worker_st *worker; |
707 | 383 | uint32_t noop_sent; | ||
708 | 383 | gearman_return_t ret; | 384 | gearman_return_t ret; |
709 | 384 | 385 | ||
710 | 385 | if (job->worker != NULL) | 386 | if (job->worker != NULL) |
711 | @@ -415,22 +416,32 @@ | |||
712 | 415 | } | 416 | } |
713 | 416 | 417 | ||
714 | 417 | /* Queue NOOP for possible sleeping workers. */ | 418 | /* Queue NOOP for possible sleeping workers. */ |
717 | 418 | for (worker= job->function->worker_list; worker != NULL; | 419 | if (job->function->worker_list != NULL) |
716 | 419 | worker= worker->function_next) | ||
718 | 420 | { | 420 | { |
721 | 421 | if (!(worker->con->options & GEARMAN_SERVER_CON_SLEEPING) || | 421 | worker= job->function->worker_list; |
722 | 422 | worker->con->options & GEARMAN_SERVER_CON_NOOP_SENT) | 422 | noop_sent= 0; |
723 | 423 | do | ||
724 | 423 | { | 424 | { |
726 | 424 | continue; | 425 | if (worker->con->options & GEARMAN_SERVER_CON_SLEEPING && |
727 | 426 | !(worker->con->options & GEARMAN_SERVER_CON_NOOP_SENT)) | ||
728 | 427 | { | ||
729 | 428 | ret= gearman_server_io_packet_add(worker->con, false, | ||
730 | 429 | GEARMAN_MAGIC_RESPONSE, | ||
731 | 430 | GEARMAN_COMMAND_NOOP, NULL); | ||
732 | 431 | if (ret != GEARMAN_SUCCESS) | ||
733 | 432 | return ret; | ||
734 | 433 | |||
735 | 434 | worker->con->options|= GEARMAN_SERVER_CON_NOOP_SENT; | ||
736 | 435 | noop_sent++; | ||
737 | 436 | } | ||
738 | 437 | |||
739 | 438 | worker= worker->function_next; | ||
740 | 425 | } | 439 | } |
749 | 426 | 440 | while (worker != job->function->worker_list && | |
750 | 427 | ret= gearman_server_io_packet_add(worker->con, false, | 441 | (job->server->worker_wakeup == 0 || |
751 | 428 | GEARMAN_MAGIC_RESPONSE, | 442 | noop_sent < job->server->worker_wakeup)); |
752 | 429 | GEARMAN_COMMAND_NOOP, NULL); | 443 | |
753 | 430 | if (ret != GEARMAN_SUCCESS) | 444 | job->function->worker_list= worker; |
746 | 431 | return ret; | ||
747 | 432 | |||
748 | 433 | worker->con->options|= GEARMAN_SERVER_CON_NOOP_SENT; | ||
754 | 434 | } | 445 | } |
755 | 435 | 446 | ||
756 | 436 | /* Queue the job to be run. */ | 447 | /* Queue the job to be run. */ |
757 | 437 | 448 | ||
758 | === modified file 'libgearman-server/job.h' | |||
759 | --- libgearman-server/job.h 2009-09-24 23:43:15 +0000 | |||
760 | +++ libgearman-server/job.h 2009-11-04 22:14:14 +0000 | |||
761 | @@ -8,7 +8,7 @@ | |||
762 | 8 | 8 | ||
763 | 9 | /** | 9 | /** |
764 | 10 | * @file | 10 | * @file |
766 | 11 | * @brief Server job declarations | 11 | * @brief Job Declarations |
767 | 12 | */ | 12 | */ |
768 | 13 | 13 | ||
769 | 14 | #ifndef __GEARMAN_SERVER_JOB_H__ | 14 | #ifndef __GEARMAN_SERVER_JOB_H__ |
770 | @@ -19,10 +19,12 @@ | |||
771 | 19 | #endif | 19 | #endif |
772 | 20 | 20 | ||
773 | 21 | /** | 21 | /** |
775 | 22 | * @addtogroup gearman_server_job Server Job Handling | 22 | * @addtogroup gearman_server_job Job Declarations |
776 | 23 | * @ingroup gearman_server | 23 | * @ingroup gearman_server |
777 | 24 | * | ||
778 | 24 | * This is a low level interface for gearman server jobs. This is used | 25 | * This is a low level interface for gearman server jobs. This is used |
779 | 25 | * internally by the server interface, so you probably want to look there first. | 26 | * internally by the server interface, so you probably want to look there first. |
780 | 27 | * | ||
781 | 26 | * @{ | 28 | * @{ |
782 | 27 | */ | 29 | */ |
783 | 28 | 30 | ||
784 | 29 | 31 | ||
785 | === modified file 'libgearman-server/packet.c' | |||
786 | --- libgearman-server/packet.c 2009-09-24 23:43:15 +0000 | |||
787 | +++ libgearman-server/packet.c 2009-11-04 22:14:14 +0000 | |||
788 | @@ -101,8 +101,8 @@ | |||
789 | 101 | if (server_packet == NULL) | 101 | if (server_packet == NULL) |
790 | 102 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | 102 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; |
791 | 103 | 103 | ||
794 | 104 | if (gearman_packet_create(con->thread->gearman, | 104 | if (gearman_add_packet(con->thread->gearman, |
795 | 105 | &(server_packet->packet)) == NULL) | 105 | &(server_packet->packet)) == NULL) |
796 | 106 | { | 106 | { |
797 | 107 | gearman_server_packet_free(server_packet, con->thread, false); | 107 | gearman_server_packet_free(server_packet, con->thread, false); |
798 | 108 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | 108 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; |
799 | 109 | 109 | ||
800 | === modified file 'libgearman-server/packet.h' | |||
801 | --- libgearman-server/packet.h 2009-09-24 23:43:15 +0000 | |||
802 | +++ libgearman-server/packet.h 2009-11-04 22:14:14 +0000 | |||
803 | @@ -8,7 +8,7 @@ | |||
804 | 8 | 8 | ||
805 | 9 | /** | 9 | /** |
806 | 10 | * @file | 10 | * @file |
808 | 11 | * @brief Server Packet declarations | 11 | * @brief Packet Declarations |
809 | 12 | */ | 12 | */ |
810 | 13 | 13 | ||
811 | 14 | #ifndef __GEARMAN_SERVER_PACKET_H__ | 14 | #ifndef __GEARMAN_SERVER_PACKET_H__ |
812 | @@ -19,10 +19,12 @@ | |||
813 | 19 | #endif | 19 | #endif |
814 | 20 | 20 | ||
815 | 21 | /** | 21 | /** |
817 | 22 | * @addtogroup gearman_server_con Server Connection Handling | 22 | * @addtogroup gearman_server_packet Packet Declarations |
818 | 23 | * @ingroup gearman_server | 23 | * @ingroup gearman_server |
819 | 24 | * | ||
820 | 24 | * This is a low level interface for gearman server connections. This is used | 25 | * This is a low level interface for gearman server connections. This is used |
821 | 25 | * internally by the server interface, so you probably want to look there first. | 26 | * internally by the server interface, so you probably want to look there first. |
822 | 27 | * | ||
823 | 26 | * @{ | 28 | * @{ |
824 | 27 | */ | 29 | */ |
825 | 28 | 30 | ||
826 | 29 | 31 | ||
827 | === modified file 'libgearman-server/protocol_http.c' | |||
828 | --- libgearman-server/protocol_http.c 2009-09-24 23:43:15 +0000 | |||
829 | +++ libgearman-server/protocol_http.c 2009-11-04 22:14:14 +0000 | |||
830 | @@ -17,8 +17,8 @@ | |||
831 | 17 | #include <libgearman-server/protocol_http.h> | 17 | #include <libgearman-server/protocol_http.h> |
832 | 18 | 18 | ||
833 | 19 | /** | 19 | /** |
836 | 20 | * @addtogroup gearman_protocol_http HTTP Protocol Functions | 20 | * @addtogroup gearman_protocol_http_static Static HTTP Protocol Definitions |
837 | 21 | * @ingroup gearman_protocol | 21 | * @ingroup gearman_protocol_http |
838 | 22 | * @{ | 22 | * @{ |
839 | 23 | */ | 23 | */ |
840 | 24 | 24 | ||
841 | @@ -27,10 +27,6 @@ | |||
842 | 27 | */ | 27 | */ |
843 | 28 | #define GEARMAN_PROTOCOL_HTTP_DEFAULT_PORT 8080 | 28 | #define GEARMAN_PROTOCOL_HTTP_DEFAULT_PORT 8080 |
844 | 29 | 29 | ||
845 | 30 | /* | ||
846 | 31 | * Private declarations | ||
847 | 32 | */ | ||
848 | 33 | |||
849 | 34 | /** | 30 | /** |
850 | 35 | * Structure for HTTP specific data. | 31 | * Structure for HTTP specific data. |
851 | 36 | */ | 32 | */ |
852 | @@ -42,7 +38,7 @@ | |||
853 | 42 | 38 | ||
854 | 43 | /* Protocol callback functions. */ | 39 | /* Protocol callback functions. */ |
855 | 44 | static gearman_return_t _http_con_add(gearman_con_st *con); | 40 | static gearman_return_t _http_con_add(gearman_con_st *con); |
857 | 45 | static void _http_free(gearman_con_st *con , void *data); | 41 | static void _http_free(gearman_con_st *con, void *context); |
858 | 46 | static size_t _http_pack(const gearman_packet_st *packet, gearman_con_st *con, | 42 | static size_t _http_pack(const gearman_packet_st *packet, gearman_con_st *con, |
859 | 47 | void *data, size_t data_size, | 43 | void *data, size_t data_size, |
860 | 48 | gearman_return_t *ret_ptr); | 44 | gearman_return_t *ret_ptr); |
861 | @@ -115,7 +111,7 @@ | |||
862 | 115 | } | 111 | } |
863 | 116 | 112 | ||
864 | 117 | /* | 113 | /* |
866 | 118 | * Private definitions | 114 | * Static definitions |
867 | 119 | */ | 115 | */ |
868 | 120 | 116 | ||
869 | 121 | static gearman_return_t _http_con_add(gearman_con_st *con) | 117 | static gearman_return_t _http_con_add(gearman_con_st *con) |
870 | @@ -140,9 +136,10 @@ | |||
871 | 140 | return GEARMAN_SUCCESS; | 136 | return GEARMAN_SUCCESS; |
872 | 141 | } | 137 | } |
873 | 142 | 138 | ||
875 | 143 | static void _http_free(gearman_con_st *con __attribute__ ((unused)), void *data) | 139 | static void _http_free(gearman_con_st *con __attribute__ ((unused)), |
876 | 140 | void *context) | ||
877 | 144 | { | 141 | { |
879 | 145 | free(data); | 142 | free((gearman_protocol_http_st *)context); |
880 | 146 | } | 143 | } |
881 | 147 | 144 | ||
882 | 148 | static size_t _http_pack(const gearman_packet_st *packet, gearman_con_st *con, | 145 | static size_t _http_pack(const gearman_packet_st *packet, gearman_con_st *con, |
883 | 149 | 146 | ||
884 | === modified file 'libgearman-server/protocol_http.h' | |||
885 | --- libgearman-server/protocol_http.h 2009-09-24 23:43:15 +0000 | |||
886 | +++ libgearman-server/protocol_http.h 2009-11-04 22:14:14 +0000 | |||
887 | @@ -19,20 +19,24 @@ | |||
888 | 19 | #endif | 19 | #endif |
889 | 20 | 20 | ||
890 | 21 | /** | 21 | /** |
893 | 22 | * @addtogroup gearman_protocol_http HTTP Protocol Functions | 22 | * @addtogroup gearman_protocol_http HTTP Protocol Declarations |
894 | 23 | * @ingroup gearman_protocol | 23 | * @ingroup gearman_server_protocol |
895 | 24 | * | ||
896 | 24 | * This module provides a simple HTTP interface into the Gearman job server. It | 25 | * This module provides a simple HTTP interface into the Gearman job server. It |
897 | 25 | * is also meant to serve as an example of how other protocols can plug into | 26 | * is also meant to serve as an example of how other protocols can plug into |
898 | 26 | * the server. This module will ignore all headers except: | 27 | * the server. This module will ignore all headers except: |
899 | 28 | * | ||
900 | 27 | * Content-Length: SIZE | 29 | * Content-Length: SIZE |
901 | 28 | * Connection: Keep-Alive | 30 | * Connection: Keep-Alive |
902 | 29 | * X-Gearman-Unique: UNIQUE_KEY | 31 | * X-Gearman-Unique: UNIQUE_KEY |
903 | 30 | * X-Gearman-Background: true | 32 | * X-Gearman-Background: true |
904 | 31 | * X-Gearman-Priority: HIGH | LOW | 33 | * X-Gearman-Priority: HIGH | LOW |
905 | 34 | * | ||
906 | 32 | * All HTTP requests are translated into SUBMIT_JOB requests, and only | 35 | * All HTTP requests are translated into SUBMIT_JOB requests, and only |
907 | 33 | * WORK_COMPLETE, WORK_FAIL, and JOB_CREATED responses are returned. | 36 | * WORK_COMPLETE, WORK_FAIL, and JOB_CREATED responses are returned. |
908 | 34 | * JOB_CREATED packet are only sent back if the "X-Gearman-Background: true" | 37 | * JOB_CREATED packet are only sent back if the "X-Gearman-Background: true" |
909 | 35 | * header is given. | 38 | * header is given. |
910 | 39 | * | ||
911 | 36 | * @{ | 40 | * @{ |
912 | 37 | */ | 41 | */ |
913 | 38 | 42 | ||
914 | 39 | 43 | ||
915 | === modified file 'libgearman-server/queue_libdrizzle.c' | |||
916 | --- libgearman-server/queue_libdrizzle.c 2009-09-24 23:43:15 +0000 | |||
917 | +++ libgearman-server/queue_libdrizzle.c 2009-11-04 22:14:14 +0000 | |||
918 | @@ -8,7 +8,7 @@ | |||
919 | 8 | 8 | ||
920 | 9 | /** | 9 | /** |
921 | 10 | * @file | 10 | * @file |
923 | 11 | * @brief Drizzle Queue Storage Definitions | 11 | * @brief libdrizzle Queue Storage Definitions |
924 | 12 | */ | 12 | */ |
925 | 13 | 13 | ||
926 | 14 | #include "common.h" | 14 | #include "common.h" |
927 | @@ -17,8 +17,8 @@ | |||
928 | 17 | #include <libdrizzle/drizzle_client.h> | 17 | #include <libdrizzle/drizzle_client.h> |
929 | 18 | 18 | ||
930 | 19 | /** | 19 | /** |
933 | 20 | * @addtogroup gearman_queue_libdrizzle libdrizzle Queue Storage Functions | 20 | * @addtogroup gearman_queue_libdrizzle_static Static libdrizzle Queue Storage Definitions |
934 | 21 | * @ingroup gearman_queue | 21 | * @ingroup gearman_queue_libdrizzle |
935 | 22 | * @{ | 22 | * @{ |
936 | 23 | */ | 23 | */ |
937 | 24 | 24 | ||
938 | @@ -29,10 +29,6 @@ | |||
939 | 29 | #define GEARMAN_QUEUE_LIBDRIZZLE_DEFAULT_TABLE "queue" | 29 | #define GEARMAN_QUEUE_LIBDRIZZLE_DEFAULT_TABLE "queue" |
940 | 30 | #define GEARMAN_QUEUE_QUERY_BUFFER 256 | 30 | #define GEARMAN_QUEUE_QUERY_BUFFER 256 |
941 | 31 | 31 | ||
942 | 32 | /* | ||
943 | 33 | * Private declarations | ||
944 | 34 | */ | ||
945 | 35 | |||
946 | 36 | /** | 32 | /** |
947 | 37 | * Structure for libdrizzle specific data. | 33 | * Structure for libdrizzle specific data. |
948 | 38 | */ | 34 | */ |
949 | @@ -289,7 +285,7 @@ | |||
950 | 289 | } | 285 | } |
951 | 290 | 286 | ||
952 | 291 | /* | 287 | /* |
954 | 292 | * Private definitions | 288 | * Static definitions |
955 | 293 | */ | 289 | */ |
956 | 294 | 290 | ||
957 | 295 | static drizzle_return_t _libdrizzle_query(gearman_server_st *server, | 291 | static drizzle_return_t _libdrizzle_query(gearman_server_st *server, |
958 | 296 | 292 | ||
959 | === modified file 'libgearman-server/queue_libdrizzle.h' | |||
960 | --- libgearman-server/queue_libdrizzle.h 2009-09-24 23:43:15 +0000 | |||
961 | +++ libgearman-server/queue_libdrizzle.h 2009-11-04 22:14:14 +0000 | |||
962 | @@ -19,8 +19,8 @@ | |||
963 | 19 | #endif | 19 | #endif |
964 | 20 | 20 | ||
965 | 21 | /** | 21 | /** |
968 | 22 | * @addtogroup gearman_queue_libdrizzle libdrizzle Queue Storage Functions | 22 | * @addtogroup gearman_queue_libdrizzle libdrizzle Queue Storage Declarations |
969 | 23 | * @ingroup gearman_queue | 23 | * @ingroup gearman_server_queue |
970 | 24 | * @{ | 24 | * @{ |
971 | 25 | */ | 25 | */ |
972 | 26 | 26 | ||
973 | 27 | 27 | ||
974 | === modified file 'libgearman-server/queue_libmemcached.c' | |||
975 | --- libgearman-server/queue_libmemcached.c 2009-09-24 23:43:15 +0000 | |||
976 | +++ libgearman-server/queue_libmemcached.c 2009-11-04 22:14:14 +0000 | |||
977 | @@ -8,7 +8,7 @@ | |||
978 | 8 | 8 | ||
979 | 9 | /** | 9 | /** |
980 | 10 | * @file | 10 | * @file |
982 | 11 | * @brief Drizzle Queue Storage Definitions | 11 | * @brief libmemcached Queue Storage Definitions |
983 | 12 | */ | 12 | */ |
984 | 13 | 13 | ||
985 | 14 | #include "common.h" | 14 | #include "common.h" |
986 | @@ -17,8 +17,8 @@ | |||
987 | 17 | #include <libmemcached/memcached.h> | 17 | #include <libmemcached/memcached.h> |
988 | 18 | 18 | ||
989 | 19 | /** | 19 | /** |
992 | 20 | * @addtogroup gearman_queue_libmemcached libmemcached Queue Storage Functions | 20 | * @addtogroup gearman_queue_libmemcached_static Static libmemcached Queue Storage Functions |
993 | 21 | * @ingroup gearman_queue | 21 | * @ingroup gearman_queue_libmemcached |
994 | 22 | * @{ | 22 | * @{ |
995 | 23 | */ | 23 | */ |
996 | 24 | 24 | ||
997 | @@ -27,10 +27,6 @@ | |||
998 | 27 | */ | 27 | */ |
999 | 28 | #define GEARMAN_QUEUE_LIBMEMCACHED_DEFAULT_PREFIX "gear_" | 28 | #define GEARMAN_QUEUE_LIBMEMCACHED_DEFAULT_PREFIX "gear_" |
1000 | 29 | 29 | ||
1001 | 30 | /* | ||
1002 | 31 | * Private declarations | ||
1003 | 32 | */ | ||
1004 | 33 | |||
1005 | 34 | /** | 30 | /** |
1006 | 35 | * Structure for libmemcached specific data. | 31 | * Structure for libmemcached specific data. |
1007 | 36 | */ | 32 | */ |
1008 | @@ -191,7 +187,7 @@ | |||
1009 | 191 | } | 187 | } |
1010 | 192 | 188 | ||
1011 | 193 | /* | 189 | /* |
1013 | 194 | * Private definitions | 190 | * Static definitions |
1014 | 195 | */ | 191 | */ |
1015 | 196 | 192 | ||
1016 | 197 | static gearman_return_t _libmemcached_add(gearman_server_st *server, | 193 | static gearman_return_t _libmemcached_add(gearman_server_st *server, |
1017 | 198 | 194 | ||
1018 | === modified file 'libgearman-server/queue_libmemcached.h' | |||
1019 | --- libgearman-server/queue_libmemcached.h 2009-09-24 23:43:15 +0000 | |||
1020 | +++ libgearman-server/queue_libmemcached.h 2009-11-04 22:14:14 +0000 | |||
1021 | @@ -19,8 +19,8 @@ | |||
1022 | 19 | #endif | 19 | #endif |
1023 | 20 | 20 | ||
1024 | 21 | /** | 21 | /** |
1027 | 22 | * @addtogroup gearman_queue_libmemcached libmemcached Queue Storage Functions | 22 | * @addtogroup gearman_queue_libmemcached libmemcached Queue Storage Declarations |
1028 | 23 | * @ingroup gearman_queue | 23 | * @ingroup gearman_server_queue |
1029 | 24 | * @{ | 24 | * @{ |
1030 | 25 | */ | 25 | */ |
1031 | 26 | 26 | ||
1032 | 27 | 27 | ||
1033 | === modified file 'libgearman-server/queue_libpq.c' | |||
1034 | --- libgearman-server/queue_libpq.c 2009-09-24 23:43:15 +0000 | |||
1035 | +++ libgearman-server/queue_libpq.c 2009-11-04 22:14:14 +0000 | |||
1036 | @@ -8,7 +8,7 @@ | |||
1037 | 8 | 8 | ||
1038 | 9 | /** | 9 | /** |
1039 | 10 | * @file | 10 | * @file |
1041 | 11 | * @brief PostgreSQL Queue Storage Definitions | 11 | * @brief libpq Queue Storage Definitions |
1042 | 12 | */ | 12 | */ |
1043 | 13 | 13 | ||
1044 | 14 | #include "common.h" | 14 | #include "common.h" |
1045 | @@ -24,8 +24,8 @@ | |||
1046 | 24 | #endif | 24 | #endif |
1047 | 25 | 25 | ||
1048 | 26 | /** | 26 | /** |
1051 | 27 | * @addtogroup gearman_queue_libpq libpq Queue Storage Functions | 27 | * @addtogroup gearman_queue_libpq_static Static libpq Queue Storage Definitions |
1052 | 28 | * @ingroup gearman_queue | 28 | * @ingroup gearman_queue_libpq |
1053 | 29 | * @{ | 29 | * @{ |
1054 | 30 | */ | 30 | */ |
1055 | 31 | 31 | ||
1056 | @@ -35,10 +35,6 @@ | |||
1057 | 35 | #define GEARMAN_QUEUE_LIBPQ_DEFAULT_TABLE "queue" | 35 | #define GEARMAN_QUEUE_LIBPQ_DEFAULT_TABLE "queue" |
1058 | 36 | #define GEARMAN_QUEUE_QUERY_BUFFER 256 | 36 | #define GEARMAN_QUEUE_QUERY_BUFFER 256 |
1059 | 37 | 37 | ||
1060 | 38 | /* | ||
1061 | 39 | * Private declarations | ||
1062 | 40 | */ | ||
1063 | 41 | |||
1064 | 42 | /** | 38 | /** |
1065 | 43 | * Structure for libpq specific data. | 39 | * Structure for libpq specific data. |
1066 | 44 | */ | 40 | */ |
1067 | @@ -241,7 +237,7 @@ | |||
1068 | 241 | } | 237 | } |
1069 | 242 | 238 | ||
1070 | 243 | /* | 239 | /* |
1072 | 244 | * Private definitions | 240 | * Static definitions |
1073 | 245 | */ | 241 | */ |
1074 | 246 | 242 | ||
1075 | 247 | static void _libpq_notice_processor(void *arg, const char *message) | 243 | static void _libpq_notice_processor(void *arg, const char *message) |
1076 | 248 | 244 | ||
1077 | === modified file 'libgearman-server/queue_libpq.h' | |||
1078 | --- libgearman-server/queue_libpq.h 2009-09-24 23:43:15 +0000 | |||
1079 | +++ libgearman-server/queue_libpq.h 2009-11-04 22:14:14 +0000 | |||
1080 | @@ -19,8 +19,8 @@ | |||
1081 | 19 | #endif | 19 | #endif |
1082 | 20 | 20 | ||
1083 | 21 | /** | 21 | /** |
1086 | 22 | * @addtogroup gearman_queue_libpq libpq Queue Storage Functions | 22 | * @addtogroup gearman_queue_libpq libpq Queue Storage Declarations |
1087 | 23 | * @ingroup gearman_queue | 23 | * @ingroup gearman_server_queue |
1088 | 24 | * @{ | 24 | * @{ |
1089 | 25 | */ | 25 | */ |
1090 | 26 | 26 | ||
1091 | 27 | 27 | ||
1092 | === modified file 'libgearman-server/queue_libsqlite3.c' | |||
1093 | --- libgearman-server/queue_libsqlite3.c 2009-09-24 23:43:15 +0000 | |||
1094 | +++ libgearman-server/queue_libsqlite3.c 2009-11-04 22:14:14 +0000 | |||
1095 | @@ -8,7 +8,7 @@ | |||
1096 | 8 | 8 | ||
1097 | 9 | /** | 9 | /** |
1098 | 10 | * @file | 10 | * @file |
1100 | 11 | * @brief Sqlite Queue Storage Definitions | 11 | * @brief libsqlite3 Queue Storage Definitions |
1101 | 12 | */ | 12 | */ |
1102 | 13 | 13 | ||
1103 | 14 | #include "common.h" | 14 | #include "common.h" |
1104 | @@ -17,8 +17,8 @@ | |||
1105 | 17 | #include <sqlite3.h> | 17 | #include <sqlite3.h> |
1106 | 18 | 18 | ||
1107 | 19 | /** | 19 | /** |
1110 | 20 | * @addtogroup gearman_queue_sqlite sqlite Queue Storage Functions | 20 | * @addtogroup gearman_queue_libsqlite3_static Static libsqlite3 Queue Storage Definitions |
1111 | 21 | * @ingroup gearman_queue | 21 | * @ingroup gearman_queue_libsqlite3 |
1112 | 22 | * @{ | 22 | * @{ |
1113 | 23 | */ | 23 | */ |
1114 | 24 | 24 | ||
1115 | @@ -27,10 +27,6 @@ | |||
1116 | 27 | */ | 27 | */ |
1117 | 28 | #define GEARMAN_QUEUE_SQLITE_DEFAULT_TABLE "gearman_queue" | 28 | #define GEARMAN_QUEUE_SQLITE_DEFAULT_TABLE "gearman_queue" |
1118 | 29 | #define GEARMAN_QUEUE_QUERY_BUFFER 256 | 29 | #define GEARMAN_QUEUE_QUERY_BUFFER 256 |
1119 | 30 | |||
1120 | 31 | /* | ||
1121 | 32 | * Private declarations | ||
1122 | 33 | */ | ||
1123 | 34 | #define SQLITE_MAX_TABLE_SIZE 256 | 30 | #define SQLITE_MAX_TABLE_SIZE 256 |
1124 | 35 | #define SQLITE_MAX_CREATE_TABLE_SIZE 1024 | 31 | #define SQLITE_MAX_CREATE_TABLE_SIZE 1024 |
1125 | 36 | 32 | ||
1126 | @@ -281,7 +277,7 @@ | |||
1127 | 281 | } | 277 | } |
1128 | 282 | 278 | ||
1129 | 283 | /* | 279 | /* |
1131 | 284 | * Private definitions | 280 | * Static definitions |
1132 | 285 | */ | 281 | */ |
1133 | 286 | 282 | ||
1134 | 287 | int _sqlite_query(gearman_server_st *server, | 283 | int _sqlite_query(gearman_server_st *server, |
1135 | 288 | 284 | ||
1136 | === modified file 'libgearman-server/queue_libsqlite3.h' | |||
1137 | --- libgearman-server/queue_libsqlite3.h 2009-09-24 23:43:15 +0000 | |||
1138 | +++ libgearman-server/queue_libsqlite3.h 2009-11-04 22:14:14 +0000 | |||
1139 | @@ -19,8 +19,8 @@ | |||
1140 | 19 | #endif | 19 | #endif |
1141 | 20 | 20 | ||
1142 | 21 | /** | 21 | /** |
1145 | 22 | * @addtogroup gearman_queue_libsqlite3 libsqlite3 Queue Storage Functions | 22 | * @addtogroup gearman_queue_libsqlite3 libsqlite3 Queue Storage Declarations |
1146 | 23 | * @ingroup gearman_queue | 23 | * @ingroup gearman_server_queue |
1147 | 24 | * @{ | 24 | * @{ |
1148 | 25 | */ | 25 | */ |
1149 | 26 | 26 | ||
1150 | 27 | 27 | ||
1151 | === modified file 'libgearman-server/server.c' | |||
1152 | --- libgearman-server/server.c 2009-09-24 23:43:15 +0000 | |||
1153 | +++ libgearman-server/server.c 2009-11-04 22:14:14 +0000 | |||
1154 | @@ -84,6 +84,7 @@ | |||
1155 | 84 | server->proc_wakeup= false; | 84 | server->proc_wakeup= false; |
1156 | 85 | server->proc_shutdown= false; | 85 | server->proc_shutdown= false; |
1157 | 86 | server->job_retries= 0; | 86 | server->job_retries= 0; |
1158 | 87 | server->worker_wakeup= 0; | ||
1159 | 87 | server->thread_count= 0; | 88 | server->thread_count= 0; |
1160 | 88 | server->free_packet_count= 0; | 89 | server->free_packet_count= 0; |
1161 | 89 | server->function_count= 0; | 90 | server->function_count= 0; |
1162 | @@ -191,6 +192,12 @@ | |||
1163 | 191 | server->job_retries= job_retries; | 192 | server->job_retries= job_retries; |
1164 | 192 | } | 193 | } |
1165 | 193 | 194 | ||
1166 | 195 | void gearman_server_set_worker_wakeup(gearman_server_st *server, | ||
1167 | 196 | uint8_t worker_wakeup) | ||
1168 | 197 | { | ||
1169 | 198 | server->worker_wakeup= worker_wakeup; | ||
1170 | 199 | } | ||
1171 | 200 | |||
1172 | 194 | void gearman_server_set_log_fn(gearman_server_st *server, | 201 | void gearman_server_set_log_fn(gearman_server_st *server, |
1173 | 195 | gearman_log_fn *function, | 202 | gearman_log_fn *function, |
1174 | 196 | const void *context, gearman_verbose_t verbose) | 203 | const void *context, gearman_verbose_t verbose) |
1175 | @@ -906,8 +913,8 @@ | |||
1176 | 906 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | 913 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; |
1177 | 907 | } | 914 | } |
1178 | 908 | 915 | ||
1181 | 909 | if (gearman_packet_create(server_con->thread->gearman, | 916 | if (gearman_add_packet(server_con->thread->gearman, |
1182 | 910 | &(server_packet->packet)) == NULL) | 917 | &(server_packet->packet)) == NULL) |
1183 | 911 | { | 918 | { |
1184 | 912 | free(data); | 919 | free(data); |
1185 | 913 | gearman_server_packet_free(server_packet, server_con->thread, false); | 920 | gearman_server_packet_free(server_packet, server_con->thread, false); |
1186 | 914 | 921 | ||
1187 | === modified file 'libgearman-server/server.h' | |||
1188 | --- libgearman-server/server.h 2009-09-24 23:43:15 +0000 | |||
1189 | +++ libgearman-server/server.h 2009-11-04 22:14:14 +0000 | |||
1190 | @@ -15,6 +15,8 @@ | |||
1191 | 15 | #define __GEARMAN_SERVER_H__ | 15 | #define __GEARMAN_SERVER_H__ |
1192 | 16 | 16 | ||
1193 | 17 | #include <libgearman/gearman.h> | 17 | #include <libgearman/gearman.h> |
1194 | 18 | #include <event.h> | ||
1195 | 19 | |||
1196 | 18 | #include <libgearman-server/constants.h> | 20 | #include <libgearman-server/constants.h> |
1197 | 19 | #include <libgearman-server/structs.h> | 21 | #include <libgearman-server/structs.h> |
1198 | 20 | #include <libgearman-server/conf.h> | 22 | #include <libgearman-server/conf.h> |
1199 | @@ -32,7 +34,7 @@ | |||
1200 | 32 | #endif | 34 | #endif |
1201 | 33 | 35 | ||
1202 | 34 | /** | 36 | /** |
1204 | 35 | * @addtogroup gearman_server Server Interface | 37 | * @addtogroup gearman_server Gearman Server Declarations |
1205 | 36 | * This is the interface gearman servers should use. | 38 | * This is the interface gearman servers should use. |
1206 | 37 | * @{ | 39 | * @{ |
1207 | 38 | */ | 40 | */ |
1208 | @@ -66,6 +68,16 @@ | |||
1209 | 66 | uint8_t job_retries); | 68 | uint8_t job_retries); |
1210 | 67 | 69 | ||
1211 | 68 | /** | 70 | /** |
1212 | 71 | * Set maximum number of workers to wake up per job. | ||
1213 | 72 | * @param server Server structure previously initialized with | ||
1214 | 73 | * gearman_server_create. | ||
1215 | 74 | * @param worker_wakeup Number of workers to wake up. | ||
1216 | 75 | */ | ||
1217 | 76 | GEARMAN_API | ||
1218 | 77 | void gearman_server_set_worker_wakeup(gearman_server_st *server, | ||
1219 | 78 | uint8_t worker_wakeup); | ||
1220 | 79 | |||
1221 | 80 | /** | ||
1222 | 69 | * Set logging callback for server instance. | 81 | * Set logging callback for server instance. |
1223 | 70 | * @param server Server structure previously initialized with | 82 | * @param server Server structure previously initialized with |
1224 | 71 | * gearman_server_create. | 83 | * gearman_server_create. |
1225 | 72 | 84 | ||
1226 | === modified file 'libgearman-server/structs.h' | |||
1227 | --- libgearman-server/structs.h 2009-09-24 23:43:15 +0000 | |||
1228 | +++ libgearman-server/structs.h 2009-11-04 22:14:14 +0000 | |||
1229 | @@ -8,7 +8,7 @@ | |||
1230 | 8 | 8 | ||
1231 | 9 | /** | 9 | /** |
1232 | 10 | * @file | 10 | * @file |
1234 | 11 | * @brief Struct definitions | 11 | * @brief Struct Definitions |
1235 | 12 | */ | 12 | */ |
1236 | 13 | 13 | ||
1237 | 14 | #ifndef __GEARMAN_SERVER_STRUCTS_H__ | 14 | #ifndef __GEARMAN_SERVER_STRUCTS_H__ |
1238 | @@ -29,6 +29,7 @@ | |||
1239 | 29 | bool proc_wakeup; | 29 | bool proc_wakeup; |
1240 | 30 | bool proc_shutdown; | 30 | bool proc_shutdown; |
1241 | 31 | uint8_t job_retries; | 31 | uint8_t job_retries; |
1242 | 32 | uint8_t worker_wakeup; | ||
1243 | 32 | uint32_t job_handle_count; | 33 | uint32_t job_handle_count; |
1244 | 33 | uint32_t thread_count; | 34 | uint32_t thread_count; |
1245 | 34 | uint32_t function_count; | 35 | uint32_t function_count; |
1246 | 35 | 36 | ||
1247 | === modified file 'libgearman-server/thread.c' | |||
1248 | --- libgearman-server/thread.c 2009-09-24 23:43:15 +0000 | |||
1249 | +++ libgearman-server/thread.c 2009-11-04 22:14:14 +0000 | |||
1250 | @@ -227,7 +227,7 @@ | |||
1251 | 227 | } | 227 | } |
1252 | 228 | 228 | ||
1253 | 229 | /* Check for new activity on connections. */ | 229 | /* Check for new activity on connections. */ |
1255 | 230 | while ((con= gearman_con_ready(thread->gearman)) != NULL) | 230 | while ((con= gearman_ready(thread->gearman)) != NULL) |
1256 | 231 | { | 231 | { |
1257 | 232 | /* Inherited classes anyone? Some people would call this a hack, I call | 232 | /* Inherited classes anyone? Some people would call this a hack, I call |
1258 | 233 | it clean (avoids extra ptrs). Brian, I'll give you your C99 0-byte | 233 | it clean (avoids extra ptrs). Brian, I'll give you your C99 0-byte |
1259 | 234 | 234 | ||
1260 | === modified file 'libgearman-server/thread.h' | |||
1261 | --- libgearman-server/thread.h 2009-09-24 23:43:15 +0000 | |||
1262 | +++ libgearman-server/thread.h 2009-11-04 22:14:14 +0000 | |||
1263 | @@ -8,7 +8,7 @@ | |||
1264 | 8 | 8 | ||
1265 | 9 | /** | 9 | /** |
1266 | 10 | * @file | 10 | * @file |
1268 | 11 | * @brief Server Thread Declarations | 11 | * @brief Thread Declarations |
1269 | 12 | */ | 12 | */ |
1270 | 13 | 13 | ||
1271 | 14 | #ifndef __GEARMAN_SERVER_THREAD_H__ | 14 | #ifndef __GEARMAN_SERVER_THREAD_H__ |
1272 | @@ -19,8 +19,11 @@ | |||
1273 | 19 | #endif | 19 | #endif |
1274 | 20 | 20 | ||
1275 | 21 | /** | 21 | /** |
1277 | 22 | * @addtogroup gearman_server_thread Server Thread Handling | 22 | * @addtogroup gearman_server_thread Thread Declarations |
1278 | 23 | * @ingroup gearman_server | ||
1279 | 24 | * | ||
1280 | 23 | * This is the interface gearman servers should use for creating threads. | 25 | * This is the interface gearman servers should use for creating threads. |
1281 | 26 | * | ||
1282 | 24 | * @{ | 27 | * @{ |
1283 | 25 | */ | 28 | */ |
1284 | 26 | 29 | ||
1285 | 27 | 30 | ||
1286 | === modified file 'libgearman-server/worker.c' | |||
1287 | --- libgearman-server/worker.c 2009-09-24 23:43:15 +0000 | |||
1288 | +++ libgearman-server/worker.c 2009-11-04 22:14:14 +0000 | |||
1289 | @@ -73,7 +73,23 @@ | |||
1290 | 73 | worker->con= con; | 73 | worker->con= con; |
1291 | 74 | GEARMAN_LIST_ADD(con->worker, worker, con_) | 74 | GEARMAN_LIST_ADD(con->worker, worker, con_) |
1292 | 75 | worker->function= function; | 75 | worker->function= function; |
1294 | 76 | GEARMAN_LIST_ADD(function->worker, worker, function_) | 76 | |
1295 | 77 | /* Add worker to the function list, which is a double-linked circular list. */ | ||
1296 | 78 | if (function->worker_list == NULL) | ||
1297 | 79 | { | ||
1298 | 80 | function->worker_list= worker; | ||
1299 | 81 | worker->function_next= worker; | ||
1300 | 82 | worker->function_prev= worker; | ||
1301 | 83 | } | ||
1302 | 84 | else | ||
1303 | 85 | { | ||
1304 | 86 | worker->function_next= function->worker_list; | ||
1305 | 87 | worker->function_prev= function->worker_list->function_prev; | ||
1306 | 88 | worker->function_next->function_prev= worker; | ||
1307 | 89 | worker->function_prev->function_next= worker; | ||
1308 | 90 | } | ||
1309 | 91 | function->worker_count++; | ||
1310 | 92 | |||
1311 | 77 | worker->job_list= NULL; | 93 | worker->job_list= NULL; |
1312 | 78 | 94 | ||
1313 | 79 | return worker; | 95 | return worker; |
1314 | @@ -88,7 +104,17 @@ | |||
1315 | 88 | (void)gearman_server_job_queue(worker->job_list); | 104 | (void)gearman_server_job_queue(worker->job_list); |
1316 | 89 | 105 | ||
1317 | 90 | GEARMAN_LIST_DEL(worker->con->worker, worker, con_) | 106 | GEARMAN_LIST_DEL(worker->con->worker, worker, con_) |
1319 | 91 | GEARMAN_LIST_DEL(worker->function->worker, worker, function_) | 107 | |
1320 | 108 | if (worker == worker->function_next) | ||
1321 | 109 | worker->function->worker_list= NULL; | ||
1322 | 110 | else | ||
1323 | 111 | { | ||
1324 | 112 | worker->function_next->function_prev= worker->function_prev; | ||
1325 | 113 | worker->function_prev->function_next= worker->function_next; | ||
1326 | 114 | if (worker == worker->function->worker_list) | ||
1327 | 115 | worker->function->worker_list= worker->function_next; | ||
1328 | 116 | } | ||
1329 | 117 | worker->function->worker_count--; | ||
1330 | 92 | 118 | ||
1331 | 93 | if (worker->options & GEARMAN_SERVER_WORKER_ALLOCATED) | 119 | if (worker->options & GEARMAN_SERVER_WORKER_ALLOCATED) |
1332 | 94 | { | 120 | { |
1333 | 95 | 121 | ||
1334 | === modified file 'libgearman-server/worker.h' | |||
1335 | --- libgearman-server/worker.h 2009-09-24 23:43:15 +0000 | |||
1336 | +++ libgearman-server/worker.h 2009-11-04 22:14:14 +0000 | |||
1337 | @@ -8,7 +8,7 @@ | |||
1338 | 8 | 8 | ||
1339 | 9 | /** | 9 | /** |
1340 | 10 | * @file | 10 | * @file |
1342 | 11 | * @brief Server worker declarations | 11 | * @brief Worker Declarations |
1343 | 12 | */ | 12 | */ |
1344 | 13 | 13 | ||
1345 | 14 | #ifndef __GEARMAN_SERVER_WORKER_H__ | 14 | #ifndef __GEARMAN_SERVER_WORKER_H__ |
1346 | @@ -19,10 +19,12 @@ | |||
1347 | 19 | #endif | 19 | #endif |
1348 | 20 | 20 | ||
1349 | 21 | /** | 21 | /** |
1351 | 22 | * @addtogroup gearman_server_worker Server Worker Handling | 22 | * @addtogroup gearman_server_worker Worker Declarations |
1352 | 23 | * @ingroup gearman_server | 23 | * @ingroup gearman_server |
1353 | 24 | * | ||
1354 | 24 | * This is a low level interface for gearman server workers. This is used | 25 | * This is a low level interface for gearman server workers. This is used |
1355 | 25 | * internally by the server interface, so you probably want to look there first. | 26 | * internally by the server interface, so you probably want to look there first. |
1356 | 27 | * | ||
1357 | 26 | * @{ | 28 | * @{ |
1358 | 27 | */ | 29 | */ |
1359 | 28 | 30 | ||
1360 | 29 | 31 | ||
1361 | === modified file 'libgearman/Makefile.am' | |||
1362 | --- libgearman/Makefile.am 2009-09-26 16:54:44 +0000 | |||
1363 | +++ libgearman/Makefile.am 2009-11-04 22:14:14 +0000 | |||
1364 | @@ -22,7 +22,8 @@ | |||
1365 | 22 | worker.h | 22 | worker.h |
1366 | 23 | 23 | ||
1367 | 24 | noinst_HEADERS= \ | 24 | noinst_HEADERS= \ |
1369 | 25 | common.h | 25 | common.h \ |
1370 | 26 | gearman_local.h | ||
1371 | 26 | 27 | ||
1372 | 27 | libgearman_la_SOURCES= \ | 28 | libgearman_la_SOURCES= \ |
1373 | 28 | client.c \ | 29 | client.c \ |
1374 | 29 | 30 | ||
1375 | === modified file 'libgearman/client.c' | |||
1376 | --- libgearman/client.c 2009-09-28 17:47:34 +0000 | |||
1377 | +++ libgearman/client.c 2009-11-04 22:14:14 +0000 | |||
1378 | @@ -8,17 +8,13 @@ | |||
1379 | 8 | 8 | ||
1380 | 9 | /** | 9 | /** |
1381 | 10 | * @file | 10 | * @file |
1383 | 11 | * @brief Client definitions | 11 | * @brief Client Definitions |
1384 | 12 | */ | 12 | */ |
1385 | 13 | 13 | ||
1386 | 14 | #include "common.h" | 14 | #include "common.h" |
1387 | 15 | 15 | ||
1388 | 16 | /* | ||
1389 | 17 | * Private declarations | ||
1390 | 18 | */ | ||
1391 | 19 | |||
1392 | 20 | /** | 16 | /** |
1394 | 21 | * @addtogroup gearman_client_private Private Client Functions | 17 | * @addtogroup gearman_client_static Static Client Declarations |
1395 | 22 | * @ingroup gearman_client | 18 | * @ingroup gearman_client |
1396 | 23 | * @{ | 19 | * @{ |
1397 | 24 | */ | 20 | */ |
1398 | @@ -102,7 +98,7 @@ | |||
1399 | 102 | /** @} */ | 98 | /** @} */ |
1400 | 103 | 99 | ||
1401 | 104 | /* | 100 | /* |
1403 | 105 | * Public definitions | 101 | * Public Definitions |
1404 | 106 | */ | 102 | */ |
1405 | 107 | 103 | ||
1406 | 108 | gearman_client_st *gearman_client_create(gearman_client_st *client) | 104 | gearman_client_st *gearman_client_create(gearman_client_st *client) |
1407 | @@ -251,7 +247,7 @@ | |||
1408 | 251 | gearman_return_t gearman_client_add_server(gearman_client_st *client, | 247 | gearman_return_t gearman_client_add_server(gearman_client_st *client, |
1409 | 252 | const char *host, in_port_t port) | 248 | const char *host, in_port_t port) |
1410 | 253 | { | 249 | { |
1412 | 254 | if (gearman_con_add(client->gearman, NULL, host, port) == NULL) | 250 | if (gearman_add_con_args(client->gearman, NULL, host, port) == NULL) |
1413 | 255 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | 251 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; |
1414 | 256 | 252 | ||
1415 | 257 | return GEARMAN_SUCCESS; | 253 | return GEARMAN_SUCCESS; |
1416 | @@ -265,12 +261,12 @@ | |||
1417 | 265 | 261 | ||
1418 | 266 | void gearman_client_remove_servers(gearman_client_st *client) | 262 | void gearman_client_remove_servers(gearman_client_st *client) |
1419 | 267 | { | 263 | { |
1421 | 268 | gearman_con_free_all(client->gearman); | 264 | gearman_free_all_cons(client->gearman); |
1422 | 269 | } | 265 | } |
1423 | 270 | 266 | ||
1424 | 271 | gearman_return_t gearman_client_wait(gearman_client_st *client) | 267 | gearman_return_t gearman_client_wait(gearman_client_st *client) |
1425 | 272 | { | 268 | { |
1427 | 273 | return gearman_con_wait(client->gearman); | 269 | return gearman_wait(client->gearman); |
1428 | 274 | } | 270 | } |
1429 | 275 | 271 | ||
1430 | 276 | void *gearman_client_do(gearman_client_st *client, const char *function_name, | 272 | void *gearman_client_do(gearman_client_st *client, const char *function_name, |
1431 | @@ -394,7 +390,7 @@ | |||
1432 | 394 | const void *workload, | 390 | const void *workload, |
1433 | 395 | size_t workload_size) | 391 | size_t workload_size) |
1434 | 396 | { | 392 | { |
1436 | 397 | return gearman_con_echo(client->gearman, workload, workload_size); | 393 | return gearman_echo(client->gearman, workload, workload_size); |
1437 | 398 | } | 394 | } |
1438 | 399 | 395 | ||
1439 | 400 | void gearman_task_free(gearman_task_st *task) | 396 | void gearman_task_free(gearman_task_st *task) |
1440 | @@ -402,8 +398,11 @@ | |||
1441 | 402 | if (task->options & GEARMAN_TASK_SEND_IN_USE) | 398 | if (task->options & GEARMAN_TASK_SEND_IN_USE) |
1442 | 403 | gearman_packet_free(&(task->send)); | 399 | gearman_packet_free(&(task->send)); |
1443 | 404 | 400 | ||
1446 | 405 | if (task->context != NULL && task->client->task_context_free_fn != NULL) | 401 | if (task != &(task->client->do_task) && task->context != NULL && |
1447 | 406 | (*(task->client->task_context_free_fn))(task, (void *)(task->context)); | 402 | task->client->task_context_free_fn != NULL) |
1448 | 403 | { | ||
1449 | 404 | task->client->task_context_free_fn(task, (void *)task->context); | ||
1450 | 405 | } | ||
1451 | 407 | 406 | ||
1452 | 408 | if (task->client->task_list == task) | 407 | if (task->client->task_list == task) |
1453 | 409 | task->client->task_list= task->next; | 408 | task->client->task_list= task->next; |
1454 | @@ -521,6 +520,9 @@ | |||
1455 | 521 | const char *job_handle, | 520 | const char *job_handle, |
1456 | 522 | gearman_return_t *ret_ptr) | 521 | gearman_return_t *ret_ptr) |
1457 | 523 | { | 522 | { |
1458 | 523 | const void *args[1]; | ||
1459 | 524 | size_t args_size[1]; | ||
1460 | 525 | |||
1461 | 524 | task= _task_create(client, task); | 526 | task= _task_create(client, task); |
1462 | 525 | if (task == NULL) | 527 | if (task == NULL) |
1463 | 526 | { | 528 | { |
1464 | @@ -531,10 +533,12 @@ | |||
1465 | 531 | task->context= context; | 533 | task->context= context; |
1466 | 532 | snprintf(task->job_handle, GEARMAN_JOB_HANDLE_SIZE, "%s", job_handle); | 534 | snprintf(task->job_handle, GEARMAN_JOB_HANDLE_SIZE, "%s", job_handle); |
1467 | 533 | 535 | ||
1472 | 534 | *ret_ptr= gearman_packet_add(client->gearman, &(task->send), | 536 | args[0]= job_handle; |
1473 | 535 | GEARMAN_MAGIC_REQUEST, | 537 | args_size[0]= strlen(job_handle); |
1474 | 536 | GEARMAN_COMMAND_GET_STATUS, | 538 | *ret_ptr= gearman_add_packet_args(client->gearman, &(task->send), |
1475 | 537 | (uint8_t *)job_handle, strlen(job_handle), NULL); | 539 | GEARMAN_MAGIC_REQUEST, |
1476 | 540 | GEARMAN_COMMAND_GET_STATUS, | ||
1477 | 541 | args, args_size, 1); | ||
1478 | 538 | if (*ret_ptr == GEARMAN_SUCCESS) | 542 | if (*ret_ptr == GEARMAN_SUCCESS) |
1479 | 539 | { | 543 | { |
1480 | 540 | client->new_tasks++; | 544 | client->new_tasks++; |
1481 | @@ -636,10 +640,20 @@ | |||
1482 | 636 | return ret; | 640 | return ret; |
1483 | 637 | } | 641 | } |
1484 | 638 | } | 642 | } |
1485 | 643 | |||
1486 | 644 | if (client->new_tasks == 0) | ||
1487 | 645 | { | ||
1488 | 646 | ret= gearman_flush_all(client->gearman); | ||
1489 | 647 | if (ret != GEARMAN_SUCCESS) | ||
1490 | 648 | { | ||
1491 | 649 | client->gearman->options= options; | ||
1492 | 650 | return ret; | ||
1493 | 651 | } | ||
1494 | 652 | } | ||
1495 | 639 | } | 653 | } |
1496 | 640 | 654 | ||
1497 | 641 | /* See if there are any connections ready for I/O. */ | 655 | /* See if there are any connections ready for I/O. */ |
1499 | 642 | while ((client->con= gearman_con_ready(client->gearman)) != NULL) | 656 | while ((client->con= gearman_ready(client->gearman)) != NULL) |
1500 | 643 | { | 657 | { |
1501 | 644 | if (client->con->revents & (POLLOUT | POLLERR | POLLHUP | POLLNVAL)) | 658 | if (client->con->revents & (POLLOUT | POLLERR | POLLHUP | POLLNVAL)) |
1502 | 645 | { | 659 | { |
1503 | @@ -738,7 +752,7 @@ | |||
1504 | 738 | } | 752 | } |
1505 | 739 | else if (client->con->packet.command == GEARMAN_COMMAND_ERROR) | 753 | else if (client->con->packet.command == GEARMAN_COMMAND_ERROR) |
1506 | 740 | { | 754 | { |
1508 | 741 | gearman_error_set(client->gearman, "gearman_client_run_tasks", | 755 | gearman_set_error(client->gearman, "gearman_client_run_tasks", |
1509 | 742 | "%s:%.*s", | 756 | "%s:%.*s", |
1510 | 743 | (char *)(client->con->packet.arg[0]), | 757 | (char *)(client->con->packet.arg[0]), |
1511 | 744 | (int)(client->con->packet.arg_size[1]), | 758 | (int)(client->con->packet.arg_size[1]), |
1512 | @@ -800,7 +814,7 @@ | |||
1513 | 800 | } | 814 | } |
1514 | 801 | 815 | ||
1515 | 802 | /* Wait for activity on one of the connections. */ | 816 | /* Wait for activity on one of the connections. */ |
1517 | 803 | ret= gearman_con_wait(client->gearman); | 817 | ret= gearman_wait(client->gearman); |
1518 | 804 | if (ret != GEARMAN_SUCCESS && ret != GEARMAN_IO_WAIT) | 818 | if (ret != GEARMAN_SUCCESS && ret != GEARMAN_IO_WAIT) |
1519 | 805 | { | 819 | { |
1520 | 806 | client->state= GEARMAN_CLIENT_STATE_IDLE; | 820 | client->state= GEARMAN_CLIENT_STATE_IDLE; |
1521 | @@ -812,7 +826,7 @@ | |||
1522 | 812 | break; | 826 | break; |
1523 | 813 | 827 | ||
1524 | 814 | default: | 828 | default: |
1526 | 815 | gearman_error_set(client->gearman, "gearman_client_run_tasks", | 829 | gearman_set_error(client->gearman, "gearman_client_run_tasks", |
1527 | 816 | "unknown state: %u", client->state); | 830 | "unknown state: %u", client->state); |
1528 | 817 | client->gearman->options= options; | 831 | client->gearman->options= options; |
1529 | 818 | return GEARMAN_UNKNOWN_STATE; | 832 | return GEARMAN_UNKNOWN_STATE; |
1530 | @@ -824,7 +838,7 @@ | |||
1531 | 824 | } | 838 | } |
1532 | 825 | 839 | ||
1533 | 826 | /* | 840 | /* |
1535 | 827 | * Private definitions | 841 | * Static Definitions |
1536 | 828 | */ | 842 | */ |
1537 | 829 | 843 | ||
1538 | 830 | static gearman_client_st *_client_allocate(gearman_client_st *client) | 844 | static gearman_client_st *_client_allocate(gearman_client_st *client) |
1539 | @@ -883,6 +897,8 @@ | |||
1540 | 883 | { | 897 | { |
1541 | 884 | uuid_t uuid; | 898 | uuid_t uuid; |
1542 | 885 | char uuid_string[37]; | 899 | char uuid_string[37]; |
1543 | 900 | const void *args[3]; | ||
1544 | 901 | size_t args_size[3]; | ||
1545 | 886 | 902 | ||
1546 | 887 | task= _task_create(client, task); | 903 | task= _task_create(client, task); |
1547 | 888 | if (task == NULL) | 904 | if (task == NULL) |
1548 | @@ -900,12 +916,16 @@ | |||
1549 | 900 | unique= uuid_string; | 916 | unique= uuid_string; |
1550 | 901 | } | 917 | } |
1551 | 902 | 918 | ||
1558 | 903 | *ret_ptr= gearman_packet_add(client->gearman, &(task->send), | 919 | args[0]= function_name; |
1559 | 904 | GEARMAN_MAGIC_REQUEST, command, | 920 | args_size[0]= (size_t)strlen(function_name) + 1; |
1560 | 905 | (uint8_t *)function_name, | 921 | args[1]= unique; |
1561 | 906 | (size_t)(strlen(function_name) + 1), | 922 | args_size[1]= (size_t)strlen(unique) + 1; |
1562 | 907 | (uint8_t *)unique, (size_t)(strlen(unique) + 1), | 923 | args[2]= workload; |
1563 | 908 | workload, workload_size, NULL); | 924 | args_size[2]= workload_size; |
1564 | 925 | |||
1565 | 926 | *ret_ptr= gearman_add_packet_args(client->gearman, &(task->send), | ||
1566 | 927 | GEARMAN_MAGIC_REQUEST, command, | ||
1567 | 928 | args, args_size, 3); | ||
1568 | 909 | if (*ret_ptr == GEARMAN_SUCCESS) | 929 | if (*ret_ptr == GEARMAN_SUCCESS) |
1569 | 910 | { | 930 | { |
1570 | 911 | client->new_tasks++; | 931 | client->new_tasks++; |
1571 | @@ -930,7 +950,8 @@ | |||
1572 | 930 | { | 950 | { |
1573 | 931 | client->new_tasks--; | 951 | client->new_tasks--; |
1574 | 932 | client->running_tasks--; | 952 | client->running_tasks--; |
1576 | 933 | gearman_error_set(client->gearman, "_client_run_task", "no servers added"); | 953 | gearman_set_error(client->gearman, "_client_run_task", |
1577 | 954 | "no servers added"); | ||
1578 | 934 | return GEARMAN_NO_SERVERS; | 955 | return GEARMAN_NO_SERVERS; |
1579 | 935 | } | 956 | } |
1580 | 936 | 957 | ||
1581 | @@ -981,6 +1002,8 @@ | |||
1582 | 981 | break; | 1002 | break; |
1583 | 982 | } | 1003 | } |
1584 | 983 | } | 1004 | } |
1585 | 1005 | else | ||
1586 | 1006 | task->con= NULL; | ||
1587 | 984 | 1007 | ||
1588 | 985 | if (task->con == NULL) | 1008 | if (task->con == NULL) |
1589 | 986 | { | 1009 | { |
1590 | @@ -1000,13 +1023,13 @@ | |||
1591 | 1000 | { | 1023 | { |
1592 | 1001 | if (client->workload_fn == NULL) | 1024 | if (client->workload_fn == NULL) |
1593 | 1002 | { | 1025 | { |
1596 | 1003 | gearman_error_set(client->gearman, "_client_run_task", | 1026 | gearman_set_error(client->gearman, "_client_run_task", |
1597 | 1004 | "workload size > 0, but no data pointer or workload_fn was given"); | 1027 | "workload size > 0, but no data pointer or workload_fn was given"); |
1598 | 1005 | return GEARMAN_NEED_WORKLOAD_FN; | 1028 | return GEARMAN_NEED_WORKLOAD_FN; |
1599 | 1006 | } | 1029 | } |
1600 | 1007 | 1030 | ||
1601 | 1008 | case GEARMAN_TASK_STATE_WORKLOAD: | 1031 | case GEARMAN_TASK_STATE_WORKLOAD: |
1603 | 1009 | ret= (*(client->workload_fn))(task); | 1032 | ret= client->workload_fn(task); |
1604 | 1010 | if (ret != GEARMAN_SUCCESS) | 1033 | if (ret != GEARMAN_SUCCESS) |
1605 | 1011 | { | 1034 | { |
1606 | 1012 | task->state= GEARMAN_TASK_STATE_WORKLOAD; | 1035 | task->state= GEARMAN_TASK_STATE_WORKLOAD; |
1607 | @@ -1028,7 +1051,7 @@ | |||
1608 | 1028 | case GEARMAN_TASK_STATE_CREATED: | 1051 | case GEARMAN_TASK_STATE_CREATED: |
1609 | 1029 | if (client->created_fn != NULL) | 1052 | if (client->created_fn != NULL) |
1610 | 1030 | { | 1053 | { |
1612 | 1031 | ret= (*(client->created_fn))(task); | 1054 | ret= client->created_fn(task); |
1613 | 1032 | if (ret != GEARMAN_SUCCESS) | 1055 | if (ret != GEARMAN_SUCCESS) |
1614 | 1033 | { | 1056 | { |
1615 | 1034 | task->state= GEARMAN_TASK_STATE_CREATED; | 1057 | task->state= GEARMAN_TASK_STATE_CREATED; |
1616 | @@ -1048,7 +1071,7 @@ | |||
1617 | 1048 | case GEARMAN_TASK_STATE_DATA: | 1071 | case GEARMAN_TASK_STATE_DATA: |
1618 | 1049 | if (client->data_fn != NULL) | 1072 | if (client->data_fn != NULL) |
1619 | 1050 | { | 1073 | { |
1621 | 1051 | ret= (*(client->data_fn))(task); | 1074 | ret= client->data_fn(task); |
1622 | 1052 | if (ret != GEARMAN_SUCCESS) | 1075 | if (ret != GEARMAN_SUCCESS) |
1623 | 1053 | { | 1076 | { |
1624 | 1054 | task->state= GEARMAN_TASK_STATE_DATA; | 1077 | task->state= GEARMAN_TASK_STATE_DATA; |
1625 | @@ -1061,7 +1084,7 @@ | |||
1626 | 1061 | case GEARMAN_TASK_STATE_WARNING: | 1084 | case GEARMAN_TASK_STATE_WARNING: |
1627 | 1062 | if (client->warning_fn != NULL) | 1085 | if (client->warning_fn != NULL) |
1628 | 1063 | { | 1086 | { |
1630 | 1064 | ret= (*(client->warning_fn))(task); | 1087 | ret= client->warning_fn(task); |
1631 | 1065 | if (ret != GEARMAN_SUCCESS) | 1088 | if (ret != GEARMAN_SUCCESS) |
1632 | 1066 | { | 1089 | { |
1633 | 1067 | task->state= GEARMAN_TASK_STATE_WARNING; | 1090 | task->state= GEARMAN_TASK_STATE_WARNING; |
1634 | @@ -1098,7 +1121,7 @@ | |||
1635 | 1098 | case GEARMAN_TASK_STATE_STATUS: | 1121 | case GEARMAN_TASK_STATE_STATUS: |
1636 | 1099 | if (client->status_fn != NULL) | 1122 | if (client->status_fn != NULL) |
1637 | 1100 | { | 1123 | { |
1639 | 1101 | ret= (*(client->status_fn))(task); | 1124 | ret= client->status_fn(task); |
1640 | 1102 | if (ret != GEARMAN_SUCCESS) | 1125 | if (ret != GEARMAN_SUCCESS) |
1641 | 1103 | { | 1126 | { |
1642 | 1104 | task->state= GEARMAN_TASK_STATE_STATUS; | 1127 | task->state= GEARMAN_TASK_STATE_STATUS; |
1643 | @@ -1114,7 +1137,7 @@ | |||
1644 | 1114 | case GEARMAN_TASK_STATE_COMPLETE: | 1137 | case GEARMAN_TASK_STATE_COMPLETE: |
1645 | 1115 | if (client->complete_fn != NULL) | 1138 | if (client->complete_fn != NULL) |
1646 | 1116 | { | 1139 | { |
1648 | 1117 | ret= (*(client->complete_fn))(task); | 1140 | ret= client->complete_fn(task); |
1649 | 1118 | if (ret != GEARMAN_SUCCESS) | 1141 | if (ret != GEARMAN_SUCCESS) |
1650 | 1119 | { | 1142 | { |
1651 | 1120 | task->state= GEARMAN_TASK_STATE_COMPLETE; | 1143 | task->state= GEARMAN_TASK_STATE_COMPLETE; |
1652 | @@ -1129,7 +1152,7 @@ | |||
1653 | 1129 | case GEARMAN_TASK_STATE_EXCEPTION: | 1152 | case GEARMAN_TASK_STATE_EXCEPTION: |
1654 | 1130 | if (client->exception_fn != NULL) | 1153 | if (client->exception_fn != NULL) |
1655 | 1131 | { | 1154 | { |
1657 | 1132 | ret= (*(client->exception_fn))(task); | 1155 | ret= client->exception_fn(task); |
1658 | 1133 | if (ret != GEARMAN_SUCCESS) | 1156 | if (ret != GEARMAN_SUCCESS) |
1659 | 1134 | { | 1157 | { |
1660 | 1135 | task->state= GEARMAN_TASK_STATE_EXCEPTION; | 1158 | task->state= GEARMAN_TASK_STATE_EXCEPTION; |
1661 | @@ -1142,7 +1165,7 @@ | |||
1662 | 1142 | case GEARMAN_TASK_STATE_FAIL: | 1165 | case GEARMAN_TASK_STATE_FAIL: |
1663 | 1143 | if (client->fail_fn != NULL) | 1166 | if (client->fail_fn != NULL) |
1664 | 1144 | { | 1167 | { |
1666 | 1145 | ret= (*(client->fail_fn))(task); | 1168 | ret= client->fail_fn(task); |
1667 | 1146 | if (ret != GEARMAN_SUCCESS) | 1169 | if (ret != GEARMAN_SUCCESS) |
1668 | 1147 | { | 1170 | { |
1669 | 1148 | task->state= GEARMAN_TASK_STATE_FAIL; | 1171 | task->state= GEARMAN_TASK_STATE_FAIL; |
1670 | @@ -1160,7 +1183,7 @@ | |||
1671 | 1160 | break; | 1183 | break; |
1672 | 1161 | 1184 | ||
1673 | 1162 | default: | 1185 | default: |
1675 | 1163 | gearman_error_set(client->gearman, "_client_run_task", "unknown state: %u", | 1186 | gearman_set_error(client->gearman, "_client_run_task", "unknown state: %u", |
1676 | 1164 | task->state); | 1187 | task->state); |
1677 | 1165 | return GEARMAN_UNKNOWN_STATE; | 1188 | return GEARMAN_UNKNOWN_STATE; |
1678 | 1166 | } | 1189 | } |
1679 | @@ -1311,7 +1334,7 @@ | |||
1680 | 1311 | task= malloc(sizeof(gearman_task_st)); | 1334 | task= malloc(sizeof(gearman_task_st)); |
1681 | 1312 | if (task == NULL) | 1335 | if (task == NULL) |
1682 | 1313 | { | 1336 | { |
1684 | 1314 | gearman_error_set(client->gearman, "_task_create", "malloc"); | 1337 | gearman_set_error(client->gearman, "_task_create", "malloc"); |
1685 | 1315 | return NULL; | 1338 | return NULL; |
1686 | 1316 | } | 1339 | } |
1687 | 1317 | 1340 | ||
1688 | 1318 | 1341 | ||
1689 | === modified file 'libgearman/client.h' | |||
1690 | --- libgearman/client.h 2009-10-02 01:13:31 +0000 | |||
1691 | +++ libgearman/client.h 2009-11-04 22:14:14 +0000 | |||
1692 | @@ -8,7 +8,7 @@ | |||
1693 | 8 | 8 | ||
1694 | 9 | /** | 9 | /** |
1695 | 10 | * @file | 10 | * @file |
1697 | 11 | * @brief Client declarations | 11 | * @brief Client Declarations |
1698 | 12 | */ | 12 | */ |
1699 | 13 | 13 | ||
1700 | 14 | #ifndef __GEARMAN_CLIENT_H__ | 14 | #ifndef __GEARMAN_CLIENT_H__ |
1701 | @@ -19,7 +19,8 @@ | |||
1702 | 19 | #endif | 19 | #endif |
1703 | 20 | 20 | ||
1704 | 21 | /** | 21 | /** |
1706 | 22 | * @addtogroup gearman_client Client Interface | 22 | * @addtogroup gearman_client Client Declarations |
1707 | 23 | * | ||
1708 | 23 | * This is the interface gearman clients should use. You can run tasks one at a | 24 | * This is the interface gearman clients should use. You can run tasks one at a |
1709 | 24 | * time or concurrently. | 25 | * time or concurrently. |
1710 | 25 | * | 26 | * |
1711 | @@ -227,6 +228,8 @@ | |||
1712 | 227 | GEARMAN_API | 228 | GEARMAN_API |
1713 | 228 | gearman_return_t gearman_client_wait(gearman_client_st *client); | 229 | gearman_return_t gearman_client_wait(gearman_client_st *client); |
1714 | 229 | 230 | ||
1715 | 231 | /** @} */ | ||
1716 | 232 | |||
1717 | 230 | /** | 233 | /** |
1718 | 231 | * @addtogroup gearman_client_single Single Task Interface | 234 | * @addtogroup gearman_client_single Single Task Interface |
1719 | 232 | * @ingroup gearman_client | 235 | * @ingroup gearman_client |
1720 | @@ -654,8 +657,6 @@ | |||
1721 | 654 | 657 | ||
1722 | 655 | /** @} */ | 658 | /** @} */ |
1723 | 656 | 659 | ||
1724 | 657 | /** @} */ | ||
1725 | 658 | |||
1726 | 659 | #ifdef __cplusplus | 660 | #ifdef __cplusplus |
1727 | 660 | } | 661 | } |
1728 | 661 | #endif | 662 | #endif |
1729 | 662 | 663 | ||
1730 | === modified file 'libgearman/common.h' | |||
1731 | --- libgearman/common.h 2009-09-26 16:54:44 +0000 | |||
1732 | +++ libgearman/common.h 2009-11-04 22:14:14 +0000 | |||
1733 | @@ -8,7 +8,7 @@ | |||
1734 | 8 | 8 | ||
1735 | 9 | /** | 9 | /** |
1736 | 10 | * @file | 10 | * @file |
1738 | 11 | * @brief System include files | 11 | * @brief System Include Files |
1739 | 12 | */ | 12 | */ |
1740 | 13 | 13 | ||
1741 | 14 | #ifndef __GEARMAN_COMMON_H__ | 14 | #ifndef __GEARMAN_COMMON_H__ |
1742 | @@ -75,34 +75,6 @@ | |||
1743 | 75 | # endif | 75 | # endif |
1744 | 76 | #endif | 76 | #endif |
1745 | 77 | 77 | ||
1775 | 78 | #ifdef __cplusplus | 78 | #include "gearman_local.h" |
1747 | 79 | extern "C" { | ||
1748 | 80 | #endif | ||
1749 | 81 | |||
1750 | 82 | /** | ||
1751 | 83 | * Utility function used for error logging | ||
1752 | 84 | * @ingroup gearman_private | ||
1753 | 85 | * | ||
1754 | 86 | * @param[in] gearman Structure previously initialized with gearman_create() or | ||
1755 | 87 | * gearman_clone(). | ||
1756 | 88 | * @param[in] function Name of function the error happened in. | ||
1757 | 89 | * @param[in] format Format and variable argument list of message. | ||
1758 | 90 | */ | ||
1759 | 91 | GEARMAN_LOCAL | ||
1760 | 92 | void gearman_error_set(gearman_st *gearman, const char *function, | ||
1761 | 93 | const char *format, ...); | ||
1762 | 94 | |||
1763 | 95 | /** | ||
1764 | 96 | * Utility function used for parsing server lists. | ||
1765 | 97 | * @ingroup gearman_private | ||
1766 | 98 | */ | ||
1767 | 99 | GEARMAN_LOCAL | ||
1768 | 100 | gearman_return_t gearman_parse_servers(const char *servers, | ||
1769 | 101 | gearman_parse_server_fn *callback, | ||
1770 | 102 | const void *context); | ||
1771 | 103 | |||
1772 | 104 | #ifdef __cplusplus | ||
1773 | 105 | } | ||
1774 | 106 | #endif | ||
1776 | 107 | 79 | ||
1777 | 108 | #endif /* __GEARMAN_COMMON_H__ */ | 80 | #endif /* __GEARMAN_COMMON_H__ */ |
1778 | 109 | 81 | ||
1779 | === modified file 'libgearman/conn.c' | |||
1780 | --- libgearman/conn.c 2009-09-28 17:47:34 +0000 | |||
1781 | +++ libgearman/conn.c 2009-11-04 22:14:14 +0000 | |||
1782 | @@ -8,17 +8,13 @@ | |||
1783 | 8 | 8 | ||
1784 | 9 | /** | 9 | /** |
1785 | 10 | * @file | 10 | * @file |
1787 | 11 | * @brief Connection definitions | 11 | * @brief Connection Definitions |
1788 | 12 | */ | 12 | */ |
1789 | 13 | 13 | ||
1790 | 14 | #include "common.h" | 14 | #include "common.h" |
1791 | 15 | 15 | ||
1792 | 16 | /* | ||
1793 | 17 | * Private declarations | ||
1794 | 18 | */ | ||
1795 | 19 | |||
1796 | 20 | /** | 16 | /** |
1798 | 21 | * @addtogroup gearman_con_private Private Connection Functions | 17 | * @addtogroup gearman_con_static Static Connection Declarations |
1799 | 22 | * @ingroup gearman_con | 18 | * @ingroup gearman_con |
1800 | 23 | * @{ | 19 | * @{ |
1801 | 24 | */ | 20 | */ |
1802 | @@ -31,7 +27,7 @@ | |||
1803 | 31 | /** @} */ | 27 | /** @} */ |
1804 | 32 | 28 | ||
1805 | 33 | /* | 29 | /* |
1807 | 34 | * Public definitions | 30 | * Public Definitions |
1808 | 35 | */ | 31 | */ |
1809 | 36 | 32 | ||
1810 | 37 | void gearman_con_set_host(gearman_con_st *con, const char *host) | 33 | void gearman_con_set_host(gearman_con_st *con, const char *host) |
1811 | @@ -156,19 +152,18 @@ | |||
1812 | 156 | case GEARMAN_CON_SEND_STATE_NONE: | 152 | case GEARMAN_CON_SEND_STATE_NONE: |
1813 | 157 | if (!(packet->options & GEARMAN_PACKET_COMPLETE)) | 153 | if (!(packet->options & GEARMAN_PACKET_COMPLETE)) |
1814 | 158 | { | 154 | { |
1816 | 159 | gearman_error_set(con->gearman, "gearman_con_send", "packet not complete"); | 155 | gearman_set_error(con->gearman, "gearman_con_send", |
1817 | 156 | "packet not complete"); | ||
1818 | 160 | return GEARMAN_INVALID_PACKET; | 157 | return GEARMAN_INVALID_PACKET; |
1819 | 161 | } | 158 | } |
1820 | 162 | 159 | ||
1821 | 163 | /* Pack first part of packet, which is everything but the payload. */ | 160 | /* Pack first part of packet, which is everything but the payload. */ |
1822 | 164 | while (1) | 161 | while (1) |
1823 | 165 | { | 162 | { |
1830 | 166 | send_size= (*con->packet_pack_fn)(packet, con, | 163 | send_size= con->packet_pack_fn(packet, con, |
1831 | 167 | con->send_buffer + | 164 | con->send_buffer + con->send_buffer_size, |
1832 | 168 | con->send_buffer_size, | 165 | GEARMAN_SEND_BUFFER_SIZE - |
1833 | 169 | GEARMAN_SEND_BUFFER_SIZE - | 166 | con->send_buffer_size, &ret); |
1828 | 170 | con->send_buffer_size, | ||
1829 | 171 | &ret); | ||
1834 | 172 | if (ret == GEARMAN_SUCCESS) | 167 | if (ret == GEARMAN_SUCCESS) |
1835 | 173 | { | 168 | { |
1836 | 174 | con->send_buffer_size+= send_size; | 169 | con->send_buffer_size+= send_size; |
1837 | @@ -182,7 +177,7 @@ | |||
1838 | 182 | /* We were asked to flush when the buffer is already flushed! */ | 177 | /* We were asked to flush when the buffer is already flushed! */ |
1839 | 183 | if (con->send_buffer_size == 0) | 178 | if (con->send_buffer_size == 0) |
1840 | 184 | { | 179 | { |
1842 | 185 | gearman_error_set(con->gearman, "gearman_con_send", | 180 | gearman_set_error(con->gearman, "gearman_con_send", |
1843 | 186 | "send buffer too small (%u)", | 181 | "send buffer too small (%u)", |
1844 | 187 | GEARMAN_SEND_BUFFER_SIZE); | 182 | GEARMAN_SEND_BUFFER_SIZE); |
1845 | 188 | return GEARMAN_SEND_BUFFER_TOO_SMALL; | 183 | return GEARMAN_SEND_BUFFER_TOO_SMALL; |
1846 | @@ -264,7 +259,7 @@ | |||
1847 | 264 | return ret; | 259 | return ret; |
1848 | 265 | 260 | ||
1849 | 266 | default: | 261 | default: |
1851 | 267 | gearman_error_set(con->gearman, "gearman_con_send", "unknown state: %u", | 262 | gearman_set_error(con->gearman, "gearman_con_send", "unknown state: %u", |
1852 | 268 | con->send_state); | 263 | con->send_state); |
1853 | 269 | return GEARMAN_UNKNOWN_STATE; | 264 | return GEARMAN_UNKNOWN_STATE; |
1854 | 270 | } | 265 | } |
1855 | @@ -290,13 +285,13 @@ | |||
1856 | 290 | { | 285 | { |
1857 | 291 | if (con->send_state != GEARMAN_CON_SEND_STATE_FLUSH_DATA) | 286 | if (con->send_state != GEARMAN_CON_SEND_STATE_FLUSH_DATA) |
1858 | 292 | { | 287 | { |
1860 | 293 | gearman_error_set(con->gearman, "gearman_con_send_data", "not flushing"); | 288 | gearman_set_error(con->gearman, "gearman_con_send_data", "not flushing"); |
1861 | 294 | return GEARMAN_NOT_FLUSHING; | 289 | return GEARMAN_NOT_FLUSHING; |
1862 | 295 | } | 290 | } |
1863 | 296 | 291 | ||
1864 | 297 | if (data_size > (con->send_data_size - con->send_data_offset)) | 292 | if (data_size > (con->send_data_size - con->send_data_offset)) |
1865 | 298 | { | 293 | { |
1867 | 299 | gearman_error_set(con->gearman, "gearman_con_send_data", "data too large"); | 294 | gearman_set_error(con->gearman, "gearman_con_send_data", "data too large"); |
1868 | 300 | return GEARMAN_DATA_TOO_LARGE; | 295 | return GEARMAN_DATA_TOO_LARGE; |
1869 | 301 | } | 296 | } |
1870 | 302 | 297 | ||
1871 | @@ -336,7 +331,7 @@ | |||
1872 | 336 | ret= getaddrinfo(con->host, port_str, &ai, &(con->addrinfo)); | 331 | ret= getaddrinfo(con->host, port_str, &ai, &(con->addrinfo)); |
1873 | 337 | if (ret != 0) | 332 | if (ret != 0) |
1874 | 338 | { | 333 | { |
1876 | 339 | gearman_error_set(con->gearman, "gearman_con_flush", "getaddrinfo:%s", | 334 | gearman_set_error(con->gearman, "gearman_con_flush", "getaddrinfo:%s", |
1877 | 340 | gai_strerror(ret)); | 335 | gai_strerror(ret)); |
1878 | 341 | return GEARMAN_GETADDRINFO; | 336 | return GEARMAN_GETADDRINFO; |
1879 | 342 | } | 337 | } |
1880 | @@ -350,7 +345,7 @@ | |||
1881 | 350 | if (con->addrinfo_next == NULL) | 345 | if (con->addrinfo_next == NULL) |
1882 | 351 | { | 346 | { |
1883 | 352 | con->state= GEARMAN_CON_STATE_ADDRINFO; | 347 | con->state= GEARMAN_CON_STATE_ADDRINFO; |
1885 | 353 | gearman_error_set(con->gearman, "gearman_con_flush", | 348 | gearman_set_error(con->gearman, "gearman_con_flush", |
1886 | 354 | "could not connect"); | 349 | "could not connect"); |
1887 | 355 | return GEARMAN_COULD_NOT_CONNECT; | 350 | return GEARMAN_COULD_NOT_CONNECT; |
1888 | 356 | } | 351 | } |
1889 | @@ -361,7 +356,8 @@ | |||
1890 | 361 | if (con->fd == -1) | 356 | if (con->fd == -1) |
1891 | 362 | { | 357 | { |
1892 | 363 | con->state= GEARMAN_CON_STATE_ADDRINFO; | 358 | con->state= GEARMAN_CON_STATE_ADDRINFO; |
1894 | 364 | gearman_error_set(con->gearman, "gearman_con_flush", "socket:%d", errno); | 359 | gearman_set_error(con->gearman, "gearman_con_flush", "socket:%d", |
1895 | 360 | errno); | ||
1896 | 365 | con->gearman->last_errno= errno; | 361 | con->gearman->last_errno= errno; |
1897 | 366 | return GEARMAN_ERRNO; | 362 | return GEARMAN_ERRNO; |
1898 | 367 | } | 363 | } |
1899 | @@ -401,7 +397,8 @@ | |||
1900 | 401 | break; | 397 | break; |
1901 | 402 | } | 398 | } |
1902 | 403 | 399 | ||
1904 | 404 | gearman_error_set(con->gearman, "gearman_con_flush", "connect:%d", errno); | 400 | gearman_set_error(con->gearman, "gearman_con_flush", "connect:%d", |
1905 | 401 | errno); | ||
1906 | 405 | con->gearman->last_errno= errno; | 402 | con->gearman->last_errno= errno; |
1907 | 406 | gearman_con_close(con); | 403 | gearman_con_close(con); |
1908 | 407 | return GEARMAN_ERRNO; | 404 | return GEARMAN_ERRNO; |
1909 | @@ -435,7 +432,7 @@ | |||
1910 | 435 | return GEARMAN_IO_WAIT; | 432 | return GEARMAN_IO_WAIT; |
1911 | 436 | } | 433 | } |
1912 | 437 | 434 | ||
1914 | 438 | gret= gearman_con_wait(con->gearman); | 435 | gret= gearman_wait(con->gearman); |
1915 | 439 | if (gret != GEARMAN_SUCCESS) | 436 | if (gret != GEARMAN_SUCCESS) |
1916 | 440 | return gret; | 437 | return gret; |
1917 | 441 | } | 438 | } |
1918 | @@ -451,7 +448,7 @@ | |||
1919 | 451 | { | 448 | { |
1920 | 452 | if (!(con->options & GEARMAN_CON_IGNORE_LOST_CONNECTION)) | 449 | if (!(con->options & GEARMAN_CON_IGNORE_LOST_CONNECTION)) |
1921 | 453 | { | 450 | { |
1923 | 454 | gearman_error_set(con->gearman, "gearman_con_flush", | 451 | gearman_set_error(con->gearman, "gearman_con_flush", |
1924 | 455 | "lost connection to server (EOF)"); | 452 | "lost connection to server (EOF)"); |
1925 | 456 | } | 453 | } |
1926 | 457 | gearman_con_close(con); | 454 | gearman_con_close(con); |
1927 | @@ -468,7 +465,7 @@ | |||
1928 | 468 | if (con->gearman->options & GEARMAN_NON_BLOCKING) | 465 | if (con->gearman->options & GEARMAN_NON_BLOCKING) |
1929 | 469 | return GEARMAN_IO_WAIT; | 466 | return GEARMAN_IO_WAIT; |
1930 | 470 | 467 | ||
1932 | 471 | gret= gearman_con_wait(con->gearman); | 468 | gret= gearman_wait(con->gearman); |
1933 | 472 | if (gret != GEARMAN_SUCCESS) | 469 | if (gret != GEARMAN_SUCCESS) |
1934 | 473 | return gret; | 470 | return gret; |
1935 | 474 | 471 | ||
1936 | @@ -480,14 +477,15 @@ | |||
1937 | 480 | { | 477 | { |
1938 | 481 | if (!(con->options & GEARMAN_CON_IGNORE_LOST_CONNECTION)) | 478 | if (!(con->options & GEARMAN_CON_IGNORE_LOST_CONNECTION)) |
1939 | 482 | { | 479 | { |
1941 | 483 | gearman_error_set(con->gearman, "gearman_con_flush", | 480 | gearman_set_error(con->gearman, "gearman_con_flush", |
1942 | 484 | "lost connection to server (%d)", errno); | 481 | "lost connection to server (%d)", errno); |
1943 | 485 | } | 482 | } |
1944 | 486 | gearman_con_close(con); | 483 | gearman_con_close(con); |
1945 | 487 | return GEARMAN_LOST_CONNECTION; | 484 | return GEARMAN_LOST_CONNECTION; |
1946 | 488 | } | 485 | } |
1947 | 489 | 486 | ||
1949 | 490 | gearman_error_set(con->gearman, "gearman_con_flush", "write:%d", errno); | 487 | gearman_set_error(con->gearman, "gearman_con_flush", "write:%d", |
1950 | 488 | errno); | ||
1951 | 491 | con->gearman->last_errno= errno; | 489 | con->gearman->last_errno= errno; |
1952 | 492 | gearman_con_close(con); | 490 | gearman_con_close(con); |
1953 | 493 | return GEARMAN_ERRNO; | 491 | return GEARMAN_ERRNO; |
1954 | @@ -518,7 +516,8 @@ | |||
1955 | 518 | return GEARMAN_SUCCESS; | 516 | return GEARMAN_SUCCESS; |
1956 | 519 | 517 | ||
1957 | 520 | default: | 518 | default: |
1959 | 521 | gearman_error_set(con->gearman, "gearman_con_flush", "unknown state: %u", con->state); | 519 | gearman_set_error(con->gearman, "gearman_con_flush", "unknown state: %u", |
1960 | 520 | con->state); | ||
1961 | 522 | 521 | ||
1962 | 523 | return GEARMAN_UNKNOWN_STATE; | 522 | return GEARMAN_UNKNOWN_STATE; |
1963 | 524 | } | 523 | } |
1964 | @@ -536,12 +535,12 @@ | |||
1965 | 536 | case GEARMAN_CON_RECV_STATE_NONE: | 535 | case GEARMAN_CON_RECV_STATE_NONE: |
1966 | 537 | if (con->state != GEARMAN_CON_STATE_CONNECTED) | 536 | if (con->state != GEARMAN_CON_STATE_CONNECTED) |
1967 | 538 | { | 537 | { |
1969 | 539 | gearman_error_set(con->gearman, "gearman_con_recv", "not connected"); | 538 | gearman_set_error(con->gearman, "gearman_con_recv", "not connected"); |
1970 | 540 | *ret_ptr= GEARMAN_NOT_CONNECTED; | 539 | *ret_ptr= GEARMAN_NOT_CONNECTED; |
1971 | 541 | return NULL; | 540 | return NULL; |
1972 | 542 | } | 541 | } |
1973 | 543 | 542 | ||
1975 | 544 | con->recv_packet= gearman_packet_create(con->gearman, packet); | 543 | con->recv_packet= gearman_add_packet(con->gearman, packet); |
1976 | 545 | if (con->recv_packet == NULL) | 544 | if (con->recv_packet == NULL) |
1977 | 546 | { | 545 | { |
1978 | 547 | *ret_ptr= GEARMAN_MEMORY_ALLOCATION_FAILURE; | 546 | *ret_ptr= GEARMAN_MEMORY_ALLOCATION_FAILURE; |
1979 | @@ -555,9 +554,9 @@ | |||
1980 | 555 | { | 554 | { |
1981 | 556 | if (con->recv_buffer_size > 0) | 555 | if (con->recv_buffer_size > 0) |
1982 | 557 | { | 556 | { |
1986 | 558 | recv_size= (*con->packet_unpack_fn)(con->recv_packet, con, | 557 | recv_size= con->packet_unpack_fn(con->recv_packet, con, |
1987 | 559 | con->recv_buffer_ptr, | 558 | con->recv_buffer_ptr, |
1988 | 560 | con->recv_buffer_size, ret_ptr); | 559 | con->recv_buffer_size, ret_ptr); |
1989 | 561 | con->recv_buffer_ptr+= recv_size; | 560 | con->recv_buffer_ptr+= recv_size; |
1990 | 562 | con->recv_buffer_size-= recv_size; | 561 | con->recv_buffer_size-= recv_size; |
1991 | 563 | if (*ret_ptr == GEARMAN_SUCCESS) | 562 | if (*ret_ptr == GEARMAN_SUCCESS) |
1992 | @@ -602,7 +601,7 @@ | |||
1993 | 602 | else | 601 | else |
1994 | 603 | { | 602 | { |
1995 | 604 | packet->data= packet->gearman->workload_malloc_fn(packet->data_size, | 603 | packet->data= packet->gearman->workload_malloc_fn(packet->data_size, |
1997 | 605 | (void *)(packet->gearman->workload_malloc_context)); | 604 | (void *)packet->gearman->workload_malloc_context); |
1998 | 606 | } | 605 | } |
1999 | 607 | if (packet->data == NULL) | 606 | if (packet->data == NULL) |
2000 | 608 | { | 607 | { |
2001 | @@ -630,7 +629,7 @@ | |||
2002 | 630 | break; | 629 | break; |
2003 | 631 | 630 | ||
2004 | 632 | default: | 631 | default: |
2006 | 633 | gearman_error_set(con->gearman, "gearman_con_recv", "unknown state: %u", | 632 | gearman_set_error(con->gearman, "gearman_con_recv", "unknown state: %u", |
2007 | 634 | con->recv_state); | 633 | con->recv_state); |
2008 | 635 | *ret_ptr= GEARMAN_UNKNOWN_STATE; | 634 | *ret_ptr= GEARMAN_UNKNOWN_STATE; |
2009 | 636 | return NULL; | 635 | return NULL; |
2010 | @@ -702,7 +701,7 @@ | |||
2011 | 702 | { | 701 | { |
2012 | 703 | if (!(con->options & GEARMAN_CON_IGNORE_LOST_CONNECTION)) | 702 | if (!(con->options & GEARMAN_CON_IGNORE_LOST_CONNECTION)) |
2013 | 704 | { | 703 | { |
2015 | 705 | gearman_error_set(con->gearman, "gearman_con_read", | 704 | gearman_set_error(con->gearman, "gearman_con_read", |
2016 | 706 | "lost connection to server (EOF)"); | 705 | "lost connection to server (EOF)"); |
2017 | 707 | } | 706 | } |
2018 | 708 | gearman_con_close(con); | 707 | gearman_con_close(con); |
2019 | @@ -723,7 +722,7 @@ | |||
2020 | 723 | return 0; | 722 | return 0; |
2021 | 724 | } | 723 | } |
2022 | 725 | 724 | ||
2024 | 726 | *ret_ptr= gearman_con_wait(con->gearman); | 725 | *ret_ptr= gearman_wait(con->gearman); |
2025 | 727 | if (*ret_ptr != GEARMAN_SUCCESS) | 726 | if (*ret_ptr != GEARMAN_SUCCESS) |
2026 | 728 | return 0; | 727 | return 0; |
2027 | 729 | 728 | ||
2028 | @@ -735,14 +734,14 @@ | |||
2029 | 735 | { | 734 | { |
2030 | 736 | if (!(con->options & GEARMAN_CON_IGNORE_LOST_CONNECTION)) | 735 | if (!(con->options & GEARMAN_CON_IGNORE_LOST_CONNECTION)) |
2031 | 737 | { | 736 | { |
2033 | 738 | gearman_error_set(con->gearman, "gearman_con_read", | 737 | gearman_set_error(con->gearman, "gearman_con_read", |
2034 | 739 | "lost connection to server (%d)", errno); | 738 | "lost connection to server (%d)", errno); |
2035 | 740 | } | 739 | } |
2036 | 741 | *ret_ptr= GEARMAN_LOST_CONNECTION; | 740 | *ret_ptr= GEARMAN_LOST_CONNECTION; |
2037 | 742 | } | 741 | } |
2038 | 743 | else | 742 | else |
2039 | 744 | { | 743 | { |
2041 | 745 | gearman_error_set(con->gearman, "gearman_con_read", "read:%d", errno); | 744 | gearman_set_error(con->gearman, "gearman_con_read", "read:%d", errno); |
2042 | 746 | con->gearman->last_errno= errno; | 745 | con->gearman->last_errno= errno; |
2043 | 747 | *ret_ptr= GEARMAN_ERRNO; | 746 | *ret_ptr= GEARMAN_ERRNO; |
2044 | 748 | } | 747 | } |
2045 | @@ -769,7 +768,7 @@ | |||
2046 | 769 | 768 | ||
2047 | 770 | if (con->gearman->event_watch_fn != NULL) | 769 | if (con->gearman->event_watch_fn != NULL) |
2048 | 771 | { | 770 | { |
2050 | 772 | ret= (con->gearman->event_watch_fn)(con, con->events, | 771 | ret= con->gearman->event_watch_fn(con, con->events, |
2051 | 773 | (void *)con->gearman->event_watch_context); | 772 | (void *)con->gearman->event_watch_context); |
2052 | 774 | if (ret != GEARMAN_SUCCESS) | 773 | if (ret != GEARMAN_SUCCESS) |
2053 | 775 | { | 774 | { |
2054 | @@ -797,7 +796,7 @@ | |||
2055 | 797 | if (revents & POLLOUT && !(con->events & POLLOUT) && | 796 | if (revents & POLLOUT && !(con->events & POLLOUT) && |
2056 | 798 | con->gearman->event_watch_fn != NULL) | 797 | con->gearman->event_watch_fn != NULL) |
2057 | 799 | { | 798 | { |
2059 | 800 | ret= (con->gearman->event_watch_fn)(con, con->events, | 799 | ret= con->gearman->event_watch_fn(con, con->events, |
2060 | 801 | (void *)con->gearman->event_watch_context); | 800 | (void *)con->gearman->event_watch_context); |
2061 | 802 | if (ret != GEARMAN_SUCCESS) | 801 | if (ret != GEARMAN_SUCCESS) |
2062 | 803 | { | 802 | { |
2063 | @@ -840,7 +839,7 @@ | |||
2064 | 840 | } | 839 | } |
2065 | 841 | 840 | ||
2066 | 842 | /* | 841 | /* |
2068 | 843 | * Private definitions | 842 | * Static Definitions |
2069 | 844 | */ | 843 | */ |
2070 | 845 | 844 | ||
2071 | 846 | static gearman_return_t _con_setsockopt(gearman_con_st *con) | 845 | static gearman_return_t _con_setsockopt(gearman_con_st *con) |
2072 | @@ -852,9 +851,9 @@ | |||
2073 | 852 | ret= 1; | 851 | ret= 1; |
2074 | 853 | ret= setsockopt(con->fd, IPPROTO_TCP, TCP_NODELAY, &ret, | 852 | ret= setsockopt(con->fd, IPPROTO_TCP, TCP_NODELAY, &ret, |
2075 | 854 | (socklen_t)sizeof(int)); | 853 | (socklen_t)sizeof(int)); |
2077 | 855 | if (ret == -1) | 854 | if (ret == -1 && errno != EOPNOTSUPP) |
2078 | 856 | { | 855 | { |
2080 | 857 | gearman_error_set(con->gearman, "_con_setsockopt", | 856 | gearman_set_error(con->gearman, "_con_setsockopt", |
2081 | 858 | "setsockopt:TCP_NODELAY:%d", errno); | 857 | "setsockopt:TCP_NODELAY:%d", errno); |
2082 | 859 | return GEARMAN_ERRNO; | 858 | return GEARMAN_ERRNO; |
2083 | 860 | } | 859 | } |
2084 | @@ -865,7 +864,7 @@ | |||
2085 | 865 | (socklen_t)sizeof(struct linger)); | 864 | (socklen_t)sizeof(struct linger)); |
2086 | 866 | if (ret == -1) | 865 | if (ret == -1) |
2087 | 867 | { | 866 | { |
2089 | 868 | gearman_error_set(con->gearman, "_con_setsockopt", | 867 | gearman_set_error(con->gearman, "_con_setsockopt", |
2090 | 869 | "setsockopt:SO_LINGER:%d", errno); | 868 | "setsockopt:SO_LINGER:%d", errno); |
2091 | 870 | return GEARMAN_ERRNO; | 869 | return GEARMAN_ERRNO; |
2092 | 871 | } | 870 | } |
2093 | @@ -876,7 +875,7 @@ | |||
2094 | 876 | (socklen_t)sizeof(struct timeval)); | 875 | (socklen_t)sizeof(struct timeval)); |
2095 | 877 | if (ret == -1 && errno != ENOPROTOOPT) | 876 | if (ret == -1 && errno != ENOPROTOOPT) |
2096 | 878 | { | 877 | { |
2098 | 879 | gearman_error_set(con->gearman, "_con_setsockopt", | 878 | gearman_set_error(con->gearman, "_con_setsockopt", |
2099 | 880 | "setsockopt:SO_SNDTIMEO:%d", errno); | 879 | "setsockopt:SO_SNDTIMEO:%d", errno); |
2100 | 881 | return GEARMAN_ERRNO; | 880 | return GEARMAN_ERRNO; |
2101 | 882 | } | 881 | } |
2102 | @@ -885,7 +884,7 @@ | |||
2103 | 885 | (socklen_t)sizeof(struct timeval)); | 884 | (socklen_t)sizeof(struct timeval)); |
2104 | 886 | if (ret == -1 && errno != ENOPROTOOPT) | 885 | if (ret == -1 && errno != ENOPROTOOPT) |
2105 | 887 | { | 886 | { |
2107 | 888 | gearman_error_set(con->gearman, "_con_setsockopt", | 887 | gearman_set_error(con->gearman, "_con_setsockopt", |
2108 | 889 | "setsockopt:SO_RCVTIMEO:%d", errno); | 888 | "setsockopt:SO_RCVTIMEO:%d", errno); |
2109 | 890 | return GEARMAN_ERRNO; | 889 | return GEARMAN_ERRNO; |
2110 | 891 | } | 890 | } |
2111 | @@ -894,7 +893,7 @@ | |||
2112 | 894 | ret= setsockopt(con->fd, SOL_SOCKET, SO_SNDBUF, &ret, (socklen_t)sizeof(int)); | 893 | ret= setsockopt(con->fd, SOL_SOCKET, SO_SNDBUF, &ret, (socklen_t)sizeof(int)); |
2113 | 895 | if (ret == -1) | 894 | if (ret == -1) |
2114 | 896 | { | 895 | { |
2116 | 897 | gearman_error_set(con->gearman, "_con_setsockopt", | 896 | gearman_set_error(con->gearman, "_con_setsockopt", |
2117 | 898 | "setsockopt:SO_SNDBUF:%d", errno); | 897 | "setsockopt:SO_SNDBUF:%d", errno); |
2118 | 899 | return GEARMAN_ERRNO; | 898 | return GEARMAN_ERRNO; |
2119 | 900 | } | 899 | } |
2120 | @@ -903,7 +902,7 @@ | |||
2121 | 903 | ret= setsockopt(con->fd, SOL_SOCKET, SO_RCVBUF, &ret, (socklen_t)sizeof(int)); | 902 | ret= setsockopt(con->fd, SOL_SOCKET, SO_RCVBUF, &ret, (socklen_t)sizeof(int)); |
2122 | 904 | if (ret == -1) | 903 | if (ret == -1) |
2123 | 905 | { | 904 | { |
2125 | 906 | gearman_error_set(con->gearman, "_con_setsockopt", | 905 | gearman_set_error(con->gearman, "_con_setsockopt", |
2126 | 907 | "setsockopt:SO_RCVBUF:%d", errno); | 906 | "setsockopt:SO_RCVBUF:%d", errno); |
2127 | 908 | return GEARMAN_ERRNO; | 907 | return GEARMAN_ERRNO; |
2128 | 909 | } | 908 | } |
2129 | @@ -911,16 +910,16 @@ | |||
2130 | 911 | ret= fcntl(con->fd, F_GETFL, 0); | 910 | ret= fcntl(con->fd, F_GETFL, 0); |
2131 | 912 | if (ret == -1) | 911 | if (ret == -1) |
2132 | 913 | { | 912 | { |
2135 | 914 | gearman_error_set(con->gearman, "_con_setsockopt", "fcntl:F_GETFL:%d", errno); | 913 | gearman_set_error(con->gearman, "_con_setsockopt", "fcntl:F_GETFL:%d", |
2136 | 915 | 914 | errno); | |
2137 | 916 | return GEARMAN_ERRNO; | 915 | return GEARMAN_ERRNO; |
2138 | 917 | } | 916 | } |
2139 | 918 | 917 | ||
2140 | 919 | ret= fcntl(con->fd, F_SETFL, ret | O_NONBLOCK); | 918 | ret= fcntl(con->fd, F_SETFL, ret | O_NONBLOCK); |
2141 | 920 | if (ret == -1) | 919 | if (ret == -1) |
2142 | 921 | { | 920 | { |
2145 | 922 | gearman_error_set(con->gearman, "_con_setsockopt", "fcntl:F_SETFL:%d", errno); | 921 | gearman_set_error(con->gearman, "_con_setsockopt", "fcntl:F_SETFL:%d", |
2146 | 923 | 922 | errno); | |
2147 | 924 | return GEARMAN_ERRNO; | 923 | return GEARMAN_ERRNO; |
2148 | 925 | } | 924 | } |
2149 | 926 | 925 | ||
2150 | 927 | 926 | ||
2151 | === modified file 'libgearman/conn.h' | |||
2152 | --- libgearman/conn.h 2009-09-24 23:43:15 +0000 | |||
2153 | +++ libgearman/conn.h 2009-11-04 22:14:14 +0000 | |||
2154 | @@ -8,7 +8,7 @@ | |||
2155 | 8 | 8 | ||
2156 | 9 | /** | 9 | /** |
2157 | 10 | * @file | 10 | * @file |
2159 | 11 | * @brief Connection declarations | 11 | * @brief Connection Declarations |
2160 | 12 | */ | 12 | */ |
2161 | 13 | 13 | ||
2162 | 14 | #ifndef __GEARMAN_CON_H__ | 14 | #ifndef __GEARMAN_CON_H__ |
2163 | @@ -19,11 +19,14 @@ | |||
2164 | 19 | #endif | 19 | #endif |
2165 | 20 | 20 | ||
2166 | 21 | /** | 21 | /** |
2168 | 22 | * @addtogroup gearman_con Connection Handling | 22 | * @addtogroup gearman_con Connection Declarations |
2169 | 23 | * @ingroup gearman | ||
2170 | 24 | * | ||
2171 | 23 | * This is a low level interface for gearman connections. This is used | 25 | * This is a low level interface for gearman connections. This is used |
2172 | 24 | * internally by both client and worker interfaces, so you probably want to | 26 | * internally by both client and worker interfaces, so you probably want to |
2173 | 25 | * look there first. This is usually used to write lower level clients, workers, | 27 | * look there first. This is usually used to write lower level clients, workers, |
2174 | 26 | * proxies, or your own server. | 28 | * proxies, or your own server. |
2175 | 29 | * | ||
2176 | 27 | * @{ | 30 | * @{ |
2177 | 28 | */ | 31 | */ |
2178 | 29 | 32 | ||
2179 | 30 | 33 | ||
2180 | === modified file 'libgearman/constants.h' | |||
2181 | --- libgearman/constants.h 2009-09-28 17:47:34 +0000 | |||
2182 | +++ libgearman/constants.h 2009-11-04 22:14:14 +0000 | |||
2183 | @@ -19,7 +19,10 @@ | |||
2184 | 19 | #endif | 19 | #endif |
2185 | 20 | 20 | ||
2186 | 21 | /** | 21 | /** |
2188 | 22 | * @addtogroup gearman_constants Gearman Constants | 22 | * @addtogroup gearman_constants Constants |
2189 | 23 | * @ingroup gearman | ||
2190 | 24 | * @ingroup gearman_client | ||
2191 | 25 | * @ingroup gearman_worker | ||
2192 | 23 | * @{ | 26 | * @{ |
2193 | 24 | */ | 27 | */ |
2194 | 25 | 28 | ||
2195 | @@ -40,17 +43,6 @@ | |||
2196 | 40 | #define GEARMAN_RECV_BUFFER_SIZE 8192 | 43 | #define GEARMAN_RECV_BUFFER_SIZE 8192 |
2197 | 41 | #define GEARMAN_WORKER_WAIT_TIMEOUT (10 * 1000) /* Milliseconds */ | 44 | #define GEARMAN_WORKER_WAIT_TIMEOUT (10 * 1000) /* Milliseconds */ |
2198 | 42 | 45 | ||
2199 | 43 | /* Types. */ | ||
2200 | 44 | typedef struct gearman_st gearman_st; | ||
2201 | 45 | typedef struct gearman_con_st gearman_con_st; | ||
2202 | 46 | typedef struct gearman_packet_st gearman_packet_st; | ||
2203 | 47 | typedef struct gearman_command_info_st gearman_command_info_st; | ||
2204 | 48 | typedef struct gearman_task_st gearman_task_st; | ||
2205 | 49 | typedef struct gearman_client_st gearman_client_st; | ||
2206 | 50 | typedef struct gearman_job_st gearman_job_st; | ||
2207 | 51 | typedef struct gearman_worker_st gearman_worker_st; | ||
2208 | 52 | typedef struct gearman_worker_function_st gearman_worker_function_st; | ||
2209 | 53 | |||
2210 | 54 | /** | 46 | /** |
2211 | 55 | * Return codes. | 47 | * Return codes. |
2212 | 56 | */ | 48 | */ |
2213 | @@ -111,6 +103,7 @@ | |||
2214 | 111 | */ | 103 | */ |
2215 | 112 | typedef enum | 104 | typedef enum |
2216 | 113 | { | 105 | { |
2217 | 106 | GEARMAN_VERBOSE_NEVER, | ||
2218 | 114 | GEARMAN_VERBOSE_FATAL, | 107 | GEARMAN_VERBOSE_FATAL, |
2219 | 115 | GEARMAN_VERBOSE_ERROR, | 108 | GEARMAN_VERBOSE_ERROR, |
2220 | 116 | GEARMAN_VERBOSE_INFO, | 109 | GEARMAN_VERBOSE_INFO, |
2221 | @@ -386,10 +379,24 @@ | |||
2222 | 386 | } gearman_worker_work_state_t; | 379 | } gearman_worker_work_state_t; |
2223 | 387 | 380 | ||
2224 | 388 | /** | 381 | /** |
2226 | 389 | * @addtogroup gearman_constants Gearman Constants | 382 | * @addtogroup gearman_types Types |
2227 | 383 | * @ingroup gearman | ||
2228 | 384 | * @ingroup gearman_client | ||
2229 | 385 | * @ingroup gearman_worker | ||
2230 | 390 | * @{ | 386 | * @{ |
2231 | 391 | */ | 387 | */ |
2232 | 392 | 388 | ||
2233 | 389 | /* Types. */ | ||
2234 | 390 | typedef struct gearman_st gearman_st; | ||
2235 | 391 | typedef struct gearman_con_st gearman_con_st; | ||
2236 | 392 | typedef struct gearman_packet_st gearman_packet_st; | ||
2237 | 393 | typedef struct gearman_command_info_st gearman_command_info_st; | ||
2238 | 394 | typedef struct gearman_task_st gearman_task_st; | ||
2239 | 395 | typedef struct gearman_client_st gearman_client_st; | ||
2240 | 396 | typedef struct gearman_job_st gearman_job_st; | ||
2241 | 397 | typedef struct gearman_worker_st gearman_worker_st; | ||
2242 | 398 | typedef struct gearman_worker_function_st gearman_worker_function_st; | ||
2243 | 399 | |||
2244 | 393 | /* Function types. */ | 400 | /* Function types. */ |
2245 | 394 | typedef gearman_return_t (gearman_workload_fn)(gearman_task_st *task); | 401 | typedef gearman_return_t (gearman_workload_fn)(gearman_task_st *task); |
2246 | 395 | typedef gearman_return_t (gearman_created_fn)(gearman_task_st *task); | 402 | typedef gearman_return_t (gearman_created_fn)(gearman_task_st *task); |
2247 | 396 | 403 | ||
2248 | === modified file 'libgearman/gearman.c' | |||
2249 | --- libgearman/gearman.c 2009-09-28 17:47:34 +0000 | |||
2250 | +++ libgearman/gearman.c 2009-11-04 22:14:14 +0000 | |||
2251 | @@ -8,17 +8,13 @@ | |||
2252 | 8 | 8 | ||
2253 | 9 | /** | 9 | /** |
2254 | 10 | * @file | 10 | * @file |
2256 | 11 | * @brief Gearman core definitions | 11 | * @brief Gearman Definitions |
2257 | 12 | */ | 12 | */ |
2258 | 13 | 13 | ||
2259 | 14 | #include "common.h" | 14 | #include "common.h" |
2260 | 15 | 15 | ||
2261 | 16 | /* | ||
2262 | 17 | * Private declarations | ||
2263 | 18 | */ | ||
2264 | 19 | |||
2265 | 20 | /** | 16 | /** |
2267 | 21 | * @addtogroup gearman_private Private Functions | 17 | * @addtogroup gearman_static Static Gearman Declarations |
2268 | 22 | * @ingroup gearman | 18 | * @ingroup gearman |
2269 | 23 | * @{ | 19 | * @{ |
2270 | 24 | */ | 20 | */ |
2271 | @@ -28,6 +24,7 @@ | |||
2272 | 28 | */ | 24 | */ |
2273 | 29 | static const char *_verbose_name[GEARMAN_VERBOSE_MAX]= | 25 | static const char *_verbose_name[GEARMAN_VERBOSE_MAX]= |
2274 | 30 | { | 26 | { |
2275 | 27 | "NEVER", | ||
2276 | 31 | "FATAL", | 28 | "FATAL", |
2277 | 32 | "ERROR", | 29 | "ERROR", |
2278 | 33 | "INFO", | 30 | "INFO", |
2279 | @@ -38,7 +35,7 @@ | |||
2280 | 38 | /** @} */ | 35 | /** @} */ |
2281 | 39 | 36 | ||
2282 | 40 | /* | 37 | /* |
2284 | 41 | * Public definitions | 38 | * Public Definitions |
2285 | 42 | */ | 39 | */ |
2286 | 43 | 40 | ||
2287 | 44 | const char *gearman_version(void) | 41 | const char *gearman_version(void) |
2288 | @@ -108,7 +105,7 @@ | |||
2289 | 108 | 105 | ||
2290 | 109 | for (con= from->con_list; con != NULL; con= con->next) | 106 | for (con= from->con_list; con != NULL; con= con->next) |
2291 | 110 | { | 107 | { |
2293 | 111 | if (gearman_con_clone(gearman, NULL, con) == NULL) | 108 | if (gearman_clone_con(gearman, NULL, con) == NULL) |
2294 | 112 | { | 109 | { |
2295 | 113 | gearman_free(gearman); | 110 | gearman_free(gearman); |
2296 | 114 | return NULL; | 111 | return NULL; |
2297 | @@ -123,8 +120,8 @@ | |||
2298 | 123 | 120 | ||
2299 | 124 | void gearman_free(gearman_st *gearman) | 121 | void gearman_free(gearman_st *gearman) |
2300 | 125 | { | 122 | { |
2303 | 126 | gearman_con_free_all(gearman); | 123 | gearman_free_all_cons(gearman); |
2304 | 127 | gearman_packet_free_all(gearman); | 124 | gearman_free_all_packets(gearman); |
2305 | 128 | 125 | ||
2306 | 129 | if (gearman->pfds != NULL) | 126 | if (gearman->pfds != NULL) |
2307 | 130 | free(gearman->pfds); | 127 | free(gearman->pfds); |
2308 | @@ -209,14 +206,14 @@ | |||
2309 | 209 | * Connection related functions. | 206 | * Connection related functions. |
2310 | 210 | */ | 207 | */ |
2311 | 211 | 208 | ||
2313 | 212 | gearman_con_st *gearman_con_create(gearman_st *gearman, gearman_con_st *con) | 209 | gearman_con_st *gearman_add_con(gearman_st *gearman, gearman_con_st *con) |
2314 | 213 | { | 210 | { |
2315 | 214 | if (con == NULL) | 211 | if (con == NULL) |
2316 | 215 | { | 212 | { |
2317 | 216 | con= malloc(sizeof(gearman_con_st)); | 213 | con= malloc(sizeof(gearman_con_st)); |
2318 | 217 | if (con == NULL) | 214 | if (con == NULL) |
2319 | 218 | { | 215 | { |
2321 | 219 | gearman_error_set(gearman, "gearman_con_create", "malloc"); | 216 | gearman_set_error(gearman, "gearman_add_con", "malloc"); |
2322 | 220 | return NULL; | 217 | return NULL; |
2323 | 221 | } | 218 | } |
2324 | 222 | 219 | ||
2325 | @@ -264,10 +261,10 @@ | |||
2326 | 264 | return con; | 261 | return con; |
2327 | 265 | } | 262 | } |
2328 | 266 | 263 | ||
2331 | 267 | gearman_con_st *gearman_con_add(gearman_st *gearman, gearman_con_st *con, | 264 | gearman_con_st *gearman_add_con_args(gearman_st *gearman, gearman_con_st *con, |
2332 | 268 | const char *host, in_port_t port) | 265 | const char *host, in_port_t port) |
2333 | 269 | { | 266 | { |
2335 | 270 | con= gearman_con_create(gearman, con); | 267 | con= gearman_add_con(gearman, con); |
2336 | 271 | if (con == NULL) | 268 | if (con == NULL) |
2337 | 272 | return NULL; | 269 | return NULL; |
2338 | 273 | 270 | ||
2339 | @@ -277,10 +274,10 @@ | |||
2340 | 277 | return con; | 274 | return con; |
2341 | 278 | } | 275 | } |
2342 | 279 | 276 | ||
2344 | 280 | gearman_con_st *gearman_con_clone(gearman_st *gearman, gearman_con_st *con, | 277 | gearman_con_st *gearman_clone_con(gearman_st *gearman, gearman_con_st *con, |
2345 | 281 | const gearman_con_st *from) | 278 | const gearman_con_st *from) |
2346 | 282 | { | 279 | { |
2348 | 283 | con= gearman_con_create(gearman, con); | 280 | con= gearman_add_con(gearman, con); |
2349 | 284 | if (con == NULL) | 281 | if (con == NULL) |
2350 | 285 | return NULL; | 282 | return NULL; |
2351 | 286 | 283 | ||
2352 | @@ -300,7 +297,7 @@ | |||
2353 | 300 | gearman_con_reset_addrinfo(con); | 297 | gearman_con_reset_addrinfo(con); |
2354 | 301 | 298 | ||
2355 | 302 | if (con->protocol_context != NULL && con->protocol_context_free_fn != NULL) | 299 | if (con->protocol_context != NULL && con->protocol_context_free_fn != NULL) |
2357 | 303 | (*con->protocol_context_free_fn)(con, (void *)con->protocol_context); | 300 | con->protocol_context_free_fn(con, (void *)con->protocol_context); |
2358 | 304 | 301 | ||
2359 | 305 | if (con->gearman->con_list == con) | 302 | if (con->gearman->con_list == con) |
2360 | 306 | con->gearman->con_list= con->next; | 303 | con->gearman->con_list= con->next; |
2361 | @@ -317,13 +314,13 @@ | |||
2362 | 317 | free(con); | 314 | free(con); |
2363 | 318 | } | 315 | } |
2364 | 319 | 316 | ||
2366 | 320 | void gearman_con_free_all(gearman_st *gearman) | 317 | void gearman_free_all_cons(gearman_st *gearman) |
2367 | 321 | { | 318 | { |
2368 | 322 | while (gearman->con_list != NULL) | 319 | while (gearman->con_list != NULL) |
2369 | 323 | gearman_con_free(gearman->con_list); | 320 | gearman_con_free(gearman->con_list); |
2370 | 324 | } | 321 | } |
2371 | 325 | 322 | ||
2373 | 326 | gearman_return_t gearman_con_flush_all(gearman_st *gearman) | 323 | gearman_return_t gearman_flush_all(gearman_st *gearman) |
2374 | 327 | { | 324 | { |
2375 | 328 | gearman_con_st *con; | 325 | gearman_con_st *con; |
2376 | 329 | gearman_return_t ret; | 326 | gearman_return_t ret; |
2377 | @@ -341,8 +338,8 @@ | |||
2378 | 341 | return GEARMAN_SUCCESS; | 338 | return GEARMAN_SUCCESS; |
2379 | 342 | } | 339 | } |
2380 | 343 | 340 | ||
2383 | 344 | gearman_return_t gearman_con_send_all(gearman_st *gearman, | 341 | gearman_return_t gearman_send_all(gearman_st *gearman, |
2384 | 345 | const gearman_packet_st *packet) | 342 | const gearman_packet_st *packet) |
2385 | 346 | { | 343 | { |
2386 | 347 | gearman_return_t ret; | 344 | gearman_return_t ret; |
2387 | 348 | gearman_con_st *con; | 345 | gearman_con_st *con; |
2388 | @@ -371,7 +368,7 @@ | |||
2389 | 371 | 368 | ||
2390 | 372 | while (gearman->sending != 0) | 369 | while (gearman->sending != 0) |
2391 | 373 | { | 370 | { |
2393 | 374 | while ((con= gearman_con_ready(gearman)) != NULL) | 371 | while ((con= gearman_ready(gearman)) != NULL) |
2394 | 375 | { | 372 | { |
2395 | 376 | ret= gearman_con_send(con, packet, true); | 373 | ret= gearman_con_send(con, packet, true); |
2396 | 377 | if (ret != GEARMAN_SUCCESS) | 374 | if (ret != GEARMAN_SUCCESS) |
2397 | @@ -397,7 +394,7 @@ | |||
2398 | 397 | return GEARMAN_IO_WAIT; | 394 | return GEARMAN_IO_WAIT; |
2399 | 398 | } | 395 | } |
2400 | 399 | 396 | ||
2402 | 400 | ret= gearman_con_wait(gearman); | 397 | ret= gearman_wait(gearman); |
2403 | 401 | if (ret != GEARMAN_SUCCESS) | 398 | if (ret != GEARMAN_SUCCESS) |
2404 | 402 | { | 399 | { |
2405 | 403 | gearman->options= options; | 400 | gearman->options= options; |
2406 | @@ -409,7 +406,7 @@ | |||
2407 | 409 | return GEARMAN_SUCCESS; | 406 | return GEARMAN_SUCCESS; |
2408 | 410 | } | 407 | } |
2409 | 411 | 408 | ||
2411 | 412 | gearman_return_t gearman_con_wait(gearman_st *gearman) | 409 | gearman_return_t gearman_wait(gearman_st *gearman) |
2412 | 413 | { | 410 | { |
2413 | 414 | gearman_con_st *con; | 411 | gearman_con_st *con; |
2414 | 415 | struct pollfd *pfds; | 412 | struct pollfd *pfds; |
2415 | @@ -422,7 +419,7 @@ | |||
2416 | 422 | pfds= realloc(gearman->pfds, gearman->con_count * sizeof(struct pollfd)); | 419 | pfds= realloc(gearman->pfds, gearman->con_count * sizeof(struct pollfd)); |
2417 | 423 | if (pfds == NULL) | 420 | if (pfds == NULL) |
2418 | 424 | { | 421 | { |
2420 | 425 | gearman_error_set(gearman, "gearman_con_wait", "realloc"); | 422 | gearman_set_error(gearman, "gearman_wait", "realloc"); |
2421 | 426 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | 423 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; |
2422 | 427 | } | 424 | } |
2423 | 428 | 425 | ||
2424 | @@ -446,8 +443,7 @@ | |||
2425 | 446 | 443 | ||
2426 | 447 | if (x == 0) | 444 | if (x == 0) |
2427 | 448 | { | 445 | { |
2430 | 449 | gearman_error_set(gearman, "gearman_con_wait", | 446 | gearman_set_error(gearman, "gearman_wait", "no active file descriptors"); |
2429 | 450 | "no active file descriptors"); | ||
2431 | 451 | return GEARMAN_NO_ACTIVE_FDS; | 447 | return GEARMAN_NO_ACTIVE_FDS; |
2432 | 452 | } | 448 | } |
2433 | 453 | 449 | ||
2434 | @@ -459,7 +455,7 @@ | |||
2435 | 459 | if (errno == EINTR) | 455 | if (errno == EINTR) |
2436 | 460 | continue; | 456 | continue; |
2437 | 461 | 457 | ||
2439 | 462 | gearman_error_set(gearman, "gearman_con_wait", "poll:%d", errno); | 458 | gearman_set_error(gearman, "gearman_wait", "poll:%d", errno); |
2440 | 463 | gearman->last_errno= errno; | 459 | gearman->last_errno= errno; |
2441 | 464 | return GEARMAN_ERRNO; | 460 | return GEARMAN_ERRNO; |
2442 | 465 | } | 461 | } |
2443 | @@ -469,7 +465,7 @@ | |||
2444 | 469 | 465 | ||
2445 | 470 | if (ret == 0) | 466 | if (ret == 0) |
2446 | 471 | { | 467 | { |
2448 | 472 | gearman_error_set(gearman, "gearman_con_wait", "timeout reached"); | 468 | gearman_set_error(gearman, "gearman_wait", "timeout reached"); |
2449 | 473 | return GEARMAN_TIMEOUT; | 469 | return GEARMAN_TIMEOUT; |
2450 | 474 | } | 470 | } |
2451 | 475 | 471 | ||
2452 | @@ -489,7 +485,7 @@ | |||
2453 | 489 | return GEARMAN_SUCCESS; | 485 | return GEARMAN_SUCCESS; |
2454 | 490 | } | 486 | } |
2455 | 491 | 487 | ||
2457 | 492 | gearman_con_st *gearman_con_ready(gearman_st *gearman) | 488 | gearman_con_st *gearman_ready(gearman_st *gearman) |
2458 | 493 | { | 489 | { |
2459 | 494 | gearman_con_st *con; | 490 | gearman_con_st *con; |
2460 | 495 | 491 | ||
2461 | @@ -508,17 +504,17 @@ | |||
2462 | 508 | return NULL; | 504 | return NULL; |
2463 | 509 | } | 505 | } |
2464 | 510 | 506 | ||
2467 | 511 | gearman_return_t gearman_con_echo(gearman_st *gearman, const void *workload, | 507 | gearman_return_t gearman_echo(gearman_st *gearman, const void *workload, |
2468 | 512 | size_t workload_size) | 508 | size_t workload_size) |
2469 | 513 | { | 509 | { |
2470 | 514 | gearman_con_st *con; | 510 | gearman_con_st *con; |
2471 | 515 | gearman_options_t options= gearman->options; | 511 | gearman_options_t options= gearman->options; |
2472 | 516 | gearman_packet_st packet; | 512 | gearman_packet_st packet; |
2473 | 517 | gearman_return_t ret; | 513 | gearman_return_t ret; |
2474 | 518 | 514 | ||
2478 | 519 | ret= gearman_packet_add(gearman, &packet, GEARMAN_MAGIC_REQUEST, | 515 | ret= gearman_add_packet_args(gearman, &packet, GEARMAN_MAGIC_REQUEST, |
2479 | 520 | GEARMAN_COMMAND_ECHO_REQ, workload, workload_size, | 516 | GEARMAN_COMMAND_ECHO_REQ, &workload, |
2480 | 521 | NULL); | 517 | &workload_size, 1); |
2481 | 522 | if (ret != GEARMAN_SUCCESS) | 518 | if (ret != GEARMAN_SUCCESS) |
2482 | 523 | return ret; | 519 | return ret; |
2483 | 524 | 520 | ||
2484 | @@ -548,7 +544,7 @@ | |||
2485 | 548 | gearman_packet_free(&(con->packet)); | 544 | gearman_packet_free(&(con->packet)); |
2486 | 549 | gearman_packet_free(&packet); | 545 | gearman_packet_free(&packet); |
2487 | 550 | gearman->options= options; | 546 | gearman->options= options; |
2489 | 551 | gearman_error_set(gearman, "gearman_con_echo", "corruption during echo"); | 547 | gearman_set_error(gearman, "gearman_echo", "corruption during echo"); |
2490 | 552 | return GEARMAN_ECHO_DATA_CORRUPTION; | 548 | return GEARMAN_ECHO_DATA_CORRUPTION; |
2491 | 553 | } | 549 | } |
2492 | 554 | 550 | ||
2493 | @@ -564,15 +560,15 @@ | |||
2494 | 564 | * Packet related functions. | 560 | * Packet related functions. |
2495 | 565 | */ | 561 | */ |
2496 | 566 | 562 | ||
2499 | 567 | gearman_packet_st *gearman_packet_create(gearman_st *gearman, | 563 | gearman_packet_st *gearman_add_packet(gearman_st *gearman, |
2500 | 568 | gearman_packet_st *packet) | 564 | gearman_packet_st *packet) |
2501 | 569 | { | 565 | { |
2502 | 570 | if (packet == NULL) | 566 | if (packet == NULL) |
2503 | 571 | { | 567 | { |
2504 | 572 | packet= malloc(sizeof(gearman_packet_st)); | 568 | packet= malloc(sizeof(gearman_packet_st)); |
2505 | 573 | if (packet == NULL) | 569 | if (packet == NULL) |
2506 | 574 | { | 570 | { |
2508 | 575 | gearman_error_set(gearman, "gearman_packet_create", "malloc"); | 571 | gearman_set_error(gearman, "gearman_add_packet", "malloc"); |
2509 | 576 | return NULL; | 572 | return NULL; |
2510 | 577 | } | 573 | } |
2511 | 578 | 574 | ||
2512 | @@ -604,42 +600,34 @@ | |||
2513 | 604 | return packet; | 600 | return packet; |
2514 | 605 | } | 601 | } |
2515 | 606 | 602 | ||
2521 | 607 | gearman_return_t gearman_packet_add(gearman_st *gearman, | 603 | gearman_return_t gearman_add_packet_args(gearman_st *gearman, |
2522 | 608 | gearman_packet_st *packet, | 604 | gearman_packet_st *packet, |
2523 | 609 | gearman_magic_t magic, | 605 | gearman_magic_t magic, |
2524 | 610 | gearman_command_t command, | 606 | gearman_command_t command, |
2525 | 611 | const void *arg, ...) | 607 | const void *args[], |
2526 | 608 | const size_t args_size[], | ||
2527 | 609 | size_t args_count) | ||
2528 | 612 | { | 610 | { |
2529 | 613 | va_list ap; | ||
2530 | 614 | size_t arg_size; | ||
2531 | 615 | gearman_return_t ret; | 611 | gearman_return_t ret; |
2532 | 612 | size_t x; | ||
2533 | 616 | 613 | ||
2535 | 617 | packet= gearman_packet_create(gearman, packet); | 614 | packet= gearman_add_packet(gearman, packet); |
2536 | 618 | if (packet == NULL) | 615 | if (packet == NULL) |
2537 | 619 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | 616 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; |
2538 | 620 | 617 | ||
2539 | 621 | packet->magic= magic; | 618 | packet->magic= magic; |
2540 | 622 | packet->command= command; | 619 | packet->command= command; |
2541 | 623 | 620 | ||
2545 | 624 | va_start(ap, arg); | 621 | for (x= 0; x < args_count; x++) |
2543 | 625 | |||
2544 | 626 | while (arg != NULL) | ||
2546 | 627 | { | 622 | { |
2550 | 628 | arg_size = va_arg(ap, size_t); | 623 | ret= gearman_packet_add_arg(packet, args[x], args_size[x]); |
2548 | 629 | |||
2549 | 630 | ret= gearman_packet_add_arg(packet, arg, arg_size); | ||
2551 | 631 | if (ret != GEARMAN_SUCCESS) | 624 | if (ret != GEARMAN_SUCCESS) |
2552 | 632 | { | 625 | { |
2553 | 633 | va_end(ap); | ||
2554 | 634 | gearman_packet_free(packet); | 626 | gearman_packet_free(packet); |
2555 | 635 | return ret; | 627 | return ret; |
2556 | 636 | } | 628 | } |
2557 | 637 | |||
2558 | 638 | arg = va_arg(ap, void *); | ||
2559 | 639 | } | 629 | } |
2560 | 640 | 630 | ||
2561 | 641 | va_end(ap); | ||
2562 | 642 | |||
2563 | 643 | return gearman_packet_pack_header(packet); | 631 | return gearman_packet_pack_header(packet); |
2564 | 644 | } | 632 | } |
2565 | 645 | 633 | ||
2566 | @@ -651,11 +639,11 @@ | |||
2567 | 651 | if (packet->options & GEARMAN_PACKET_FREE_DATA && packet->data != NULL) | 639 | if (packet->options & GEARMAN_PACKET_FREE_DATA && packet->data != NULL) |
2568 | 652 | { | 640 | { |
2569 | 653 | if (packet->gearman->workload_free_fn == NULL) | 641 | if (packet->gearman->workload_free_fn == NULL) |
2571 | 654 | free((void *)(packet->data)); | 642 | free((void *)packet->data); |
2572 | 655 | else | 643 | else |
2573 | 656 | { | 644 | { |
2574 | 657 | packet->gearman->workload_free_fn((void *)(packet->data), | 645 | packet->gearman->workload_free_fn((void *)(packet->data), |
2576 | 658 | (void *)(packet->gearman->workload_free_context)); | 646 | (void *)packet->gearman->workload_free_context); |
2577 | 659 | } | 647 | } |
2578 | 660 | } | 648 | } |
2579 | 661 | 649 | ||
2580 | @@ -674,50 +662,65 @@ | |||
2581 | 674 | free(packet); | 662 | free(packet); |
2582 | 675 | } | 663 | } |
2583 | 676 | 664 | ||
2585 | 677 | void gearman_packet_free_all(gearman_st *gearman) | 665 | void gearman_free_all_packets(gearman_st *gearman) |
2586 | 678 | { | 666 | { |
2587 | 679 | while (gearman->packet_list != NULL) | 667 | while (gearman->packet_list != NULL) |
2588 | 680 | gearman_packet_free(gearman->packet_list); | 668 | gearman_packet_free(gearman->packet_list); |
2589 | 681 | } | 669 | } |
2590 | 682 | 670 | ||
2591 | 683 | /* | 671 | /* |
2593 | 684 | * Local package functions. | 672 | * Local Definitions |
2594 | 685 | */ | 673 | */ |
2596 | 686 | void gearman_error_set(gearman_st *gearman, const char *function, | 674 | |
2597 | 675 | void gearman_set_error(gearman_st *gearman, const char *function, | ||
2598 | 687 | const char *format, ...) | 676 | const char *format, ...) |
2599 | 688 | { | 677 | { |
2601 | 689 | size_t length; | 678 | size_t size; |
2602 | 690 | char *ptr; | 679 | char *ptr; |
2603 | 691 | char log_buffer[GEARMAN_MAX_ERROR_SIZE]; | 680 | char log_buffer[GEARMAN_MAX_ERROR_SIZE]; |
2613 | 692 | va_list arg; | 681 | va_list args; |
2614 | 693 | 682 | ||
2615 | 694 | va_start(arg, format); | 683 | size= strlen(function); |
2616 | 695 | 684 | ptr= memcpy(log_buffer, function, size); | |
2617 | 696 | length= strlen(function); | 685 | ptr+= size; |
2609 | 697 | |||
2610 | 698 | /* Copy the function name and : before the format */ | ||
2611 | 699 | ptr= memcpy(log_buffer, function, length); | ||
2612 | 700 | ptr+= length; | ||
2618 | 701 | ptr[0]= ':'; | 686 | ptr[0]= ':'; |
2620 | 702 | length++; | 687 | size++; |
2621 | 703 | ptr++; | 688 | ptr++; |
2622 | 704 | 689 | ||
2639 | 705 | length+= (size_t)vsnprintf(ptr, GEARMAN_MAX_ERROR_SIZE - length, format, arg); | 690 | va_start(args, format); |
2640 | 706 | 691 | size+= (size_t)vsnprintf(ptr, GEARMAN_MAX_ERROR_SIZE - size, format, args); | |
2641 | 707 | if (gearman->log_fn == NULL) | 692 | va_end(args); |
2642 | 708 | { | 693 | |
2643 | 709 | if (length >= GEARMAN_MAX_ERROR_SIZE) | 694 | if (gearman->log_fn == NULL) |
2644 | 710 | length= GEARMAN_MAX_ERROR_SIZE - 1; | 695 | { |
2645 | 711 | 696 | if (size >= GEARMAN_MAX_ERROR_SIZE) | |
2646 | 712 | memcpy(gearman->last_error, log_buffer, length + 1); | 697 | size= GEARMAN_MAX_ERROR_SIZE - 1; |
2647 | 713 | } | 698 | |
2648 | 714 | else | 699 | memcpy(gearman->last_error, log_buffer, size + 1); |
2649 | 715 | { | 700 | } |
2650 | 716 | (*(gearman->log_fn))(log_buffer, GEARMAN_VERBOSE_FATAL, | 701 | else |
2651 | 717 | (void *)(gearman)->log_context); | 702 | { |
2652 | 718 | } | 703 | gearman->log_fn(log_buffer, GEARMAN_VERBOSE_FATAL, |
2653 | 719 | 704 | (void *)gearman->log_context); | |
2654 | 720 | va_end(arg); | 705 | } |
2655 | 706 | } | ||
2656 | 707 | |||
2657 | 708 | void gearman_log(gearman_st *gearman, gearman_verbose_t verbose, | ||
2658 | 709 | const char *format, va_list args) | ||
2659 | 710 | { | ||
2660 | 711 | char log_buffer[GEARMAN_MAX_ERROR_SIZE]; | ||
2661 | 712 | |||
2662 | 713 | if (gearman->log_fn == NULL) | ||
2663 | 714 | { | ||
2664 | 715 | printf("%5s: ", gearman_verbose_name(verbose)); | ||
2665 | 716 | vprintf(format, args); | ||
2666 | 717 | printf("\n"); | ||
2667 | 718 | } | ||
2668 | 719 | else | ||
2669 | 720 | { | ||
2670 | 721 | vsnprintf(log_buffer, GEARMAN_MAX_ERROR_SIZE, format, args); | ||
2671 | 722 | gearman->log_fn(log_buffer, verbose, (void *)gearman->log_context); | ||
2672 | 723 | } | ||
2673 | 721 | } | 724 | } |
2674 | 722 | 725 | ||
2675 | 723 | gearman_return_t gearman_parse_servers(const char *servers, | 726 | gearman_return_t gearman_parse_servers(const char *servers, |
2676 | 724 | 727 | ||
2677 | === modified file 'libgearman/gearman.h' | |||
2678 | --- libgearman/gearman.h 2009-10-02 01:13:31 +0000 | |||
2679 | +++ libgearman/gearman.h 2009-11-04 22:14:14 +0000 | |||
2680 | @@ -8,7 +8,7 @@ | |||
2681 | 8 | 8 | ||
2682 | 9 | /** | 9 | /** |
2683 | 10 | * @file | 10 | * @file |
2685 | 11 | * @brief Gearman core declarations | 11 | * @brief Gearman Declarations |
2686 | 12 | */ | 12 | */ |
2687 | 13 | 13 | ||
2688 | 14 | #ifndef __GEARMAN_H__ | 14 | #ifndef __GEARMAN_H__ |
2689 | @@ -25,7 +25,6 @@ | |||
2690 | 25 | #include <arpa/inet.h> | 25 | #include <arpa/inet.h> |
2691 | 26 | #include <poll.h> | 26 | #include <poll.h> |
2692 | 27 | #include <sys/uio.h> | 27 | #include <sys/uio.h> |
2693 | 28 | #include <event.h> | ||
2694 | 29 | #include <stdarg.h> | 28 | #include <stdarg.h> |
2695 | 30 | 29 | ||
2696 | 31 | #include <libgearman/visibility.h> | 30 | #include <libgearman/visibility.h> |
2697 | @@ -43,7 +42,8 @@ | |||
2698 | 43 | #endif | 42 | #endif |
2699 | 44 | 43 | ||
2700 | 45 | /** | 44 | /** |
2702 | 46 | * @addtogroup gearman Gearman Core Interface | 45 | * @addtogroup gearman Gearman Declarations |
2703 | 46 | * | ||
2704 | 47 | * This is a low level interface for gearman library instances. This is used | 47 | * This is a low level interface for gearman library instances. This is used |
2705 | 48 | * internally by both client and worker interfaces, so you probably want to | 48 | * internally by both client and worker interfaces, so you probably want to |
2706 | 49 | * look there first. This is usually used to write lower level clients, workers, | 49 | * look there first. This is usually used to write lower level clients, workers, |
2707 | @@ -52,6 +52,7 @@ | |||
2708 | 52 | * There is no locking within a single gearman_st structure, so for threaded | 52 | * There is no locking within a single gearman_st structure, so for threaded |
2709 | 53 | * applications you must either ensure isolation in the application or use | 53 | * applications you must either ensure isolation in the application or use |
2710 | 54 | * multiple gearman_st structures (for example, one for each thread). | 54 | * multiple gearman_st structures (for example, one for each thread). |
2711 | 55 | * | ||
2712 | 55 | * @{ | 56 | * @{ |
2713 | 56 | */ | 57 | */ |
2714 | 57 | 58 | ||
2715 | @@ -266,7 +267,7 @@ | |||
2716 | 266 | * failure this will be NULL. | 267 | * failure this will be NULL. |
2717 | 267 | */ | 268 | */ |
2718 | 268 | GEARMAN_API | 269 | GEARMAN_API |
2720 | 269 | gearman_con_st *gearman_con_create(gearman_st *gearman, gearman_con_st *con); | 270 | gearman_con_st *gearman_add_con(gearman_st *gearman, gearman_con_st *con); |
2721 | 270 | 271 | ||
2722 | 271 | /** | 272 | /** |
2723 | 272 | * Create a connection structure with the given host and port. | 273 | * Create a connection structure with the given host and port. |
2724 | @@ -280,8 +281,8 @@ | |||
2725 | 280 | * failure this will be NULL. | 281 | * failure this will be NULL. |
2726 | 281 | */ | 282 | */ |
2727 | 282 | GEARMAN_API | 283 | GEARMAN_API |
2730 | 283 | gearman_con_st *gearman_con_add(gearman_st *gearman, gearman_con_st *con, | 284 | gearman_con_st *gearman_add_con_args(gearman_st *gearman, gearman_con_st *con, |
2731 | 284 | const char *host, in_port_t port); | 285 | const char *host, in_port_t port); |
2732 | 285 | 286 | ||
2733 | 286 | /** | 287 | /** |
2734 | 287 | * Clone a connection structure. | 288 | * Clone a connection structure. |
2735 | @@ -294,14 +295,14 @@ | |||
2736 | 294 | * failure this will be NULL. | 295 | * failure this will be NULL. |
2737 | 295 | */ | 296 | */ |
2738 | 296 | GEARMAN_API | 297 | GEARMAN_API |
2740 | 297 | gearman_con_st *gearman_con_clone(gearman_st *gearman, gearman_con_st *con, | 298 | gearman_con_st *gearman_clone_con(gearman_st *gearman, gearman_con_st *con, |
2741 | 298 | const gearman_con_st *from); | 299 | const gearman_con_st *from); |
2742 | 299 | 300 | ||
2743 | 300 | /** | 301 | /** |
2744 | 301 | * Free a connection structure. | 302 | * Free a connection structure. |
2745 | 302 | * | 303 | * |
2748 | 303 | * @param[in] con Structure previously initialized with gearman_con_create(), | 304 | * @param[in] con Structure previously initialized with gearman_add_con(), |
2749 | 304 | * gearman_con_add(), or gearman_con_clone(). | 305 | * gearman_add_con_args(), or gearman_clone_con(). |
2750 | 305 | */ | 306 | */ |
2751 | 306 | GEARMAN_API | 307 | GEARMAN_API |
2752 | 307 | void gearman_con_free(gearman_con_st *con); | 308 | void gearman_con_free(gearman_con_st *con); |
2753 | @@ -313,7 +314,7 @@ | |||
2754 | 313 | * gearman_clone(). | 314 | * gearman_clone(). |
2755 | 314 | */ | 315 | */ |
2756 | 315 | GEARMAN_API | 316 | GEARMAN_API |
2758 | 316 | void gearman_con_free_all(gearman_st *gearman); | 317 | void gearman_free_all_cons(gearman_st *gearman); |
2759 | 317 | 318 | ||
2760 | 318 | /** | 319 | /** |
2761 | 319 | * Flush the send buffer for all connections. | 320 | * Flush the send buffer for all connections. |
2762 | @@ -323,7 +324,7 @@ | |||
2763 | 323 | * @return Standard gearman return value. | 324 | * @return Standard gearman return value. |
2764 | 324 | */ | 325 | */ |
2765 | 325 | GEARMAN_API | 326 | GEARMAN_API |
2767 | 326 | gearman_return_t gearman_con_flush_all(gearman_st *gearman); | 327 | gearman_return_t gearman_flush_all(gearman_st *gearman); |
2768 | 327 | 328 | ||
2769 | 328 | /** | 329 | /** |
2770 | 329 | * Send packet to all connections. | 330 | * Send packet to all connections. |
2771 | @@ -334,8 +335,8 @@ | |||
2772 | 334 | * @return Standard gearman return value. | 335 | * @return Standard gearman return value. |
2773 | 335 | */ | 336 | */ |
2774 | 336 | GEARMAN_API | 337 | GEARMAN_API |
2777 | 337 | gearman_return_t gearman_con_send_all(gearman_st *gearman, | 338 | gearman_return_t gearman_send_all(gearman_st *gearman, |
2778 | 338 | const gearman_packet_st *packet); | 339 | const gearman_packet_st *packet); |
2779 | 339 | 340 | ||
2780 | 340 | /** | 341 | /** |
2781 | 341 | * Wait for I/O on connections. | 342 | * Wait for I/O on connections. |
2782 | @@ -345,7 +346,7 @@ | |||
2783 | 345 | * @return Standard gearman return value. | 346 | * @return Standard gearman return value. |
2784 | 346 | */ | 347 | */ |
2785 | 347 | GEARMAN_API | 348 | GEARMAN_API |
2787 | 348 | gearman_return_t gearman_con_wait(gearman_st *gearman); | 349 | gearman_return_t gearman_wait(gearman_st *gearman); |
2788 | 349 | 350 | ||
2789 | 350 | /** | 351 | /** |
2790 | 351 | * Get next connection that is ready for I/O. | 352 | * Get next connection that is ready for I/O. |
2791 | @@ -355,7 +356,7 @@ | |||
2792 | 355 | * @return Connection that is ready for I/O, or NULL if there are none. | 356 | * @return Connection that is ready for I/O, or NULL if there are none. |
2793 | 356 | */ | 357 | */ |
2794 | 357 | GEARMAN_API | 358 | GEARMAN_API |
2796 | 358 | gearman_con_st *gearman_con_ready(gearman_st *gearman); | 359 | gearman_con_st *gearman_ready(gearman_st *gearman); |
2797 | 359 | 360 | ||
2798 | 360 | /** | 361 | /** |
2799 | 361 | * Test echo with all connections. | 362 | * Test echo with all connections. |
2800 | @@ -367,8 +368,8 @@ | |||
2801 | 367 | * @return Standard gearman return value. | 368 | * @return Standard gearman return value. |
2802 | 368 | */ | 369 | */ |
2803 | 369 | GEARMAN_API | 370 | GEARMAN_API |
2806 | 370 | gearman_return_t gearman_con_echo(gearman_st *gearman, const void *workload, | 371 | gearman_return_t gearman_echo(gearman_st *gearman, const void *workload, |
2807 | 371 | size_t workload_size); | 372 | size_t workload_size); |
2808 | 372 | 373 | ||
2809 | 373 | /* | 374 | /* |
2810 | 374 | * Packet related functions. | 375 | * Packet related functions. |
2811 | @@ -384,20 +385,27 @@ | |||
2812 | 384 | * failure this will be NULL. | 385 | * failure this will be NULL. |
2813 | 385 | */ | 386 | */ |
2814 | 386 | GEARMAN_API | 387 | GEARMAN_API |
2817 | 387 | gearman_packet_st *gearman_packet_create(gearman_st *gearman, | 388 | gearman_packet_st *gearman_add_packet(gearman_st *gearman, |
2818 | 388 | gearman_packet_st *packet); | 389 | gearman_packet_st *packet); |
2819 | 389 | 390 | ||
2820 | 390 | /** | 391 | /** |
2823 | 391 | * Initialize a packet with all arguments. Variable list is NULL terminated | 392 | * Initialize a packet with all arguments. For example: |
2822 | 392 | * alternating argument and argument size (size_t) pairs. For example: | ||
2824 | 393 | * | 393 | * |
2825 | 394 | * @code | 394 | * @code |
2827 | 395 | * ret= gearman_packet_add_args(gearman, packet, | 395 | * void *args[3]; |
2828 | 396 | * size_t args_suze[3]; | ||
2829 | 397 | * | ||
2830 | 398 | * args[0]= function_name; | ||
2831 | 399 | * args_size[0]= strlen(function_name) + 1; | ||
2832 | 400 | * args[1]= unique_string; | ||
2833 | 401 | * args_size[1]= strlen(unique_string,) + 1; | ||
2834 | 402 | * args[2]= workload; | ||
2835 | 403 | * args_size[2]= workload_size; | ||
2836 | 404 | * | ||
2837 | 405 | * ret= gearman_add_packet_args(gearman, packet, | ||
2838 | 396 | * GEARMAN_MAGIC_REQUEST, | 406 | * GEARMAN_MAGIC_REQUEST, |
2839 | 397 | * GEARMAN_COMMAND_SUBMIT_JOB, | 407 | * GEARMAN_COMMAND_SUBMIT_JOB, |
2843 | 398 | * function_name, strlen(function_name) + 1, | 408 | * args, args_size, 3); |
2841 | 399 | * unique_string, strlen(unique_string) + 1, | ||
2842 | 400 | * workload, workload_size, NULL); | ||
2844 | 401 | * @endcode | 409 | * @endcode |
2845 | 402 | * | 410 | * |
2846 | 403 | * @param[in] gearman Structure previously initialized with gearman_create() or | 411 | * @param[in] gearman Structure previously initialized with gearman_create() or |
2847 | @@ -405,21 +413,25 @@ | |||
2848 | 405 | * @param[in] packet Pre-allocated packet to initialize with arguments. | 413 | * @param[in] packet Pre-allocated packet to initialize with arguments. |
2849 | 406 | * @param[in] magic Magic type for packet header. | 414 | * @param[in] magic Magic type for packet header. |
2850 | 407 | * @param[in] command Command type for packet. | 415 | * @param[in] command Command type for packet. |
2852 | 408 | * @param[in] arg NULL terminated argument list in pairs of "arg, arg_size". | 416 | * @param[in] args Array of arguments to add. |
2853 | 417 | * @param[in] args_size Array of sizes of each byte array in the args array. | ||
2854 | 418 | * @param[in] args_count Number of elements in args/args_sizes arrays. | ||
2855 | 409 | * @return Standard gearman return value. | 419 | * @return Standard gearman return value. |
2856 | 410 | */ | 420 | */ |
2857 | 411 | GEARMAN_API | 421 | GEARMAN_API |
2863 | 412 | gearman_return_t gearman_packet_add(gearman_st *gearman, | 422 | gearman_return_t gearman_add_packet_args(gearman_st *gearman, |
2864 | 413 | gearman_packet_st *packet, | 423 | gearman_packet_st *packet, |
2865 | 414 | gearman_magic_t magic, | 424 | gearman_magic_t magic, |
2866 | 415 | gearman_command_t command, | 425 | gearman_command_t command, |
2867 | 416 | const void *arg, ...); | 426 | const void *args[], |
2868 | 427 | const size_t args_size[], | ||
2869 | 428 | size_t args_count); | ||
2870 | 417 | 429 | ||
2871 | 418 | /** | 430 | /** |
2872 | 419 | * Free a packet structure. | 431 | * Free a packet structure. |
2873 | 420 | * | 432 | * |
2874 | 421 | * @param[in] packet Structure previously initialized with | 433 | * @param[in] packet Structure previously initialized with |
2876 | 422 | * gearman_packet_create() or gearman_packet_add(). | 434 | * gearman_add_packet() or gearman_add_packet_args(). |
2877 | 423 | */ | 435 | */ |
2878 | 424 | GEARMAN_API | 436 | GEARMAN_API |
2879 | 425 | void gearman_packet_free(gearman_packet_st *packet); | 437 | void gearman_packet_free(gearman_packet_st *packet); |
2880 | @@ -431,7 +443,7 @@ | |||
2881 | 431 | * gearman_clone(). | 443 | * gearman_clone(). |
2882 | 432 | */ | 444 | */ |
2883 | 433 | GEARMAN_API | 445 | GEARMAN_API |
2885 | 434 | void gearman_packet_free_all(gearman_st *gearman); | 446 | void gearman_free_all_packets(gearman_st *gearman); |
2886 | 435 | 447 | ||
2887 | 436 | /** @} */ | 448 | /** @} */ |
2888 | 437 | 449 | ||
2889 | 438 | 450 | ||
2890 | === added file 'libgearman/gearman_local.h' | |||
2891 | --- libgearman/gearman_local.h 1970-01-01 00:00:00 +0000 | |||
2892 | +++ libgearman/gearman_local.h 2009-11-04 22:14:14 +0000 | |||
2893 | @@ -0,0 +1,150 @@ | |||
2894 | 1 | /* Gearman server and library | ||
2895 | 2 | * Copyright (C) 2008 Brian Aker, Eric Day | ||
2896 | 3 | * All rights reserved. | ||
2897 | 4 | * | ||
2898 | 5 | * Use and distribution licensed under the BSD license. See | ||
2899 | 6 | * the COPYING file in the parent directory for full text. | ||
2900 | 7 | */ | ||
2901 | 8 | |||
2902 | 9 | /** | ||
2903 | 10 | * @file | ||
2904 | 11 | * @brief Local Gearman Declarations | ||
2905 | 12 | */ | ||
2906 | 13 | |||
2907 | 14 | #ifndef __GEARMAN_LOCAL_H__ | ||
2908 | 15 | #define __GEARMAN_LOCAL_H__ | ||
2909 | 16 | |||
2910 | 17 | #ifdef __cplusplus | ||
2911 | 18 | extern "C" { | ||
2912 | 19 | #endif | ||
2913 | 20 | |||
2914 | 21 | /** | ||
2915 | 22 | * @addtogroup gearman_local Local Gearman Declarations | ||
2916 | 23 | * @ingroup gearman | ||
2917 | 24 | * @{ | ||
2918 | 25 | */ | ||
2919 | 26 | |||
2920 | 27 | /** | ||
2921 | 28 | * Set the error string. | ||
2922 | 29 | * | ||
2923 | 30 | * @param[in] gearman Structure previously initialized with gearman_create() or | ||
2924 | 31 | * gearman_clone(). | ||
2925 | 32 | * @param[in] function Name of function the error happened in. | ||
2926 | 33 | * @param[in] format Format and variable argument list of message. | ||
2927 | 34 | */ | ||
2928 | 35 | GEARMAN_LOCAL | ||
2929 | 36 | void gearman_set_error(gearman_st *gearman, const char *function, | ||
2930 | 37 | const char *format, ...); | ||
2931 | 38 | |||
2932 | 39 | /** | ||
2933 | 40 | * Log a message. | ||
2934 | 41 | * | ||
2935 | 42 | * @param[in] gearman Structure previously initialized with gearman_create() or | ||
2936 | 43 | * gearman_clone(). | ||
2937 | 44 | * @param[in] verbose Logging level of the message. | ||
2938 | 45 | * @param[in] format Format and variable argument list of message. | ||
2939 | 46 | * @param[in] args Variable argument list that has been initialized. | ||
2940 | 47 | */ | ||
2941 | 48 | GEARMAN_LOCAL | ||
2942 | 49 | void gearman_log(gearman_st *gearman, gearman_verbose_t verbose, | ||
2943 | 50 | const char *format, va_list args); | ||
2944 | 51 | |||
2945 | 52 | /** | ||
2946 | 53 | * Log a fatal message, see gearman_log() for argument details. | ||
2947 | 54 | */ | ||
2948 | 55 | static inline void gearman_log_fatal(gearman_st *gearman, const char *format, | ||
2949 | 56 | ...) | ||
2950 | 57 | { | ||
2951 | 58 | va_list args; | ||
2952 | 59 | |||
2953 | 60 | if (gearman->verbose >= GEARMAN_VERBOSE_FATAL) | ||
2954 | 61 | { | ||
2955 | 62 | va_start(args, format); | ||
2956 | 63 | gearman_log(gearman, GEARMAN_VERBOSE_FATAL, format, args); | ||
2957 | 64 | va_end(args); | ||
2958 | 65 | } | ||
2959 | 66 | } | ||
2960 | 67 | /** | ||
2961 | 68 | * Log an error message, see gearman_log() for argument details. | ||
2962 | 69 | */ | ||
2963 | 70 | static inline void gearman_log_error(gearman_st *gearman, const char *format, | ||
2964 | 71 | ...) | ||
2965 | 72 | { | ||
2966 | 73 | va_list args; | ||
2967 | 74 | |||
2968 | 75 | if (gearman->verbose >= GEARMAN_VERBOSE_ERROR) | ||
2969 | 76 | { | ||
2970 | 77 | va_start(args, format); | ||
2971 | 78 | gearman_log(gearman, GEARMAN_VERBOSE_ERROR, format, args); | ||
2972 | 79 | va_end(args); | ||
2973 | 80 | } | ||
2974 | 81 | } | ||
2975 | 82 | |||
2976 | 83 | /** | ||
2977 | 84 | * Log an info message, see gearman_log() for argument details. | ||
2978 | 85 | */ | ||
2979 | 86 | static inline void gearman_log_info(gearman_st *gearman, const char *format, | ||
2980 | 87 | ...) | ||
2981 | 88 | { | ||
2982 | 89 | va_list args; | ||
2983 | 90 | |||
2984 | 91 | if (gearman->verbose >= GEARMAN_VERBOSE_INFO) | ||
2985 | 92 | { | ||
2986 | 93 | va_start(args, format); | ||
2987 | 94 | gearman_log(gearman, GEARMAN_VERBOSE_INFO, format, args); | ||
2988 | 95 | va_end(args); | ||
2989 | 96 | } | ||
2990 | 97 | } | ||
2991 | 98 | |||
2992 | 99 | /** | ||
2993 | 100 | * Log a debug message, see gearman_log() for argument details. | ||
2994 | 101 | */ | ||
2995 | 102 | static inline void gearman_log_debug(gearman_st *gearman, const char *format, | ||
2996 | 103 | ...) | ||
2997 | 104 | { | ||
2998 | 105 | va_list args; | ||
2999 | 106 | |||
3000 | 107 | if (gearman->verbose >= GEARMAN_VERBOSE_DEBUG) | ||
3001 | 108 | { | ||
3002 | 109 | va_start(args, format); | ||
3003 | 110 | gearman_log(gearman, GEARMAN_VERBOSE_DEBUG, format, args); | ||
3004 | 111 | va_end(args); | ||
3005 | 112 | } | ||
3006 | 113 | } | ||
3007 | 114 | |||
3008 | 115 | /** | ||
3009 | 116 | * Log a crazy message, see gearman_log() for argument details. | ||
3010 | 117 | */ | ||
3011 | 118 | static inline void gearman_log_crazy(gearman_st *gearman, const char *format, | ||
3012 | 119 | ...) | ||
3013 | 120 | { | ||
3014 | 121 | va_list args; | ||
3015 | 122 | |||
3016 | 123 | if (gearman->verbose >= GEARMAN_VERBOSE_CRAZY) | ||
3017 | 124 | { | ||
3018 | 125 | va_start(args, format); | ||
3019 | 126 | gearman_log(gearman, GEARMAN_VERBOSE_CRAZY, format, args); | ||
3020 | 127 | va_end(args); | ||
3021 | 128 | } | ||
3022 | 129 | } | ||
3023 | 130 | |||
3024 | 131 | /** | ||
3025 | 132 | * Utility function used for parsing server lists. | ||
3026 | 133 | * | ||
3027 | 134 | * @param[in] servers String containing a list of servers to parse. | ||
3028 | 135 | * @param[in] callback Function to call for each server that is found. | ||
3029 | 136 | * @param[in] context Argument to pass along with callback function. | ||
3030 | 137 | * @return Standard Gearman return value. | ||
3031 | 138 | */ | ||
3032 | 139 | GEARMAN_LOCAL | ||
3033 | 140 | gearman_return_t gearman_parse_servers(const char *servers, | ||
3034 | 141 | gearman_parse_server_fn *callback, | ||
3035 | 142 | const void *context); | ||
3036 | 143 | |||
3037 | 144 | /** @} */ | ||
3038 | 145 | |||
3039 | 146 | #ifdef __cplusplus | ||
3040 | 147 | } | ||
3041 | 148 | #endif | ||
3042 | 149 | |||
3043 | 150 | #endif /* __GEARMAN_LOCAL_H__ */ | ||
3044 | 0 | 151 | ||
3045 | === modified file 'libgearman/job.c' | |||
3046 | --- libgearman/job.c 2009-09-23 05:25:01 +0000 | |||
3047 | +++ libgearman/job.c 2009-11-04 22:14:14 +0000 | |||
3048 | @@ -8,17 +8,13 @@ | |||
3049 | 8 | 8 | ||
3050 | 9 | /** | 9 | /** |
3051 | 10 | * @file | 10 | * @file |
3053 | 11 | * @brief Job definitions | 11 | * @brief Job Definitions |
3054 | 12 | */ | 12 | */ |
3055 | 13 | 13 | ||
3056 | 14 | #include "common.h" | 14 | #include "common.h" |
3057 | 15 | 15 | ||
3058 | 16 | /* | ||
3059 | 17 | * Private declarations | ||
3060 | 18 | */ | ||
3061 | 19 | |||
3062 | 20 | /** | 16 | /** |
3064 | 21 | * @addtogroup gearman_job_private Private Job Functions | 17 | * @addtogroup gearman_job_static Static Job Declarations |
3065 | 22 | * @ingroup gearman_job | 18 | * @ingroup gearman_job |
3066 | 23 | * @{ | 19 | * @{ |
3067 | 24 | */ | 20 | */ |
3068 | @@ -31,20 +27,26 @@ | |||
3069 | 31 | /** @} */ | 27 | /** @} */ |
3070 | 32 | 28 | ||
3071 | 33 | /* | 29 | /* |
3073 | 34 | * Public definitions | 30 | * Public Definitions |
3074 | 35 | */ | 31 | */ |
3075 | 36 | 32 | ||
3076 | 37 | gearman_return_t gearman_job_send_data(gearman_job_st *job, const void *data, | 33 | gearman_return_t gearman_job_send_data(gearman_job_st *job, const void *data, |
3077 | 38 | size_t data_size) | 34 | size_t data_size) |
3078 | 39 | { | 35 | { |
3079 | 40 | gearman_return_t ret; | 36 | gearman_return_t ret; |
3080 | 37 | const void *args[2]; | ||
3081 | 38 | size_t args_size[2]; | ||
3082 | 41 | 39 | ||
3083 | 42 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) | 40 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) |
3084 | 43 | { | 41 | { |
3089 | 44 | ret= gearman_packet_add(job->worker->gearman, &(job->work), | 42 | args[0]= job->assigned.arg[0]; |
3090 | 45 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_WORK_DATA, | 43 | args_size[0]= job->assigned.arg_size[0]; |
3091 | 46 | job->assigned.arg[0], job->assigned.arg_size[0], | 44 | args[1]= data; |
3092 | 47 | data, data_size, NULL); | 45 | args_size[1]= data_size; |
3093 | 46 | ret= gearman_add_packet_args(job->worker->gearman, &(job->work), | ||
3094 | 47 | GEARMAN_MAGIC_REQUEST, | ||
3095 | 48 | GEARMAN_COMMAND_WORK_DATA, | ||
3096 | 49 | args, args_size, 2); | ||
3097 | 48 | if (ret != GEARMAN_SUCCESS) | 50 | if (ret != GEARMAN_SUCCESS) |
3098 | 49 | return ret; | 51 | return ret; |
3099 | 50 | 52 | ||
3100 | @@ -59,13 +61,19 @@ | |||
3101 | 59 | size_t warning_size) | 61 | size_t warning_size) |
3102 | 60 | { | 62 | { |
3103 | 61 | gearman_return_t ret; | 63 | gearman_return_t ret; |
3104 | 64 | const void *args[2]; | ||
3105 | 65 | size_t args_size[2]; | ||
3106 | 62 | 66 | ||
3107 | 63 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) | 67 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) |
3108 | 64 | { | 68 | { |
3113 | 65 | ret= gearman_packet_add(job->worker->gearman, &(job->work), | 69 | args[0]= job->assigned.arg[0]; |
3114 | 66 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_WORK_WARNING, | 70 | args_size[0]= job->assigned.arg_size[0]; |
3115 | 67 | job->assigned.arg[0], job->assigned.arg_size[0], | 71 | args[1]= warning; |
3116 | 68 | warning, warning_size, NULL); | 72 | args_size[1]= warning_size; |
3117 | 73 | ret= gearman_add_packet_args(job->worker->gearman, &(job->work), | ||
3118 | 74 | GEARMAN_MAGIC_REQUEST, | ||
3119 | 75 | GEARMAN_COMMAND_WORK_WARNING, | ||
3120 | 76 | args, args_size, 2); | ||
3121 | 69 | if (ret != GEARMAN_SUCCESS) | 77 | if (ret != GEARMAN_SUCCESS) |
3122 | 70 | return ret; | 78 | return ret; |
3123 | 71 | 79 | ||
3124 | @@ -82,18 +90,24 @@ | |||
3125 | 82 | gearman_return_t ret; | 90 | gearman_return_t ret; |
3126 | 83 | char numerator_string[12]; | 91 | char numerator_string[12]; |
3127 | 84 | char denominator_string[12]; | 92 | char denominator_string[12]; |
3128 | 93 | const void *args[3]; | ||
3129 | 94 | size_t args_size[3]; | ||
3130 | 85 | 95 | ||
3131 | 86 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) | 96 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) |
3132 | 87 | { | 97 | { |
3133 | 88 | snprintf(numerator_string, 12, "%u", numerator); | 98 | snprintf(numerator_string, 12, "%u", numerator); |
3134 | 89 | snprintf(denominator_string, 12, "%u", denominator); | 99 | snprintf(denominator_string, 12, "%u", denominator); |
3135 | 90 | 100 | ||
3142 | 91 | ret= gearman_packet_add(job->worker->gearman, &(job->work), | 101 | args[0]= job->assigned.arg[0]; |
3143 | 92 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_WORK_STATUS, | 102 | args_size[0]= job->assigned.arg_size[0]; |
3144 | 93 | job->assigned.arg[0], job->assigned.arg_size[0], | 103 | args[1]= numerator_string; |
3145 | 94 | numerator_string, strlen(numerator_string) + 1, | 104 | args_size[1]= strlen(numerator_string) + 1; |
3146 | 95 | denominator_string, strlen(denominator_string), | 105 | args[2]= denominator_string; |
3147 | 96 | NULL); | 106 | args_size[2]= strlen(denominator_string); |
3148 | 107 | ret= gearman_add_packet_args(job->worker->gearman, &(job->work), | ||
3149 | 108 | GEARMAN_MAGIC_REQUEST, | ||
3150 | 109 | GEARMAN_COMMAND_WORK_STATUS, | ||
3151 | 110 | args, args_size, 3); | ||
3152 | 97 | if (ret != GEARMAN_SUCCESS) | 111 | if (ret != GEARMAN_SUCCESS) |
3153 | 98 | return ret; | 112 | return ret; |
3154 | 99 | 113 | ||
3155 | @@ -108,17 +122,22 @@ | |||
3156 | 108 | size_t result_size) | 122 | size_t result_size) |
3157 | 109 | { | 123 | { |
3158 | 110 | gearman_return_t ret; | 124 | gearman_return_t ret; |
3159 | 125 | const void *args[2]; | ||
3160 | 126 | size_t args_size[2]; | ||
3161 | 111 | 127 | ||
3162 | 112 | if (job->options & GEARMAN_JOB_FINISHED) | 128 | if (job->options & GEARMAN_JOB_FINISHED) |
3163 | 113 | return GEARMAN_SUCCESS; | 129 | return GEARMAN_SUCCESS; |
3164 | 114 | 130 | ||
3165 | 115 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) | 131 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) |
3166 | 116 | { | 132 | { |
3172 | 117 | ret= gearman_packet_add(job->worker->gearman, &(job->work), | 133 | args[0]= job->assigned.arg[0]; |
3173 | 118 | GEARMAN_MAGIC_REQUEST, | 134 | args_size[0]= job->assigned.arg_size[0]; |
3174 | 119 | GEARMAN_COMMAND_WORK_COMPLETE, | 135 | args[1]= result; |
3175 | 120 | job->assigned.arg[0], job->assigned.arg_size[0], | 136 | args_size[1]= result_size; |
3176 | 121 | result, result_size, NULL); | 137 | ret= gearman_add_packet_args(job->worker->gearman, &(job->work), |
3177 | 138 | GEARMAN_MAGIC_REQUEST, | ||
3178 | 139 | GEARMAN_COMMAND_WORK_COMPLETE, | ||
3179 | 140 | args, args_size, 2); | ||
3180 | 122 | if (ret != GEARMAN_SUCCESS) | 141 | if (ret != GEARMAN_SUCCESS) |
3181 | 123 | return ret; | 142 | return ret; |
3182 | 124 | 143 | ||
3183 | @@ -138,14 +157,19 @@ | |||
3184 | 138 | size_t exception_size) | 157 | size_t exception_size) |
3185 | 139 | { | 158 | { |
3186 | 140 | gearman_return_t ret; | 159 | gearman_return_t ret; |
3187 | 160 | const void *args[2]; | ||
3188 | 161 | size_t args_size[2]; | ||
3189 | 141 | 162 | ||
3190 | 142 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) | 163 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) |
3191 | 143 | { | 164 | { |
3197 | 144 | ret= gearman_packet_add(job->worker->gearman, &(job->work), | 165 | args[0]= job->assigned.arg[0]; |
3198 | 145 | GEARMAN_MAGIC_REQUEST, | 166 | args_size[0]= job->assigned.arg_size[0]; |
3199 | 146 | GEARMAN_COMMAND_WORK_EXCEPTION, | 167 | args[1]= exception; |
3200 | 147 | job->assigned.arg[0], job->assigned.arg_size[0], | 168 | args_size[1]= exception_size; |
3201 | 148 | exception, exception_size, NULL); | 169 | ret= gearman_add_packet_args(job->worker->gearman, &(job->work), |
3202 | 170 | GEARMAN_MAGIC_REQUEST, | ||
3203 | 171 | GEARMAN_COMMAND_WORK_EXCEPTION, | ||
3204 | 172 | args, args_size, 2); | ||
3205 | 149 | if (ret != GEARMAN_SUCCESS) | 173 | if (ret != GEARMAN_SUCCESS) |
3206 | 150 | return ret; | 174 | return ret; |
3207 | 151 | 175 | ||
3208 | @@ -158,16 +182,20 @@ | |||
3209 | 158 | gearman_return_t gearman_job_send_fail(gearman_job_st *job) | 182 | gearman_return_t gearman_job_send_fail(gearman_job_st *job) |
3210 | 159 | { | 183 | { |
3211 | 160 | gearman_return_t ret; | 184 | gearman_return_t ret; |
3212 | 185 | const void *args[1]; | ||
3213 | 186 | size_t args_size[1]; | ||
3214 | 161 | 187 | ||
3215 | 162 | if (job->options & GEARMAN_JOB_FINISHED) | 188 | if (job->options & GEARMAN_JOB_FINISHED) |
3216 | 163 | return GEARMAN_SUCCESS; | 189 | return GEARMAN_SUCCESS; |
3217 | 164 | 190 | ||
3218 | 165 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) | 191 | if (!(job->options & GEARMAN_JOB_WORK_IN_USE)) |
3219 | 166 | { | 192 | { |
3224 | 167 | ret= gearman_packet_add(job->worker->gearman, &(job->work), | 193 | args[0]= job->assigned.arg[0]; |
3225 | 168 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_WORK_FAIL, | 194 | args_size[0]= job->assigned.arg_size[0] - 1; |
3226 | 169 | job->assigned.arg[0], job->assigned.arg_size[0] - 1, | 195 | ret= gearman_add_packet_args(job->worker->gearman, &(job->work), |
3227 | 170 | NULL); | 196 | GEARMAN_MAGIC_REQUEST, |
3228 | 197 | GEARMAN_COMMAND_WORK_FAIL, | ||
3229 | 198 | args, args_size, 2); | ||
3230 | 171 | if (ret != GEARMAN_SUCCESS) | 199 | if (ret != GEARMAN_SUCCESS) |
3231 | 172 | return ret; | 200 | return ret; |
3232 | 173 | 201 | ||
3233 | @@ -215,7 +243,7 @@ | |||
3234 | 215 | } | 243 | } |
3235 | 216 | 244 | ||
3236 | 217 | /* | 245 | /* |
3238 | 218 | * Private definitions | 246 | * Static Definitions |
3239 | 219 | */ | 247 | */ |
3240 | 220 | 248 | ||
3241 | 221 | static gearman_return_t _job_send(gearman_job_st *job) | 249 | static gearman_return_t _job_send(gearman_job_st *job) |
3242 | 222 | 250 | ||
3243 | === modified file 'libgearman/job.h' | |||
3244 | --- libgearman/job.h 2009-09-23 05:25:01 +0000 | |||
3245 | +++ libgearman/job.h 2009-11-04 22:14:14 +0000 | |||
3246 | @@ -8,7 +8,7 @@ | |||
3247 | 8 | 8 | ||
3248 | 9 | /** | 9 | /** |
3249 | 10 | * @file | 10 | * @file |
3251 | 11 | * @brief Job declarations | 11 | * @brief Job Declarations |
3252 | 12 | */ | 12 | */ |
3253 | 13 | 13 | ||
3254 | 14 | #ifndef __GEARMAN_JOB_H__ | 14 | #ifndef __GEARMAN_JOB_H__ |
3255 | @@ -19,10 +19,12 @@ | |||
3256 | 19 | #endif | 19 | #endif |
3257 | 20 | 20 | ||
3258 | 21 | /** | 21 | /** |
3260 | 22 | * @addtogroup gearman_job Job Management | 22 | * @addtogroup gearman_job Job Declarations |
3261 | 23 | * @ingroup gearman_worker | 23 | * @ingroup gearman_worker |
3262 | 24 | * | ||
3263 | 24 | * The job functions are used to manage jobs assigned to workers. It is most | 25 | * The job functions are used to manage jobs assigned to workers. It is most |
3264 | 25 | * commonly used with the worker interface. | 26 | * commonly used with the worker interface. |
3265 | 27 | * | ||
3266 | 26 | * @{ | 28 | * @{ |
3267 | 27 | */ | 29 | */ |
3268 | 28 | 30 | ||
3269 | 29 | 31 | ||
3270 | === modified file 'libgearman/packet.c' | |||
3271 | --- libgearman/packet.c 2009-09-26 08:14:01 +0000 | |||
3272 | +++ libgearman/packet.c 2009-11-04 22:14:14 +0000 | |||
3273 | @@ -8,17 +8,13 @@ | |||
3274 | 8 | 8 | ||
3275 | 9 | /** | 9 | /** |
3276 | 10 | * @file | 10 | * @file |
3278 | 11 | * @brief Packet definitions | 11 | * @brief Packet Definitions |
3279 | 12 | */ | 12 | */ |
3280 | 13 | 13 | ||
3281 | 14 | #include "common.h" | 14 | #include "common.h" |
3282 | 15 | 15 | ||
3283 | 16 | /* | ||
3284 | 17 | * Private declarations | ||
3285 | 18 | */ | ||
3286 | 19 | |||
3287 | 20 | /** | 16 | /** |
3289 | 21 | * @addtogroup gearman_packet_private Private Packet Functions | 17 | * @addtogroup gearman_packet_static Static Packet Declarations |
3290 | 22 | * @ingroup gearman_packet | 18 | * @ingroup gearman_packet |
3291 | 23 | * @{ | 19 | * @{ |
3292 | 24 | */ | 20 | */ |
3293 | @@ -71,7 +67,7 @@ | |||
3294 | 71 | /** @} */ | 67 | /** @} */ |
3295 | 72 | 68 | ||
3296 | 73 | /* | 69 | /* |
3298 | 74 | * Public definitions | 70 | * Public Definitions |
3299 | 75 | */ | 71 | */ |
3300 | 76 | 72 | ||
3301 | 77 | gearman_return_t gearman_packet_add_arg(gearman_packet_st *packet, | 73 | gearman_return_t gearman_packet_add_arg(gearman_packet_st *packet, |
3302 | @@ -85,7 +81,7 @@ | |||
3303 | 85 | (!(gearman_command_info_list[packet->command].data) || | 81 | (!(gearman_command_info_list[packet->command].data) || |
3304 | 86 | packet->data != NULL)) | 82 | packet->data != NULL)) |
3305 | 87 | { | 83 | { |
3307 | 88 | gearman_error_set(packet->gearman, "gearman_packet_add_arg", | 84 | gearman_set_error(packet->gearman, "gearman_packet_add_arg", |
3308 | 89 | "too many arguments for command"); | 85 | "too many arguments for command"); |
3309 | 90 | return GEARMAN_TOO_MANY_ARGS; | 86 | return GEARMAN_TOO_MANY_ARGS; |
3310 | 91 | } | 87 | } |
3311 | @@ -110,7 +106,7 @@ | |||
3312 | 110 | new_args= realloc(packet->args, packet->args_size + arg_size); | 106 | new_args= realloc(packet->args, packet->args_size + arg_size); |
3313 | 111 | if (new_args == NULL) | 107 | if (new_args == NULL) |
3314 | 112 | { | 108 | { |
3316 | 113 | gearman_error_set(packet->gearman, "gearman_packet_add_arg", "realloc"); | 109 | gearman_set_error(packet->gearman, "gearman_packet_add_arg", "realloc"); |
3317 | 114 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | 110 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; |
3318 | 115 | } | 111 | } |
3319 | 116 | 112 | ||
3320 | @@ -169,7 +165,7 @@ | |||
3321 | 169 | break; | 165 | break; |
3322 | 170 | 166 | ||
3323 | 171 | default: | 167 | default: |
3325 | 172 | gearman_error_set(packet->gearman, "gearman_packet_pack_header", | 168 | gearman_set_error(packet->gearman, "gearman_packet_pack_header", |
3326 | 173 | "invalid magic value"); | 169 | "invalid magic value"); |
3327 | 174 | return GEARMAN_INVALID_MAGIC; | 170 | return GEARMAN_INVALID_MAGIC; |
3328 | 175 | } | 171 | } |
3329 | @@ -177,7 +173,7 @@ | |||
3330 | 177 | if (packet->command == GEARMAN_COMMAND_TEXT || | 173 | if (packet->command == GEARMAN_COMMAND_TEXT || |
3331 | 178 | packet->command >= GEARMAN_COMMAND_MAX) | 174 | packet->command >= GEARMAN_COMMAND_MAX) |
3332 | 179 | { | 175 | { |
3334 | 180 | gearman_error_set(packet->gearman, "gearman_packet_pack_header", | 176 | gearman_set_error(packet->gearman, "gearman_packet_pack_header", |
3335 | 181 | "invalid command value"); | 177 | "invalid command value"); |
3336 | 182 | return GEARMAN_INVALID_COMMAND; | 178 | return GEARMAN_INVALID_COMMAND; |
3337 | 183 | } | 179 | } |
3338 | @@ -206,7 +202,7 @@ | |||
3339 | 206 | packet->magic= GEARMAN_MAGIC_RESPONSE; | 202 | packet->magic= GEARMAN_MAGIC_RESPONSE; |
3340 | 207 | else | 203 | else |
3341 | 208 | { | 204 | { |
3343 | 209 | gearman_error_set(packet->gearman, "gearman_packet_unpack_header", | 205 | gearman_set_error(packet->gearman, "gearman_packet_unpack_header", |
3344 | 210 | "invalid magic value"); | 206 | "invalid magic value"); |
3345 | 211 | return GEARMAN_INVALID_MAGIC; | 207 | return GEARMAN_INVALID_MAGIC; |
3346 | 212 | } | 208 | } |
3347 | @@ -217,7 +213,7 @@ | |||
3348 | 217 | if (packet->command == GEARMAN_COMMAND_TEXT || | 213 | if (packet->command == GEARMAN_COMMAND_TEXT || |
3349 | 218 | packet->command >= GEARMAN_COMMAND_MAX) | 214 | packet->command >= GEARMAN_COMMAND_MAX) |
3350 | 219 | { | 215 | { |
3352 | 220 | gearman_error_set(packet->gearman, "gearman_packet_unpack_header", | 216 | gearman_set_error(packet->gearman, "gearman_packet_unpack_header", |
3353 | 221 | "invalid command value"); | 217 | "invalid command value"); |
3354 | 222 | return GEARMAN_INVALID_COMMAND; | 218 | return GEARMAN_INVALID_COMMAND; |
3355 | 223 | } | 219 | } |
3356 | 224 | 220 | ||
3357 | === modified file 'libgearman/packet.h' | |||
3358 | --- libgearman/packet.h 2009-09-24 23:43:15 +0000 | |||
3359 | +++ libgearman/packet.h 2009-11-04 22:14:14 +0000 | |||
3360 | @@ -8,7 +8,7 @@ | |||
3361 | 8 | 8 | ||
3362 | 9 | /** | 9 | /** |
3363 | 10 | * @file | 10 | * @file |
3365 | 11 | * @brief Packet declarations | 11 | * @brief Packet Declarations |
3366 | 12 | */ | 12 | */ |
3367 | 13 | 13 | ||
3368 | 14 | #ifndef __GEARMAN_PACKET_H__ | 14 | #ifndef __GEARMAN_PACKET_H__ |
3369 | @@ -26,11 +26,14 @@ | |||
3370 | 26 | gearman_command_info_st gearman_command_info_list[GEARMAN_COMMAND_MAX]; | 26 | gearman_command_info_st gearman_command_info_list[GEARMAN_COMMAND_MAX]; |
3371 | 27 | 27 | ||
3372 | 28 | /** | 28 | /** |
3374 | 29 | * @addtogroup gearman_packet Packet Handling | 29 | * @addtogroup gearman_packet Packet Declarations |
3375 | 30 | * @ingroup gearman | ||
3376 | 31 | * | ||
3377 | 30 | * This is a low level interface for gearman packet. This is used internally | 32 | * This is a low level interface for gearman packet. This is used internally |
3378 | 31 | * internally by both client and worker interfaces (or more specifically, tasks | 33 | * internally by both client and worker interfaces (or more specifically, tasks |
3379 | 32 | * and jobs), so you probably want to look there first. This is usually used to | 34 | * and jobs), so you probably want to look there first. This is usually used to |
3380 | 33 | * write lower level clients, workers, proxies, or your own server. | 35 | * write lower level clients, workers, proxies, or your own server. |
3381 | 36 | * | ||
3382 | 34 | * @{ | 37 | * @{ |
3383 | 35 | */ | 38 | */ |
3384 | 36 | 39 | ||
3385 | 37 | 40 | ||
3386 | === modified file 'libgearman/structs.h' | |||
3387 | --- libgearman/structs.h 2009-09-28 17:47:34 +0000 | |||
3388 | +++ libgearman/structs.h 2009-11-04 22:14:14 +0000 | |||
3389 | @@ -8,7 +8,7 @@ | |||
3390 | 8 | 8 | ||
3391 | 9 | /** | 9 | /** |
3392 | 10 | * @file | 10 | * @file |
3394 | 11 | * @brief Struct definitions | 11 | * @brief Struct Definitions |
3395 | 12 | */ | 12 | */ |
3396 | 13 | 13 | ||
3397 | 14 | #ifndef __GEARMAN_STRUCTS_H__ | 14 | #ifndef __GEARMAN_STRUCTS_H__ |
3398 | 15 | 15 | ||
3399 | === modified file 'libgearman/task.c' | |||
3400 | --- libgearman/task.c 2009-09-23 05:25:01 +0000 | |||
3401 | +++ libgearman/task.c 2009-11-04 22:14:14 +0000 | |||
3402 | @@ -8,13 +8,13 @@ | |||
3403 | 8 | 8 | ||
3404 | 9 | /** | 9 | /** |
3405 | 10 | * @file | 10 | * @file |
3407 | 11 | * @brief Task definitions | 11 | * @brief Task Definitions |
3408 | 12 | */ | 12 | */ |
3409 | 13 | 13 | ||
3410 | 14 | #include "common.h" | 14 | #include "common.h" |
3411 | 15 | 15 | ||
3412 | 16 | /* | 16 | /* |
3414 | 17 | * Public definitions | 17 | * Public Definitions |
3415 | 18 | */ | 18 | */ |
3416 | 19 | 19 | ||
3417 | 20 | void *gearman_task_context(const gearman_task_st *task) | 20 | void *gearman_task_context(const gearman_task_st *task) |
3418 | 21 | 21 | ||
3419 | === modified file 'libgearman/task.h' | |||
3420 | --- libgearman/task.h 2009-09-23 05:25:01 +0000 | |||
3421 | +++ libgearman/task.h 2009-11-04 22:14:14 +0000 | |||
3422 | @@ -8,7 +8,7 @@ | |||
3423 | 8 | 8 | ||
3424 | 9 | /** | 9 | /** |
3425 | 10 | * @file | 10 | * @file |
3427 | 11 | * @brief Task declarations | 11 | * @brief Task Declarations |
3428 | 12 | */ | 12 | */ |
3429 | 13 | 13 | ||
3430 | 14 | #ifndef __GEARMAN_TASK_H__ | 14 | #ifndef __GEARMAN_TASK_H__ |
3431 | @@ -19,10 +19,12 @@ | |||
3432 | 19 | #endif | 19 | #endif |
3433 | 20 | 20 | ||
3434 | 21 | /** | 21 | /** |
3436 | 22 | * @addtogroup gearman_task Task Management | 22 | * @addtogroup gearman_task Task Declarations |
3437 | 23 | * @ingroup gearman_client | 23 | * @ingroup gearman_client |
3438 | 24 | * | ||
3439 | 24 | * The task functions are used to manage tasks being run by clients. They are | 25 | * The task functions are used to manage tasks being run by clients. They are |
3440 | 25 | * most commonly used with the client interface. | 26 | * most commonly used with the client interface. |
3441 | 27 | * | ||
3442 | 26 | * @{ | 28 | * @{ |
3443 | 27 | */ | 29 | */ |
3444 | 28 | 30 | ||
3445 | 29 | 31 | ||
3446 | === modified file 'libgearman/visibility.h' | |||
3447 | --- libgearman/visibility.h 2009-09-18 02:48:06 +0000 | |||
3448 | +++ libgearman/visibility.h 2009-11-04 22:14:14 +0000 | |||
3449 | @@ -10,14 +10,13 @@ | |||
3450 | 10 | 10 | ||
3451 | 11 | /** | 11 | /** |
3452 | 12 | * @file | 12 | * @file |
3454 | 13 | * @brief Visibility control macros | 13 | * @brief Visibility Control Macros |
3455 | 14 | */ | 14 | */ |
3456 | 15 | 15 | ||
3457 | 16 | #ifndef __GEARMAN_VISIBILITY_H | 16 | #ifndef __GEARMAN_VISIBILITY_H |
3458 | 17 | #define __GEARMAN_VISIBILITY_H | 17 | #define __GEARMAN_VISIBILITY_H |
3459 | 18 | 18 | ||
3460 | 19 | /** | 19 | /** |
3461 | 20 | * | ||
3462 | 21 | * GEARMAN_API is used for the public API symbols. It either DLL imports or | 20 | * GEARMAN_API is used for the public API symbols. It either DLL imports or |
3463 | 22 | * DLL exports (or does nothing for static build). | 21 | * DLL exports (or does nothing for static build). |
3464 | 23 | * | 22 | * |
3465 | @@ -28,6 +27,9 @@ | |||
3466 | 28 | # if defined(HAVE_VISIBILITY) | 27 | # if defined(HAVE_VISIBILITY) |
3467 | 29 | # define GEARMAN_API __attribute__ ((visibility("default"))) | 28 | # define GEARMAN_API __attribute__ ((visibility("default"))) |
3468 | 30 | # define GEARMAN_LOCAL __attribute__ ((visibility("hidden"))) | 29 | # define GEARMAN_LOCAL __attribute__ ((visibility("hidden"))) |
3469 | 30 | # elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) | ||
3470 | 31 | # define GEARMAN_API __global | ||
3471 | 32 | # define GEARMAN_API __hidden | ||
3472 | 31 | # elif defined(_MSC_VER) | 33 | # elif defined(_MSC_VER) |
3473 | 32 | # define GEARMAN_API extern __declspec(dllexport) | 34 | # define GEARMAN_API extern __declspec(dllexport) |
3474 | 33 | # define GEARMAN_LOCAL | 35 | # define GEARMAN_LOCAL |
3475 | 34 | 36 | ||
3476 | === modified file 'libgearman/worker.c' | |||
3477 | --- libgearman/worker.c 2009-09-28 17:47:34 +0000 | |||
3478 | +++ libgearman/worker.c 2009-11-04 22:14:14 +0000 | |||
3479 | @@ -8,17 +8,13 @@ | |||
3480 | 8 | 8 | ||
3481 | 9 | /** | 9 | /** |
3482 | 10 | * @file | 10 | * @file |
3484 | 11 | * @brief Worker definitions | 11 | * @brief Worker Definitions |
3485 | 12 | */ | 12 | */ |
3486 | 13 | 13 | ||
3487 | 14 | #include "common.h" | 14 | #include "common.h" |
3488 | 15 | 15 | ||
3489 | 16 | /* | ||
3490 | 17 | * Private declarations | ||
3491 | 18 | */ | ||
3492 | 19 | |||
3493 | 20 | /** | 16 | /** |
3495 | 21 | * @addtogroup gearman_worker_private Private Worker Functions | 17 | * @addtogroup gearman_worker_static Static Worker Declarations |
3496 | 22 | * @ingroup gearman_worker | 18 | * @ingroup gearman_worker |
3497 | 23 | * @{ | 19 | * @{ |
3498 | 24 | */ | 20 | */ |
3499 | @@ -63,7 +59,7 @@ | |||
3500 | 63 | /** @} */ | 59 | /** @} */ |
3501 | 64 | 60 | ||
3502 | 65 | /* | 61 | /* |
3504 | 66 | * Public definitions | 62 | * Public Definitions |
3505 | 67 | */ | 63 | */ |
3506 | 68 | 64 | ||
3507 | 69 | gearman_worker_st *gearman_worker_create(gearman_worker_st *worker) | 65 | gearman_worker_st *gearman_worker_create(gearman_worker_st *worker) |
3508 | @@ -140,7 +136,7 @@ | |||
3509 | 140 | else | 136 | else |
3510 | 141 | { | 137 | { |
3511 | 142 | worker->gearman->workload_free_fn(worker->work_result, | 138 | worker->gearman->workload_free_fn(worker->work_result, |
3513 | 143 | (void *)(worker->gearman->workload_free_context)); | 139 | (void *)worker->gearman->workload_free_context); |
3514 | 144 | } | 140 | } |
3515 | 145 | } | 141 | } |
3516 | 146 | 142 | ||
3517 | @@ -262,7 +258,7 @@ | |||
3518 | 262 | gearman_return_t gearman_worker_add_server(gearman_worker_st *worker, | 258 | gearman_return_t gearman_worker_add_server(gearman_worker_st *worker, |
3519 | 263 | const char *host, in_port_t port) | 259 | const char *host, in_port_t port) |
3520 | 264 | { | 260 | { |
3522 | 265 | if (gearman_con_add(worker->gearman, NULL, host, port) == NULL) | 261 | if (gearman_add_con_args(worker->gearman, NULL, host, port) == NULL) |
3523 | 266 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | 262 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; |
3524 | 267 | 263 | ||
3525 | 268 | return GEARMAN_SUCCESS; | 264 | return GEARMAN_SUCCESS; |
3526 | @@ -274,9 +270,14 @@ | |||
3527 | 274 | return gearman_parse_servers(servers, _worker_add_server, worker); | 270 | return gearman_parse_servers(servers, _worker_add_server, worker); |
3528 | 275 | } | 271 | } |
3529 | 276 | 272 | ||
3530 | 273 | void gearman_worker_remove_servers(gearman_worker_st *worker) | ||
3531 | 274 | { | ||
3532 | 275 | gearman_free_all_cons(worker->gearman); | ||
3533 | 276 | } | ||
3534 | 277 | |||
3535 | 277 | gearman_return_t gearman_worker_wait(gearman_worker_st *worker) | 278 | gearman_return_t gearman_worker_wait(gearman_worker_st *worker) |
3536 | 278 | { | 279 | { |
3538 | 279 | return gearman_con_wait(worker->gearman); | 280 | return gearman_wait(worker->gearman); |
3539 | 280 | } | 281 | } |
3540 | 281 | 282 | ||
3541 | 282 | gearman_return_t gearman_worker_register(gearman_worker_st *worker, | 283 | gearman_return_t gearman_worker_register(gearman_worker_st *worker, |
3542 | @@ -291,6 +292,8 @@ | |||
3543 | 291 | { | 292 | { |
3544 | 292 | gearman_worker_function_st *function; | 293 | gearman_worker_function_st *function; |
3545 | 293 | gearman_return_t ret; | 294 | gearman_return_t ret; |
3546 | 295 | const void *args[1]; | ||
3547 | 296 | size_t args_size[1]; | ||
3548 | 294 | 297 | ||
3549 | 295 | for (function= worker->function_list; function != NULL; | 298 | for (function= worker->function_list; function != NULL; |
3550 | 296 | function= function->next) | 299 | function= function->next) |
3551 | @@ -304,10 +307,11 @@ | |||
3552 | 304 | 307 | ||
3553 | 305 | gearman_packet_free(&(function->packet)); | 308 | gearman_packet_free(&(function->packet)); |
3554 | 306 | 309 | ||
3559 | 307 | ret= gearman_packet_add(worker->gearman, &(function->packet), | 310 | args[0]= function_name; |
3560 | 308 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_CANT_DO, | 311 | args_size[0]= strlen(function_name); |
3561 | 309 | (uint8_t *)function_name, strlen(function_name), | 312 | ret= gearman_add_packet_args(worker->gearman, &(function->packet), |
3562 | 310 | NULL); | 313 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_CANT_DO, |
3563 | 314 | args, args_size, 1); | ||
3564 | 311 | if (ret != GEARMAN_SUCCESS) | 315 | if (ret != GEARMAN_SUCCESS) |
3565 | 312 | { | 316 | { |
3566 | 313 | function->options&= | 317 | function->options&= |
3567 | @@ -335,9 +339,11 @@ | |||
3568 | 335 | 339 | ||
3569 | 336 | gearman_packet_free(&(worker->function_list->packet)); | 340 | gearman_packet_free(&(worker->function_list->packet)); |
3570 | 337 | 341 | ||
3574 | 338 | ret= gearman_packet_add(worker->gearman, &(worker->function_list->packet), | 342 | ret= gearman_add_packet_args(worker->gearman, |
3575 | 339 | GEARMAN_MAGIC_REQUEST, | 343 | &(worker->function_list->packet), |
3576 | 340 | GEARMAN_COMMAND_RESET_ABILITIES, NULL); | 344 | GEARMAN_MAGIC_REQUEST, |
3577 | 345 | GEARMAN_COMMAND_RESET_ABILITIES, | ||
3578 | 346 | NULL, NULL, 0); | ||
3579 | 341 | if (ret != GEARMAN_SUCCESS) | 347 | if (ret != GEARMAN_SUCCESS) |
3580 | 342 | { | 348 | { |
3581 | 343 | worker->function_list->options&= | 349 | worker->function_list->options&= |
3582 | @@ -419,7 +425,7 @@ | |||
3583 | 419 | 425 | ||
3584 | 420 | if (worker->function_list == NULL) | 426 | if (worker->function_list == NULL) |
3585 | 421 | { | 427 | { |
3587 | 422 | gearman_error_set(worker->gearman, "gearman_worker_grab_job", | 428 | gearman_set_error(worker->gearman, "gearman_worker_grab_job", |
3588 | 423 | "no functions have been registered"); | 429 | "no functions have been registered"); |
3589 | 424 | *ret_ptr= GEARMAN_NO_REGISTERED_FUNCTIONS; | 430 | *ret_ptr= GEARMAN_NO_REGISTERED_FUNCTIONS; |
3590 | 425 | return NULL; | 431 | return NULL; |
3591 | @@ -521,7 +527,7 @@ | |||
3592 | 521 | 527 | ||
3593 | 522 | if (worker->job->assigned.command != GEARMAN_COMMAND_NOOP) | 528 | if (worker->job->assigned.command != GEARMAN_COMMAND_NOOP) |
3594 | 523 | { | 529 | { |
3596 | 524 | gearman_error_set(worker->gearman, "gearman_worker_grab_job", | 530 | gearman_set_error(worker->gearman, "gearman_worker_grab_job", |
3597 | 525 | "unexpected packet:%s", | 531 | "unexpected packet:%s", |
3598 | 526 | gearman_command_info_list[worker->job->assigned.command].name); | 532 | gearman_command_info_list[worker->job->assigned.command].name); |
3599 | 527 | gearman_packet_free(&(worker->job->assigned)); | 533 | gearman_packet_free(&(worker->job->assigned)); |
3600 | @@ -588,7 +594,7 @@ | |||
3601 | 588 | 594 | ||
3602 | 589 | if (worker->options & GEARMAN_WORKER_TIMEOUT_RETURN) | 595 | if (worker->options & GEARMAN_WORKER_TIMEOUT_RETURN) |
3603 | 590 | { | 596 | { |
3605 | 591 | gearman_error_set(worker->gearman, "gearman_worker_grab_job", | 597 | gearman_set_error(worker->gearman, "gearman_worker_grab_job", |
3606 | 592 | "timeout reached"); | 598 | "timeout reached"); |
3607 | 593 | *ret_ptr= GEARMAN_TIMEOUT; | 599 | *ret_ptr= GEARMAN_TIMEOUT; |
3608 | 594 | return NULL; | 600 | return NULL; |
3609 | @@ -597,7 +603,7 @@ | |||
3610 | 597 | } | 603 | } |
3611 | 598 | else | 604 | else |
3612 | 599 | { | 605 | { |
3614 | 600 | *ret_ptr= gearman_con_wait(worker->gearman); | 606 | *ret_ptr= gearman_wait(worker->gearman); |
3615 | 601 | if (*ret_ptr != GEARMAN_SUCCESS && (*ret_ptr != GEARMAN_TIMEOUT || | 607 | if (*ret_ptr != GEARMAN_SUCCESS && (*ret_ptr != GEARMAN_TIMEOUT || |
3616 | 602 | worker->options & GEARMAN_WORKER_TIMEOUT_RETURN)) | 608 | worker->options & GEARMAN_WORKER_TIMEOUT_RETURN)) |
3617 | 603 | { | 609 | { |
3618 | @@ -608,7 +614,7 @@ | |||
3619 | 608 | break; | 614 | break; |
3620 | 609 | 615 | ||
3621 | 610 | default: | 616 | default: |
3623 | 611 | gearman_error_set(worker->gearman, "gearman_worker_grab_job", | 617 | gearman_set_error(worker->gearman, "gearman_worker_grab_job", |
3624 | 612 | "unknown state: %u", worker->state); | 618 | "unknown state: %u", worker->state); |
3625 | 613 | *ret_ptr= GEARMAN_UNKNOWN_STATE; | 619 | *ret_ptr= GEARMAN_UNKNOWN_STATE; |
3626 | 614 | return NULL; | 620 | return NULL; |
3627 | @@ -650,14 +656,14 @@ | |||
3628 | 650 | { | 656 | { |
3629 | 651 | if (function_name == NULL) | 657 | if (function_name == NULL) |
3630 | 652 | { | 658 | { |
3632 | 653 | gearman_error_set(worker->gearman, "gearman_worker_add_function", | 659 | gearman_set_error(worker->gearman, "gearman_worker_add_function", |
3633 | 654 | "function name not given"); | 660 | "function name not given"); |
3634 | 655 | return GEARMAN_INVALID_FUNCTION_NAME; | 661 | return GEARMAN_INVALID_FUNCTION_NAME; |
3635 | 656 | } | 662 | } |
3636 | 657 | 663 | ||
3637 | 658 | if (worker_fn == NULL) | 664 | if (worker_fn == NULL) |
3638 | 659 | { | 665 | { |
3640 | 660 | gearman_error_set(worker->gearman, "gearman_worker_add_function", | 666 | gearman_set_error(worker->gearman, "gearman_worker_add_function", |
3641 | 661 | "function not given"); | 667 | "function not given"); |
3642 | 662 | return GEARMAN_INVALID_WORKER_FUNCTION; | 668 | return GEARMAN_INVALID_WORKER_FUNCTION; |
3643 | 663 | } | 669 | } |
3644 | @@ -691,7 +697,7 @@ | |||
3645 | 691 | if (worker->work_function == NULL) | 697 | if (worker->work_function == NULL) |
3646 | 692 | { | 698 | { |
3647 | 693 | gearman_job_free(&(worker->work_job)); | 699 | gearman_job_free(&(worker->work_job)); |
3649 | 694 | gearman_error_set(worker->gearman, "gearman_worker_work", | 700 | gearman_set_error(worker->gearman, "gearman_worker_work", |
3650 | 695 | "function not found"); | 701 | "function not found"); |
3651 | 696 | return GEARMAN_INVALID_FUNCTION_NAME; | 702 | return GEARMAN_INVALID_FUNCTION_NAME; |
3652 | 697 | } | 703 | } |
3653 | @@ -699,7 +705,7 @@ | |||
3654 | 699 | if (worker->work_function->worker_fn == NULL) | 705 | if (worker->work_function->worker_fn == NULL) |
3655 | 700 | { | 706 | { |
3656 | 701 | gearman_job_free(&(worker->work_job)); | 707 | gearman_job_free(&(worker->work_job)); |
3658 | 702 | gearman_error_set(worker->gearman, "gearman_worker_work", | 708 | gearman_set_error(worker->gearman, "gearman_worker_work", |
3659 | 703 | "no callback function supplied"); | 709 | "no callback function supplied"); |
3660 | 704 | return GEARMAN_INVALID_FUNCTION_NAME; | 710 | return GEARMAN_INVALID_FUNCTION_NAME; |
3661 | 705 | } | 711 | } |
3662 | @@ -708,10 +714,9 @@ | |||
3663 | 708 | worker->work_result_size= 0; | 714 | worker->work_result_size= 0; |
3664 | 709 | 715 | ||
3665 | 710 | case GEARMAN_WORKER_WORK_STATE_FUNCTION: | 716 | case GEARMAN_WORKER_WORK_STATE_FUNCTION: |
3670 | 711 | worker->work_result= (*(worker->work_function->worker_fn))( | 717 | worker->work_result= worker->work_function->worker_fn(&(worker->work_job), |
3671 | 712 | &(worker->work_job), | 718 | (void *)worker->work_function->context, |
3672 | 713 | (void *)(worker->work_function->context), | 719 | &(worker->work_result_size), &ret); |
3669 | 714 | &(worker->work_result_size), &ret); | ||
3673 | 715 | if (ret == GEARMAN_WORK_FAIL) | 720 | if (ret == GEARMAN_WORK_FAIL) |
3674 | 716 | { | 721 | { |
3675 | 717 | ret= gearman_job_send_fail(&(worker->work_job)); | 722 | ret= gearman_job_send_fail(&(worker->work_job)); |
3676 | @@ -752,7 +757,7 @@ | |||
3677 | 752 | else | 757 | else |
3678 | 753 | { | 758 | { |
3679 | 754 | worker->gearman->workload_free_fn(worker->work_result, | 759 | worker->gearman->workload_free_fn(worker->work_result, |
3681 | 755 | (void *)(worker->gearman->workload_free_context)); | 760 | (void *)worker->gearman->workload_free_context); |
3682 | 756 | } | 761 | } |
3683 | 757 | worker->work_result= NULL; | 762 | worker->work_result= NULL; |
3684 | 758 | } | 763 | } |
3685 | @@ -780,7 +785,7 @@ | |||
3686 | 780 | break; | 785 | break; |
3687 | 781 | 786 | ||
3688 | 782 | default: | 787 | default: |
3690 | 783 | gearman_error_set(worker->gearman, "gearman_worker_work", | 788 | gearman_set_error(worker->gearman, "gearman_worker_work", |
3691 | 784 | "unknown state: %u", worker->work_state); | 789 | "unknown state: %u", worker->work_state); |
3692 | 785 | return GEARMAN_UNKNOWN_STATE; | 790 | return GEARMAN_UNKNOWN_STATE; |
3693 | 786 | } | 791 | } |
3694 | @@ -795,11 +800,11 @@ | |||
3695 | 795 | const void *workload, | 800 | const void *workload, |
3696 | 796 | size_t workload_size) | 801 | size_t workload_size) |
3697 | 797 | { | 802 | { |
3699 | 798 | return gearman_con_echo(worker->gearman, workload, workload_size); | 803 | return gearman_echo(worker->gearman, workload, workload_size); |
3700 | 799 | } | 804 | } |
3701 | 800 | 805 | ||
3702 | 801 | /* | 806 | /* |
3704 | 802 | * Private definitions | 807 | * Static Definitions |
3705 | 803 | */ | 808 | */ |
3706 | 804 | 809 | ||
3707 | 805 | static gearman_worker_st *_worker_allocate(gearman_worker_st *worker) | 810 | static gearman_worker_st *_worker_allocate(gearman_worker_st *worker) |
3708 | @@ -836,15 +841,15 @@ | |||
3709 | 836 | { | 841 | { |
3710 | 837 | gearman_return_t ret; | 842 | gearman_return_t ret; |
3711 | 838 | 843 | ||
3715 | 839 | ret= gearman_packet_add(worker->gearman, &(worker->grab_job), | 844 | ret= gearman_add_packet_args(worker->gearman, &(worker->grab_job), |
3716 | 840 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_GRAB_JOB, | 845 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_GRAB_JOB, |
3717 | 841 | NULL); | 846 | NULL, NULL, 0); |
3718 | 842 | if (ret != GEARMAN_SUCCESS) | 847 | if (ret != GEARMAN_SUCCESS) |
3719 | 843 | return ret; | 848 | return ret; |
3720 | 844 | 849 | ||
3724 | 845 | ret= gearman_packet_add(worker->gearman, &(worker->pre_sleep), | 850 | ret= gearman_add_packet_args(worker->gearman, &(worker->pre_sleep), |
3725 | 846 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_PRE_SLEEP, | 851 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_PRE_SLEEP, |
3726 | 847 | NULL); | 852 | NULL, NULL, 0); |
3727 | 848 | if (ret != GEARMAN_SUCCESS) | 853 | if (ret != GEARMAN_SUCCESS) |
3728 | 849 | { | 854 | { |
3729 | 850 | gearman_packet_free(&(worker->grab_job)); | 855 | gearman_packet_free(&(worker->grab_job)); |
3730 | @@ -871,11 +876,13 @@ | |||
3731 | 871 | gearman_worker_function_st *function; | 876 | gearman_worker_function_st *function; |
3732 | 872 | gearman_return_t ret; | 877 | gearman_return_t ret; |
3733 | 873 | char timeout_buffer[11]; | 878 | char timeout_buffer[11]; |
3734 | 879 | const void *args[2]; | ||
3735 | 880 | size_t args_size[2]; | ||
3736 | 874 | 881 | ||
3737 | 875 | function= malloc(sizeof(gearman_worker_function_st)); | 882 | function= malloc(sizeof(gearman_worker_function_st)); |
3738 | 876 | if (function == NULL) | 883 | if (function == NULL) |
3739 | 877 | { | 884 | { |
3741 | 878 | gearman_error_set(worker->gearman, "_worker_function_add", "malloc"); | 885 | gearman_set_error(worker->gearman, "_worker_function_add", "malloc"); |
3742 | 879 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | 886 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; |
3743 | 880 | } | 887 | } |
3744 | 881 | 888 | ||
3745 | @@ -886,7 +893,7 @@ | |||
3746 | 886 | if (function->function_name == NULL) | 893 | if (function->function_name == NULL) |
3747 | 887 | { | 894 | { |
3748 | 888 | free(function); | 895 | free(function); |
3750 | 889 | gearman_error_set(worker->gearman, "gearman_worker_add_function", "strdup"); | 896 | gearman_set_error(worker->gearman, "gearman_worker_add_function", "strdup"); |
3751 | 890 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | 897 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; |
3752 | 891 | } | 898 | } |
3753 | 892 | 899 | ||
3754 | @@ -896,20 +903,22 @@ | |||
3755 | 896 | if (timeout > 0) | 903 | if (timeout > 0) |
3756 | 897 | { | 904 | { |
3757 | 898 | snprintf(timeout_buffer, 11, "%u", timeout); | 905 | snprintf(timeout_buffer, 11, "%u", timeout); |
3765 | 899 | ret= gearman_packet_add(worker->gearman, &(function->packet), | 906 | args[0]= function_name; |
3766 | 900 | GEARMAN_MAGIC_REQUEST, | 907 | args_size[0]= strlen(function_name) + 1; |
3767 | 901 | GEARMAN_COMMAND_CAN_DO_TIMEOUT, | 908 | args[1]= timeout_buffer; |
3768 | 902 | (uint8_t *)function_name, | 909 | args_size[1]= strlen(timeout_buffer); |
3769 | 903 | strlen(function_name) + 1, | 910 | ret= gearman_add_packet_args(worker->gearman, &(function->packet), |
3770 | 904 | (uint8_t *)timeout_buffer, | 911 | GEARMAN_MAGIC_REQUEST, |
3771 | 905 | strlen(timeout_buffer), NULL); | 912 | GEARMAN_COMMAND_CAN_DO_TIMEOUT, |
3772 | 913 | args, args_size, 2); | ||
3773 | 906 | } | 914 | } |
3774 | 907 | else | 915 | else |
3775 | 908 | { | 916 | { |
3780 | 909 | ret= gearman_packet_add(worker->gearman, &(function->packet), | 917 | args[0]= function_name; |
3781 | 910 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_CAN_DO, | 918 | args_size[0]= strlen(function_name); |
3782 | 911 | (uint8_t *)function_name, strlen(function_name), | 919 | ret= gearman_add_packet_args(worker->gearman, &(function->packet), |
3783 | 912 | NULL); | 920 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_CAN_DO, |
3784 | 921 | args, args_size, 1); | ||
3785 | 913 | } | 922 | } |
3786 | 914 | if (ret != GEARMAN_SUCCESS) | 923 | if (ret != GEARMAN_SUCCESS) |
3787 | 915 | { | 924 | { |
3788 | @@ -956,7 +965,7 @@ | |||
3789 | 956 | job= malloc(sizeof(gearman_job_st)); | 965 | job= malloc(sizeof(gearman_job_st)); |
3790 | 957 | if (job == NULL) | 966 | if (job == NULL) |
3791 | 958 | { | 967 | { |
3793 | 959 | gearman_error_set(worker->gearman, "_job_create", "malloc"); | 968 | gearman_set_error(worker->gearman, "_job_create", "malloc"); |
3794 | 960 | return NULL; | 969 | return NULL; |
3795 | 961 | } | 970 | } |
3796 | 962 | 971 | ||
3797 | 963 | 972 | ||
3798 | === modified file 'libgearman/worker.h' | |||
3799 | --- libgearman/worker.h 2009-10-02 01:13:31 +0000 | |||
3800 | +++ libgearman/worker.h 2009-11-04 22:14:14 +0000 | |||
3801 | @@ -8,7 +8,7 @@ | |||
3802 | 8 | 8 | ||
3803 | 9 | /** | 9 | /** |
3804 | 10 | * @file | 10 | * @file |
3806 | 11 | * @brief Worker declarations | 11 | * @brief Worker Declarations |
3807 | 12 | */ | 12 | */ |
3808 | 13 | 13 | ||
3809 | 14 | #ifndef __GEARMAN_WORKER_H__ | 14 | #ifndef __GEARMAN_WORKER_H__ |
3810 | @@ -19,7 +19,8 @@ | |||
3811 | 19 | #endif | 19 | #endif |
3812 | 20 | 20 | ||
3813 | 21 | /** | 21 | /** |
3815 | 22 | * @addtogroup gearman_worker Worker Interface | 22 | * @addtogroup gearman_worker Worker Declarations |
3816 | 23 | * | ||
3817 | 23 | * This is the interface gearman workers should use. | 24 | * This is the interface gearman workers should use. |
3818 | 24 | * | 25 | * |
3819 | 25 | * @ref main_page_worker "See Main Page for full details." | 26 | * @ref main_page_worker "See Main Page for full details." |
3820 | 26 | 27 | ||
3821 | === modified file 'tests/client_test.c' | |||
3822 | --- tests/client_test.c 2009-09-26 09:21:13 +0000 | |||
3823 | +++ tests/client_test.c 2009-11-04 22:14:14 +0000 | |||
3824 | @@ -45,8 +45,8 @@ | |||
3825 | 45 | test_return post(void *object); | 45 | test_return post(void *object); |
3826 | 46 | test_return flush(void); | 46 | test_return flush(void); |
3827 | 47 | 47 | ||
3830 | 48 | void *client_test_worker(gearman_job_st *job, void *cb_arg, size_t *result_size, | 48 | void *client_test_worker(gearman_job_st *job, void *context, |
3831 | 49 | gearman_return_t *ret_ptr); | 49 | size_t *result_size, gearman_return_t *ret_ptr); |
3832 | 50 | void *world_create(void); | 50 | void *world_create(void); |
3833 | 51 | void world_destroy(void *object); | 51 | void world_destroy(void *object); |
3834 | 52 | 52 | ||
3835 | @@ -292,7 +292,8 @@ | |||
3836 | 292 | return TEST_SUCCESS; | 292 | return TEST_SUCCESS; |
3837 | 293 | } | 293 | } |
3838 | 294 | 294 | ||
3840 | 295 | static void log_counter(const char *line, gearman_verbose_t verbose, void *context) | 295 | static void log_counter(const char *line, gearman_verbose_t verbose, |
3841 | 296 | void *context) | ||
3842 | 296 | { | 297 | { |
3843 | 297 | uint32_t *counter= (uint32_t *)context; | 298 | uint32_t *counter= (uint32_t *)context; |
3844 | 298 | 299 | ||
3845 | @@ -323,12 +324,12 @@ | |||
3846 | 323 | } | 324 | } |
3847 | 324 | 325 | ||
3848 | 325 | 326 | ||
3851 | 326 | void *client_test_worker(gearman_job_st *job, void *cb_arg, size_t *result_size, | 327 | void *client_test_worker(gearman_job_st *job, void *context, |
3852 | 327 | gearman_return_t *ret_ptr) | 328 | size_t *result_size, gearman_return_t *ret_ptr) |
3853 | 328 | { | 329 | { |
3854 | 329 | const uint8_t *workload; | 330 | const uint8_t *workload; |
3855 | 330 | uint8_t *result; | 331 | uint8_t *result; |
3857 | 331 | (void)cb_arg; | 332 | (void)context; |
3858 | 332 | 333 | ||
3859 | 333 | workload= gearman_job_workload(job); | 334 | workload= gearman_job_workload(job); |
3860 | 334 | *result_size= gearman_job_workload_size(job); | 335 | *result_size= gearman_job_workload_size(job); |
3861 | 335 | 336 | ||
3862 | === modified file 'tests/memcached_test.c' | |||
3863 | --- tests/memcached_test.c 2009-07-28 07:12:24 +0000 | |||
3864 | +++ tests/memcached_test.c 2009-11-04 22:14:14 +0000 | |||
3865 | @@ -43,8 +43,7 @@ | |||
3866 | 43 | 43 | ||
3867 | 44 | /* Counter test for worker */ | 44 | /* Counter test for worker */ |
3868 | 45 | static void *counter_function(gearman_job_st *job __attribute__((unused)), | 45 | static void *counter_function(gearman_job_st *job __attribute__((unused)), |
3871 | 46 | void *context, | 46 | void *context, size_t *result_size, |
3870 | 47 | size_t *result_size, | ||
3872 | 48 | gearman_return_t *ret_ptr __attribute__((unused))) | 47 | gearman_return_t *ret_ptr __attribute__((unused))) |
3873 | 49 | { | 48 | { |
3874 | 50 | uint32_t *counter= (uint32_t *)context; | 49 | uint32_t *counter= (uint32_t *)context; |
3875 | 51 | 50 | ||
3876 | === modified file 'tests/sqlite_test.c' | |||
3877 | --- tests/sqlite_test.c 2009-10-11 07:24:42 +0000 | |||
3878 | +++ tests/sqlite_test.c 2009-11-04 22:14:14 +0000 | |||
3879 | @@ -43,8 +43,7 @@ | |||
3880 | 43 | 43 | ||
3881 | 44 | /* Counter test for worker */ | 44 | /* Counter test for worker */ |
3882 | 45 | static void *counter_function(gearman_job_st *job __attribute__((unused)), | 45 | static void *counter_function(gearman_job_st *job __attribute__((unused)), |
3885 | 46 | void *context, | 46 | void *context, size_t *result_size, |
3884 | 47 | size_t *result_size, | ||
3886 | 48 | gearman_return_t *ret_ptr __attribute__((unused))) | 47 | gearman_return_t *ret_ptr __attribute__((unused))) |
3887 | 49 | { | 48 | { |
3888 | 50 | uint32_t *counter= (uint32_t *)context; | 49 | uint32_t *counter= (uint32_t *)context; |
3889 | 51 | 50 | ||
3890 | === modified file 'tests/worker_test.c' | |||
3891 | --- tests/worker_test.c 2009-09-23 21:05:40 +0000 | |||
3892 | +++ tests/worker_test.c 2009-11-04 22:14:14 +0000 | |||
3893 | @@ -107,46 +107,51 @@ | |||
3894 | 107 | gearman_con_st con; | 107 | gearman_con_st con; |
3895 | 108 | gearman_packet_st packet; | 108 | gearman_packet_st packet; |
3896 | 109 | uint32_t x; | 109 | uint32_t x; |
3897 | 110 | const void *args[1]; | ||
3898 | 111 | size_t args_size[1]; | ||
3899 | 110 | 112 | ||
3900 | 111 | if (gearman_create(&gearman) == NULL) | 113 | if (gearman_create(&gearman) == NULL) |
3901 | 112 | return TEST_FAILURE; | 114 | return TEST_FAILURE; |
3902 | 113 | 115 | ||
3903 | 114 | for (x= 0; x < 2; x++) | 116 | for (x= 0; x < 2; x++) |
3904 | 115 | { | 117 | { |
3906 | 116 | if (gearman_con_create(&gearman, &con) == NULL) | 118 | if (gearman_add_con(&gearman, &con) == NULL) |
3907 | 117 | return TEST_FAILURE; | 119 | return TEST_FAILURE; |
3908 | 118 | 120 | ||
3909 | 119 | gearman_con_set_host(&con, NULL); | 121 | gearman_con_set_host(&con, NULL); |
3910 | 120 | gearman_con_set_port(&con, WORKER_TEST_PORT); | 122 | gearman_con_set_port(&con, WORKER_TEST_PORT); |
3911 | 121 | 123 | ||
3940 | 122 | if (gearman_packet_add(&gearman, &packet, GEARMAN_MAGIC_REQUEST, | 124 | args[0]= "testUnregisterFunction"; |
3941 | 123 | GEARMAN_COMMAND_SET_CLIENT_ID, | 125 | args_size[0]= strlen("testUnregisterFunction"); |
3942 | 124 | (uint8_t *)"testUnregisterFunction", 13, | 126 | if (gearman_add_packet_args(&gearman, &packet, GEARMAN_MAGIC_REQUEST, |
3943 | 125 | NULL) != GEARMAN_SUCCESS) | 127 | GEARMAN_COMMAND_SET_CLIENT_ID, |
3944 | 126 | { | 128 | args, args_size, 1) != GEARMAN_SUCCESS) |
3945 | 127 | return TEST_FAILURE; | 129 | { |
3946 | 128 | } | 130 | return TEST_FAILURE; |
3947 | 129 | 131 | } | |
3948 | 130 | if (gearman_con_send(&con, &packet, true) != GEARMAN_SUCCESS) | 132 | |
3949 | 131 | return TEST_FAILURE; | 133 | if (gearman_con_send(&con, &packet, true) != GEARMAN_SUCCESS) |
3950 | 132 | 134 | return TEST_FAILURE; | |
3951 | 133 | gearman_packet_free(&packet); | 135 | |
3952 | 134 | 136 | gearman_packet_free(&packet); | |
3953 | 135 | if (gearman_packet_add(&gearman, &packet, GEARMAN_MAGIC_REQUEST, | 137 | |
3954 | 136 | GEARMAN_COMMAND_CAN_DO, (uint8_t *)"reverse", 7, | 138 | args[0]= "reverse"; |
3955 | 137 | NULL) != GEARMAN_SUCCESS) | 139 | args_size[0]= strlen("reverse"); |
3956 | 138 | { | 140 | if (gearman_add_packet_args(&gearman, &packet, GEARMAN_MAGIC_REQUEST, |
3957 | 139 | return TEST_FAILURE; | 141 | GEARMAN_COMMAND_CAN_DO, |
3958 | 140 | } | 142 | args, args_size, 1) != GEARMAN_SUCCESS) |
3959 | 141 | 143 | { | |
3960 | 142 | if (gearman_con_send(&con, &packet, true) != GEARMAN_SUCCESS) | 144 | return TEST_FAILURE; |
3961 | 143 | return TEST_FAILURE; | 145 | } |
3962 | 144 | 146 | ||
3963 | 145 | gearman_packet_free(&packet); | 147 | if (gearman_con_send(&con, &packet, true) != GEARMAN_SUCCESS) |
3964 | 146 | 148 | return TEST_FAILURE; | |
3965 | 147 | if (gearman_packet_add(&gearman, &packet, GEARMAN_MAGIC_REQUEST, | 149 | |
3966 | 148 | GEARMAN_COMMAND_CANT_DO, (uint8_t *)"reverse", 7, | 150 | gearman_packet_free(&packet); |
3967 | 149 | NULL) != GEARMAN_SUCCESS) | 151 | |
3968 | 152 | if (gearman_add_packet_args(&gearman, &packet, GEARMAN_MAGIC_REQUEST, | ||
3969 | 153 | GEARMAN_COMMAND_CANT_DO, | ||
3970 | 154 | args, args_size, 1) != GEARMAN_SUCCESS) | ||
3971 | 150 | { | 155 | { |
3972 | 151 | return TEST_FAILURE; | 156 | return TEST_FAILURE; |
3973 | 152 | } | 157 | } |
3974 | @@ -158,52 +163,57 @@ | |||
3975 | 158 | 163 | ||
3976 | 159 | gearman_con_free(&con); | 164 | gearman_con_free(&con); |
3977 | 160 | 165 | ||
3979 | 161 | if (gearman_con_create(&gearman, &con) == NULL) | 166 | if (gearman_add_con(&gearman, &con) == NULL) |
3980 | 162 | return TEST_FAILURE; | 167 | return TEST_FAILURE; |
3981 | 163 | 168 | ||
3982 | 164 | gearman_con_set_host(&con, NULL); | 169 | gearman_con_set_host(&con, NULL); |
3983 | 165 | gearman_con_set_port(&con, WORKER_TEST_PORT); | 170 | gearman_con_set_port(&con, WORKER_TEST_PORT); |
3984 | 166 | 171 | ||
4025 | 167 | if (gearman_packet_add(&gearman, &packet, GEARMAN_MAGIC_REQUEST, | 172 | args[0]= "testUnregisterFunction"; |
4026 | 168 | GEARMAN_COMMAND_SET_CLIENT_ID, | 173 | args_size[0]= strlen("testUnregisterFunction"); |
4027 | 169 | (uint8_t *)"testUnregisterFunction", 13, | 174 | if (gearman_add_packet_args(&gearman, &packet, GEARMAN_MAGIC_REQUEST, |
4028 | 170 | NULL) != GEARMAN_SUCCESS) | 175 | GEARMAN_COMMAND_SET_CLIENT_ID, |
4029 | 171 | { | 176 | args, args_size, 1) != GEARMAN_SUCCESS) |
4030 | 172 | return TEST_FAILURE; | 177 | { |
4031 | 173 | } | 178 | return TEST_FAILURE; |
4032 | 174 | 179 | } | |
4033 | 175 | if (gearman_con_send(&con, &packet, true) != GEARMAN_SUCCESS) | 180 | |
4034 | 176 | return TEST_FAILURE; | 181 | if (gearman_con_send(&con, &packet, true) != GEARMAN_SUCCESS) |
4035 | 177 | 182 | return TEST_FAILURE; | |
4036 | 178 | gearman_packet_free(&packet); | 183 | |
4037 | 179 | 184 | gearman_packet_free(&packet); | |
4038 | 180 | if (gearman_packet_add(&gearman, &packet, GEARMAN_MAGIC_REQUEST, | 185 | |
4039 | 181 | GEARMAN_COMMAND_CAN_DO, (uint8_t *)"digest", 6, | 186 | args[0]= "digest"; |
4040 | 182 | NULL) != GEARMAN_SUCCESS) | 187 | args_size[0]= strlen("digest"); |
4041 | 183 | { | 188 | if (gearman_add_packet_args(&gearman, &packet, GEARMAN_MAGIC_REQUEST, |
4042 | 184 | return TEST_FAILURE; | 189 | GEARMAN_COMMAND_CAN_DO, |
4043 | 185 | } | 190 | args, args_size, 1) != GEARMAN_SUCCESS) |
4044 | 186 | 191 | { | |
4045 | 187 | if (gearman_con_send(&con, &packet, true) != GEARMAN_SUCCESS) | 192 | return TEST_FAILURE; |
4046 | 188 | return TEST_FAILURE; | 193 | } |
4047 | 189 | 194 | ||
4048 | 190 | gearman_packet_free(&packet); | 195 | if (gearman_con_send(&con, &packet, true) != GEARMAN_SUCCESS) |
4049 | 191 | 196 | return TEST_FAILURE; | |
4050 | 192 | if (gearman_packet_add(&gearman, &packet, GEARMAN_MAGIC_REQUEST, | 197 | |
4051 | 193 | GEARMAN_COMMAND_CAN_DO, (uint8_t *)"reverse", 7, | 198 | gearman_packet_free(&packet); |
4052 | 194 | NULL) != GEARMAN_SUCCESS) | 199 | |
4053 | 195 | { | 200 | args[0]= "reverse"; |
4054 | 196 | return TEST_FAILURE; | 201 | args_size[0]= strlen("reverse"); |
4055 | 197 | } | 202 | if (gearman_add_packet_args(&gearman, &packet, GEARMAN_MAGIC_REQUEST, |
4056 | 198 | 203 | GEARMAN_COMMAND_CAN_DO, | |
4057 | 199 | if (gearman_con_send(&con, &packet, true) != GEARMAN_SUCCESS) | 204 | args, args_size, 1) != GEARMAN_SUCCESS) |
4058 | 200 | return TEST_FAILURE; | 205 | { |
4059 | 201 | 206 | return TEST_FAILURE; | |
4060 | 202 | gearman_packet_free(&packet); | 207 | } |
4061 | 203 | 208 | ||
4062 | 204 | if (gearman_packet_add(&gearman, &packet, GEARMAN_MAGIC_REQUEST, | 209 | if (gearman_con_send(&con, &packet, true) != GEARMAN_SUCCESS) |
4063 | 205 | GEARMAN_COMMAND_RESET_ABILITIES, | 210 | return TEST_FAILURE; |
4064 | 206 | NULL) != GEARMAN_SUCCESS) | 211 | |
4065 | 212 | gearman_packet_free(&packet); | ||
4066 | 213 | |||
4067 | 214 | if (gearman_add_packet_args(&gearman, &packet, GEARMAN_MAGIC_REQUEST, | ||
4068 | 215 | GEARMAN_COMMAND_RESET_ABILITIES, | ||
4069 | 216 | NULL, NULL, 0) != GEARMAN_SUCCESS) | ||
4070 | 207 | { | 217 | { |
4071 | 208 | return TEST_FAILURE; | 218 | return TEST_FAILURE; |
4072 | 209 | } | 219 | } |