Merge lp:~brianaker/gearmand/fixes-for-ssl-builds into lp:gearmand
- fixes-for-ssl-builds
- Merge into 1.2
Proposed by
Brian Aker
Status: | Merged |
---|---|
Merged at revision: | 824 |
Proposed branch: | lp:~brianaker/gearmand/fixes-for-ssl-builds |
Merge into: | lp:gearmand |
Diff against target: |
1207 lines (+334/-232) 26 files modified
libgearman-1.0/constants.h (+2/-1) libgearman-server/connection.cc (+13/-10) libgearman-server/connection.h (+2/-2) libgearman-server/gearmand.cc (+13/-18) libgearman-server/gearmand_thread.cc (+4/-10) libgearman-server/io.cc (+40/-44) libgearman-server/io.h (+5/-3) libgearman-server/plugins/protocol/gear/protocol.cc (+26/-3) libgearman-server/server.cc (+5/-2) libgearman-server/struct/gearmand_thread.h (+6/-1) libgearman-server/thread.cc (+5/-8) libgearman/check.h (+5/-0) libgearman/client.cc (+26/-30) libgearman/client.hpp (+3/-3) libgearman/function/function_v2.cc (+2/-1) libgearman/interface/universal.hpp (+4/-0) libgearman/interface/worker.hpp (+5/-0) libgearman/job.cc (+19/-2) libgearman/strcommand.h (+8/-0) libgearman/universal.cc (+7/-0) libgearman/worker.cc (+87/-71) libgearman/worker.hpp (+21/-0) tests/libgearman-1.0/gearman_execute_partition.cc (+8/-8) tests/protocol.cc (+3/-0) tests/start_worker.cc (+10/-9) tests/workers/v2/split.cc (+5/-6) |
To merge this branch: | bzr merge lp:~brianaker/gearmand/fixes-for-ssl-builds |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tangent Trunk | Pending | ||
Review via email: mp+174109@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 824. By Brian Aker
-
OSX build fixes.
- 825. By Brian Aker
-
Additional OSX fix.
- 826. By Brian Aker
-
Fix additional OSX warnings.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'libgearman-1.0/constants.h' | |||
2 | --- libgearman-1.0/constants.h 2013-06-05 21:59:31 +0000 | |||
3 | +++ libgearman-1.0/constants.h 2013-07-11 21:18:03 +0000 | |||
4 | @@ -133,7 +133,8 @@ | |||
5 | 133 | GEARMAN_WORKER_TIMEOUT_RETURN= (1 << 8), | 133 | GEARMAN_WORKER_TIMEOUT_RETURN= (1 << 8), |
6 | 134 | GEARMAN_WORKER_GRAB_ALL= (1 << 9), | 134 | GEARMAN_WORKER_GRAB_ALL= (1 << 9), |
7 | 135 | GEARMAN_WORKER_SSL= (1 << 10), | 135 | GEARMAN_WORKER_SSL= (1 << 10), |
9 | 136 | GEARMAN_WORKER_MAX= (1 << 11) | 136 | GEARMAN_WORKER_IDENTIFIER= (1 << 11), |
10 | 137 | GEARMAN_WORKER_MAX= (1 << 12) | ||
11 | 137 | } gearman_worker_options_t; | 138 | } gearman_worker_options_t; |
12 | 138 | 139 | ||
13 | 139 | /* Types. */ | 140 | /* Types. */ |
14 | 140 | 141 | ||
15 | === modified file 'libgearman-server/connection.cc' | |||
16 | --- libgearman-server/connection.cc 2013-06-26 23:50:02 +0000 | |||
17 | +++ libgearman-server/connection.cc 2013-07-11 21:18:03 +0000 | |||
18 | @@ -47,7 +47,8 @@ | |||
19 | 47 | 47 | ||
20 | 48 | #include <string.h> | 48 | #include <string.h> |
21 | 49 | #include <errno.h> | 49 | #include <errno.h> |
23 | 50 | #include <assert.h> | 50 | #include <cassert> |
24 | 51 | #include <algorithm> | ||
25 | 51 | 52 | ||
26 | 52 | static gearman_server_con_st * _server_con_create(gearman_server_thread_st *thread, gearmand_con_st *dcon, | 53 | static gearman_server_con_st * _server_con_create(gearman_server_thread_st *thread, gearmand_con_st *dcon, |
27 | 53 | gearmand_error_t& ret); | 54 | gearmand_error_t& ret); |
28 | @@ -313,16 +314,18 @@ | |||
29 | 313 | return con->id; | 314 | return con->id; |
30 | 314 | } | 315 | } |
31 | 315 | 316 | ||
34 | 316 | void gearman_server_con_set_id(gearman_server_con_st *con, char *id, | 317 | void gearman_server_con_set_id(gearman_server_con_st *con, |
35 | 317 | size_t size) | 318 | const char *id, |
36 | 319 | const size_t size) | ||
37 | 318 | { | 320 | { |
45 | 319 | if (size >= GEARMAND_SERVER_CON_ID_SIZE) | 321 | size_t min_size= std::min(size, size_t(GEARMAND_SERVER_CON_ID_SIZE -1)); |
46 | 320 | { | 322 | |
47 | 321 | size= GEARMAND_SERVER_CON_ID_SIZE - 1; | 323 | memcpy(con->id, id, min_size); |
48 | 322 | } | 324 | con->id[min_size]= 0; |
49 | 323 | 325 | ||
50 | 324 | memcpy(con->id, id, size); | 326 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, |
51 | 325 | con->id[size]= 0; | 327 | "identifier set to %.*s", |
52 | 328 | min_size, con->id); | ||
53 | 326 | } | 329 | } |
54 | 327 | 330 | ||
55 | 328 | void gearman_server_con_free_worker(gearman_server_con_st *con, | 331 | void gearman_server_con_free_worker(gearman_server_con_st *con, |
56 | 329 | 332 | ||
57 | === modified file 'libgearman-server/connection.h' | |||
58 | --- libgearman-server/connection.h 2013-06-26 23:50:02 +0000 | |||
59 | +++ libgearman-server/connection.h 2013-07-11 21:18:03 +0000 | |||
60 | @@ -111,8 +111,8 @@ | |||
61 | 111 | * Set client id. | 111 | * Set client id. |
62 | 112 | */ | 112 | */ |
63 | 113 | GEARMAN_API | 113 | GEARMAN_API |
66 | 114 | void gearman_server_con_set_id(gearman_server_con_st *con, char *id, | 114 | void gearman_server_con_set_id(gearman_server_con_st *con, const char *id, |
67 | 115 | size_t size); | 115 | const size_t size); |
68 | 116 | 116 | ||
69 | 117 | /** | 117 | /** |
70 | 118 | * Free server worker struction with name for a server connection. | 118 | * Free server worker struction with name for a server connection. |
71 | 119 | 119 | ||
72 | === modified file 'libgearman-server/gearmand.cc' | |||
73 | --- libgearman-server/gearmand.cc 2013-07-07 00:16:26 +0000 | |||
74 | +++ libgearman-server/gearmand.cc 2013-07-11 21:18:03 +0000 | |||
75 | @@ -861,15 +861,7 @@ | |||
76 | 861 | Gearmand()->ret= gearmand_perror(local_error, "accept"); | 861 | Gearmand()->ret= gearmand_perror(local_error, "accept"); |
77 | 862 | return; | 862 | return; |
78 | 863 | } | 863 | } |
88 | 864 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "accept() %d", fd); | 864 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "accept() fd:%d", fd); |
80 | 865 | |||
81 | 866 | { | ||
82 | 867 | int flags= 1; | ||
83 | 868 | if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &flags, sizeof(flags)) == -1) | ||
84 | 869 | { | ||
85 | 870 | gearmand_perror(errno, "setsockopt(SO_KEEPALIVE)"); | ||
86 | 871 | } | ||
87 | 872 | } | ||
89 | 873 | 865 | ||
90 | 874 | /* | 866 | /* |
91 | 875 | Since this is numeric, it should never fail. Even if it did we don't want to really error from it. | 867 | Since this is numeric, it should never fail. Even if it did we don't want to really error from it. |
92 | @@ -887,6 +879,14 @@ | |||
93 | 887 | 879 | ||
94 | 888 | gearmand_log_info(GEARMAN_DEFAULT_LOG_PARAM, "Accepted connection from %s:%s", host, port_str); | 880 | gearmand_log_info(GEARMAN_DEFAULT_LOG_PARAM, "Accepted connection from %s:%s", host, port_str); |
95 | 889 | 881 | ||
96 | 882 | { | ||
97 | 883 | int flags= 1; | ||
98 | 884 | if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &flags, sizeof(flags)) == -1) | ||
99 | 885 | { | ||
100 | 886 | gearmand_log_perror(GEARMAN_DEFAULT_LOG_PARAM, errno, "%s:%s setsockopt(SO_KEEPALIVE)", host, port_str); | ||
101 | 887 | } | ||
102 | 888 | } | ||
103 | 889 | |||
104 | 890 | gearmand_error_t ret= gearmand_con_create(Gearmand(), fd, host, port_str, port); | 890 | gearmand_error_t ret= gearmand_con_create(Gearmand(), fd, host, port_str, port); |
105 | 891 | if (ret == GEARMAND_MEMORY_ALLOCATION_FAILURE) | 891 | if (ret == GEARMAND_MEMORY_ALLOCATION_FAILURE) |
106 | 892 | { | 892 | { |
107 | @@ -915,15 +915,10 @@ | |||
108 | 915 | return gearmand_fatal_perror(errno, "pipe(gearmand->wakeup_fd)"); | 915 | return gearmand_fatal_perror(errno, "pipe(gearmand->wakeup_fd)"); |
109 | 916 | } | 916 | } |
110 | 917 | 917 | ||
120 | 918 | int returned_flags; | 918 | gearmand_error_t local_ret; |
121 | 919 | if ((returned_flags= fcntl(gearmand->wakeup_fd[0], F_GETFL, 0)) == -1) | 919 | if ((local_ret= gearmand_sockfd_nonblock(gearmand->wakeup_fd[0]))) |
122 | 920 | { | 920 | { |
123 | 921 | return gearmand_fatal_perror(errno, "fcntl:F_GETFL"); | 921 | return local_ret; |
115 | 922 | } | ||
116 | 923 | |||
117 | 924 | if (fcntl(gearmand->wakeup_fd[0], F_SETFL, returned_flags | O_NONBLOCK) == -1) | ||
118 | 925 | { | ||
119 | 926 | return gearmand_fatal_perror(errno, "fcntl(F_SETFL)"); | ||
124 | 927 | } | 922 | } |
125 | 928 | #endif | 923 | #endif |
126 | 929 | 924 | ||
127 | 930 | 925 | ||
128 | === modified file 'libgearman-server/gearmand_thread.cc' | |||
129 | --- libgearman-server/gearmand_thread.cc 2013-07-10 10:54:09 +0000 | |||
130 | +++ libgearman-server/gearmand_thread.cc 2013-07-11 21:18:03 +0000 | |||
131 | @@ -505,16 +505,10 @@ | |||
132 | 505 | return gearmand_perror(errno, "pipe"); | 505 | return gearmand_perror(errno, "pipe"); |
133 | 506 | } | 506 | } |
134 | 507 | 507 | ||
145 | 508 | int ret= fcntl(thread->wakeup_fd[0], F_GETFL, 0); | 508 | gearmand_error_t local_ret; |
146 | 509 | if (ret == -1) | 509 | if ((local_ret= gearmand_sockfd_nonblock(thread->gearmand().wakeup_fd[0]))) |
147 | 510 | { | 510 | { |
148 | 511 | return gearmand_perror(errno, "fcntl(F_GETFL)"); | 511 | return local_ret; |
139 | 512 | } | ||
140 | 513 | |||
141 | 514 | ret= fcntl(thread->wakeup_fd[0], F_SETFL, ret | O_NONBLOCK); | ||
142 | 515 | if (ret == -1) | ||
143 | 516 | { | ||
144 | 517 | return gearmand_perror(errno, "fcntl(F_SETFL)"); | ||
149 | 518 | } | 512 | } |
150 | 519 | #endif | 513 | #endif |
151 | 520 | 514 | ||
152 | 521 | 515 | ||
153 | === modified file 'libgearman-server/io.cc' | |||
154 | --- libgearman-server/io.cc 2013-07-07 22:07:57 +0000 | |||
155 | +++ libgearman-server/io.cc 2013-07-11 21:18:03 +0000 | |||
156 | @@ -146,10 +146,7 @@ | |||
157 | 146 | if (read_size == 0) | 146 | if (read_size == 0) |
158 | 147 | { | 147 | { |
159 | 148 | ret= GEARMAND_LOST_CONNECTION; | 148 | ret= GEARMAND_LOST_CONNECTION; |
164 | 149 | gearmand_log_info(GEARMAN_DEFAULT_LOG_PARAM, | 149 | gearmand_log_info(GEARMAN_DEFAULT_LOG_PARAM, "Peer connection has called close()"); |
161 | 150 | "Peer connection has called close() %s:%s", | ||
162 | 151 | connection->host(), | ||
163 | 152 | connection->port()); | ||
165 | 153 | _connection_close(connection); | 150 | _connection_close(connection); |
166 | 154 | return 0; | 151 | return 0; |
167 | 155 | } | 152 | } |
168 | @@ -177,10 +174,7 @@ | |||
169 | 177 | case EHOSTDOWN: | 174 | case EHOSTDOWN: |
170 | 178 | { | 175 | { |
171 | 179 | ret= GEARMAND_LOST_CONNECTION; | 176 | ret= GEARMAND_LOST_CONNECTION; |
176 | 180 | gearmand_log_info(GEARMAN_DEFAULT_LOG_PARAM, | 177 | gearmand_log_info(GEARMAN_DEFAULT_LOG_PARAM, "Peer connection has called close()"); |
173 | 181 | "Peer connection has called close() %s:%s", | ||
174 | 182 | connection->host(), | ||
175 | 183 | connection->port()); | ||
177 | 184 | _connection_close(connection); | 178 | _connection_close(connection); |
178 | 185 | return 0; | 179 | return 0; |
179 | 186 | } | 180 | } |
180 | @@ -300,9 +294,7 @@ | |||
181 | 300 | char errorString[80]; | 294 | char errorString[80]; |
182 | 301 | CyaSSL_ERR_error_string(err, errorString); | 295 | CyaSSL_ERR_error_string(err, errorString); |
183 | 302 | _connection_close(connection); | 296 | _connection_close(connection); |
187 | 303 | return gearmand_log_gerror(GEARMAN_DEFAULT_LOG_PARAM, GEARMAND_LOST_CONNECTION, "%s:%s SSL failure(%s)", | 297 | return gearmand_log_gerror(GEARMAN_DEFAULT_LOG_PARAM, GEARMAND_LOST_CONNECTION, "SSL failure(%s)", |
185 | 304 | connection->host(), | ||
186 | 305 | connection->port(), | ||
188 | 306 | errorString); | 298 | errorString); |
189 | 307 | } | 299 | } |
190 | 308 | } | 300 | } |
191 | @@ -317,10 +309,8 @@ | |||
192 | 317 | if (write_size == 0) // detect infinite loop? | 309 | if (write_size == 0) // detect infinite loop? |
193 | 318 | { | 310 | { |
194 | 319 | ++loop_counter; | 311 | ++loop_counter; |
199 | 320 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "send() sent zero bytes of %u to peer %s:%s", | 312 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "send() sent zero bytes of %u", |
200 | 321 | uint32_t(connection->send_buffer_size), | 313 | uint32_t(connection->send_buffer_size)); |
197 | 322 | connection->host(), | ||
198 | 323 | connection->port()); | ||
201 | 324 | 314 | ||
202 | 325 | if (loop_counter > 5) | 315 | if (loop_counter > 5) |
203 | 326 | { | 316 | { |
204 | @@ -366,10 +356,8 @@ | |||
205 | 366 | return GEARMAND_ERRNO; | 356 | return GEARMAND_ERRNO; |
206 | 367 | } | 357 | } |
207 | 368 | 358 | ||
212 | 369 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "send() %u bytes to peer %s:%s", | 359 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "send() %u bytes to peer", |
213 | 370 | uint32_t(write_size), | 360 | uint32_t(write_size)); |
210 | 371 | connection->host(), | ||
211 | 372 | connection->port()); | ||
214 | 373 | 361 | ||
215 | 374 | connection->send_buffer_size-= static_cast<size_t>(write_size); | 362 | connection->send_buffer_size-= static_cast<size_t>(write_size); |
216 | 375 | if (connection->send_state == gearmand_io_st::GEARMAND_CON_SEND_UNIVERSAL_FLUSH_DATA) | 363 | if (connection->send_state == gearmand_io_st::GEARMAND_CON_SEND_UNIVERSAL_FLUSH_DATA) |
217 | @@ -775,9 +763,7 @@ | |||
218 | 775 | } | 763 | } |
219 | 776 | return ret; | 764 | return ret; |
220 | 777 | } | 765 | } |
224 | 778 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "%s:%s read %lu bytes", | 766 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "read %lu bytes", |
222 | 779 | connection->host(), | ||
223 | 780 | connection->port(), | ||
225 | 781 | (unsigned long)recv_size); | 767 | (unsigned long)recv_size); |
226 | 782 | 768 | ||
227 | 783 | connection->recv_buffer_size+= recv_size; | 769 | connection->recv_buffer_size+= recv_size; |
228 | @@ -901,7 +887,6 @@ | |||
229 | 901 | 887 | ||
230 | 902 | static gearmand_error_t _io_setsockopt(gearmand_io_st &connection) | 888 | static gearmand_error_t _io_setsockopt(gearmand_io_st &connection) |
231 | 903 | { | 889 | { |
232 | 904 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "setsockopt() fd:%d", connection.fd); | ||
233 | 905 | { | 890 | { |
234 | 906 | int setting= 1; | 891 | int setting= 1; |
235 | 907 | if (setsockopt(connection.fd, IPPROTO_TCP, TCP_NODELAY, &setting, (socklen_t)sizeof(int)) and errno != EOPNOTSUPP) | 892 | if (setsockopt(connection.fd, IPPROTO_TCP, TCP_NODELAY, &setting, (socklen_t)sizeof(int)) and errno != EOPNOTSUPP) |
236 | @@ -969,28 +954,39 @@ | |||
237 | 969 | 954 | ||
238 | 970 | if (SOCK_NONBLOCK == 0) | 955 | if (SOCK_NONBLOCK == 0) |
239 | 971 | { | 956 | { |
241 | 972 | int flags; | 957 | gearmand_error_t local_ret; |
242 | 958 | if ((local_ret= gearmand_sockfd_nonblock(connection.fd))) | ||
243 | 959 | { | ||
244 | 960 | return local_ret; | ||
245 | 961 | } | ||
246 | 962 | } | ||
247 | 963 | |||
248 | 964 | return GEARMAND_SUCCESS; | ||
249 | 965 | } | ||
250 | 966 | |||
251 | 967 | gearmand_error_t gearmand_sockfd_nonblock(const int& sockfd) | ||
252 | 968 | { | ||
253 | 969 | int flags; | ||
254 | 970 | do | ||
255 | 971 | { | ||
256 | 972 | flags= fcntl(sockfd, F_GETFL, 0); | ||
257 | 973 | } while (flags == -1 and (errno == EINTR or errno == EAGAIN)); | ||
258 | 974 | |||
259 | 975 | if (flags == -1) | ||
260 | 976 | { | ||
261 | 977 | return gearmand_perror(errno, "fcntl(F_GETFL)"); | ||
262 | 978 | } | ||
263 | 979 | else if ((flags & O_NONBLOCK) == 0) | ||
264 | 980 | { | ||
265 | 981 | int retval; | ||
266 | 973 | do | 982 | do |
267 | 974 | { | 983 | { |
287 | 975 | flags= fcntl(connection.fd, F_GETFL, 0); | 984 | retval= fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); |
288 | 976 | } while (flags == -1 and (errno == EINTR or errno == EAGAIN)); | 985 | } while (retval == -1 and (errno == EINTR or errno == EAGAIN)); |
289 | 977 | 986 | ||
290 | 978 | if (flags == -1) | 987 | if (retval == -1) |
291 | 979 | { | 988 | { |
292 | 980 | return gearmand_perror(errno, "fcntl(F_GETFL)"); | 989 | return gearmand_perror(errno, "fcntl(F_SETFL)"); |
274 | 981 | } | ||
275 | 982 | else if ((flags & O_NONBLOCK) == 0) | ||
276 | 983 | { | ||
277 | 984 | int retval; | ||
278 | 985 | do | ||
279 | 986 | { | ||
280 | 987 | retval= fcntl(connection.fd, F_SETFL, flags | O_NONBLOCK); | ||
281 | 988 | } while (retval == -1 and (errno == EINTR or errno == EAGAIN)); | ||
282 | 989 | |||
283 | 990 | if (retval == -1) | ||
284 | 991 | { | ||
285 | 992 | return gearmand_perror(errno, "fcntl(F_SETFL)"); | ||
286 | 993 | } | ||
293 | 994 | } | 990 | } |
294 | 995 | } | 991 | } |
295 | 996 | 992 | ||
296 | @@ -1016,7 +1012,7 @@ | |||
297 | 1016 | } | 1012 | } |
298 | 1017 | else | 1013 | else |
299 | 1018 | { | 1014 | { |
301 | 1019 | gearmand_warning("gearmand_sockfd_close() called with an invalid socket"); | 1015 | gearmand_debug("gearmand_sockfd_close() called with an invalid socket, this was probably ok"); |
302 | 1020 | } | 1016 | } |
303 | 1021 | } | 1017 | } |
304 | 1022 | 1018 | ||
305 | 1023 | 1019 | ||
306 | === modified file 'libgearman-server/io.h' | |||
307 | --- libgearman-server/io.h 2013-03-09 22:03:25 +0000 | |||
308 | +++ libgearman-server/io.h 2013-07-11 21:18:03 +0000 | |||
309 | @@ -131,9 +131,11 @@ | |||
310 | 131 | */ | 131 | */ |
311 | 132 | gearmand_error_t gearmand_io_set_revents(gearman_server_con_st *connection, short revents); | 132 | gearmand_error_t gearmand_io_set_revents(gearman_server_con_st *connection, short revents); |
312 | 133 | 133 | ||
316 | 134 | void gearmand_sockfd_close(int& sockfd); | 134 | void gearmand_sockfd_close(int&); |
317 | 135 | 135 | ||
318 | 136 | void gearmand_pipe_close(int& sockfd); | 136 | void gearmand_pipe_close(int&); |
319 | 137 | |||
320 | 138 | gearmand_error_t gearmand_sockfd_nonblock(const int&); | ||
321 | 137 | 139 | ||
322 | 138 | /** @} */ | 140 | /** @} */ |
323 | 139 | 141 | ||
324 | 140 | 142 | ||
325 | === modified file 'libgearman-server/plugins/protocol/gear/protocol.cc' | |||
326 | --- libgearman-server/plugins/protocol/gear/protocol.cc 2013-07-10 10:54:09 +0000 | |||
327 | +++ libgearman-server/plugins/protocol/gear/protocol.cc 2013-07-11 21:18:03 +0000 | |||
328 | @@ -47,6 +47,7 @@ | |||
329 | 47 | #include <libgearman-server/common.h> | 47 | #include <libgearman-server/common.h> |
330 | 48 | #include <libgearman/strcommand.h> | 48 | #include <libgearman/strcommand.h> |
331 | 49 | #include <libgearman-server/packet.h> | 49 | #include <libgearman-server/packet.h> |
332 | 50 | #include "libgearman/strcommand.h" | ||
333 | 50 | 51 | ||
334 | 51 | #include <cstdio> | 52 | #include <cstdio> |
335 | 52 | #include <cstdlib> | 53 | #include <cstdlib> |
336 | @@ -103,9 +104,9 @@ | |||
337 | 103 | return false; | 104 | return false; |
338 | 104 | } | 105 | } |
339 | 105 | 106 | ||
341 | 106 | void notify(gearman_server_con_st *) | 107 | void notify(gearman_server_con_st* connection) |
342 | 107 | { | 108 | { |
344 | 108 | gearmand_info("Gear connection disconnected"); | 109 | gearmand_log_info(GEARMAN_DEFAULT_LOG_PARAM, "Gear connection disconnected: %s:%s", connection->host(), connection->port()); |
345 | 109 | } | 110 | } |
346 | 110 | 111 | ||
347 | 111 | size_t unpack(gearmand_packet_st *packet, | 112 | size_t unpack(gearmand_packet_st *packet, |
348 | @@ -257,6 +258,24 @@ | |||
349 | 257 | int(packet->arg_size[0]), | 258 | int(packet->arg_size[0]), |
350 | 258 | packet->arg[0]); | 259 | packet->arg[0]); |
351 | 259 | } | 260 | } |
352 | 261 | else if (packet->command == GEARMAN_COMMAND_WORK_EXCEPTION) | ||
353 | 262 | { | ||
354 | 263 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, | ||
355 | 264 | "GEAR gearmand_command_t: %s handle: %.*s exception: %.*s", | ||
356 | 265 | gearman_strcommand(packet->command), | ||
357 | 266 | int(packet->arg_size[0]), | ||
358 | 267 | packet->arg[0], | ||
359 | 268 | int(packet->data_size), | ||
360 | 269 | packet->data); | ||
361 | 270 | } | ||
362 | 271 | else if (packet->command == GEARMAN_COMMAND_SET_CLIENT_ID) | ||
363 | 272 | { | ||
364 | 273 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, | ||
365 | 274 | "GEAR gearmand_command_t: %s identifier: %.*s", | ||
366 | 275 | gearman_strcommand(packet->command), | ||
367 | 276 | int(packet->arg_size[0]), | ||
368 | 277 | packet->arg[0]); | ||
369 | 278 | } | ||
370 | 260 | else | 279 | else |
371 | 261 | { | 280 | { |
372 | 262 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, | 281 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, |
373 | @@ -353,9 +372,13 @@ | |||
374 | 353 | cyassl_error_buffer, cyassl_error); | 372 | cyassl_error_buffer, cyassl_error); |
375 | 354 | } | 373 | } |
376 | 355 | } | 374 | } |
378 | 356 | gearmand_log_info(GEARMAN_DEFAULT_LOG_PARAM, "GearSSL connection made: %d", connection->con.fd); | 375 | gearmand_log_info(GEARMAN_DEFAULT_LOG_PARAM, "GearSSL connection made: %s:%s", connection->host(), connection->port()); |
379 | 357 | } | 376 | } |
380 | 377 | else | ||
381 | 358 | #endif | 378 | #endif |
382 | 379 | { | ||
383 | 380 | gearmand_log_info(GEARMAN_DEFAULT_LOG_PARAM, "Gear connection made: %s:%s", connection->host(), connection->port()); | ||
384 | 381 | } | ||
385 | 359 | 382 | ||
386 | 360 | connection->set_protocol(&gear_context); | 383 | connection->set_protocol(&gear_context); |
387 | 361 | 384 | ||
388 | 362 | 385 | ||
389 | === modified file 'libgearman-server/server.cc' | |||
390 | --- libgearman-server/server.cc 2013-07-10 10:54:09 +0000 | |||
391 | +++ libgearman-server/server.cc 2013-07-11 21:18:03 +0000 | |||
392 | @@ -545,7 +545,7 @@ | |||
393 | 545 | long timeout= strtol(strtol_buffer, &endptr, 10); | 545 | long timeout= strtol(strtol_buffer, &endptr, 10); |
394 | 546 | if (timeout == LONG_MIN or timeout == LONG_MAX or errno != 0) | 546 | if (timeout == LONG_MIN or timeout == LONG_MAX or errno != 0) |
395 | 547 | { | 547 | { |
397 | 548 | return gearmand_log_perror(GEARMAN_DEFAULT_LOG_PARAM, errno, "GEARMAN_COMMAND_CAN_DO_TIMEOUT:strtol"); | 548 | return gearmand_log_perror(GEARMAN_DEFAULT_LOG_PARAM, errno, "GEARMAN_COMMAND_CAN_DO_TIMEOUT:strtol: %s", strtol_buffer); |
398 | 549 | } | 549 | } |
399 | 550 | 550 | ||
400 | 551 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "Registering function: %.*s with timeout %dl", | 551 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "Registering function: %.*s with timeout %dl", |
401 | @@ -1042,7 +1042,10 @@ | |||
402 | 1042 | } | 1042 | } |
403 | 1043 | else if (command == GEARMAN_COMMAND_WORK_EXCEPTION) | 1043 | else if (command == GEARMAN_COMMAND_WORK_EXCEPTION) |
404 | 1044 | { | 1044 | { |
406 | 1045 | gearmand_debug("Sending GEARMAN_COMMAND_WORK_EXCEPTION"); | 1045 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, |
407 | 1046 | "%s:%s GEARMAN_COMMAND_WORK_EXCEPTION: %.*s", | ||
408 | 1047 | server_client->con->host(), server_client->con->port(), | ||
409 | 1048 | int(packet->data_size), packet->data); | ||
410 | 1046 | } | 1049 | } |
411 | 1047 | 1050 | ||
412 | 1048 | uint8_t *data; | 1051 | uint8_t *data; |
413 | 1049 | 1052 | ||
414 | === modified file 'libgearman-server/struct/gearmand_thread.h' | |||
415 | --- libgearman-server/struct/gearmand_thread.h 2013-07-06 10:56:43 +0000 | |||
416 | +++ libgearman-server/struct/gearmand_thread.h 2013-07-11 21:18:03 +0000 | |||
417 | @@ -37,7 +37,7 @@ | |||
418 | 37 | 37 | ||
419 | 38 | #pragma once | 38 | #pragma once |
420 | 39 | 39 | ||
422 | 40 | class gearmand_st; | 40 | struct gearmand_st; |
423 | 41 | 41 | ||
424 | 42 | struct gearmand_thread_st | 42 | struct gearmand_thread_st |
425 | 43 | { | 43 | { |
426 | @@ -61,4 +61,9 @@ | |||
427 | 61 | pthread_mutex_t lock; | 61 | pthread_mutex_t lock; |
428 | 62 | 62 | ||
429 | 63 | gearmand_thread_st(gearmand_st&); | 63 | gearmand_thread_st(gearmand_st&); |
430 | 64 | |||
431 | 65 | gearmand_st& gearmand() | ||
432 | 66 | { | ||
433 | 67 | return _gearmand; | ||
434 | 68 | } | ||
435 | 64 | }; | 69 | }; |
436 | 65 | 70 | ||
437 | === modified file 'libgearman-server/thread.cc' | |||
438 | --- libgearman-server/thread.cc 2013-07-06 20:11:54 +0000 | |||
439 | +++ libgearman-server/thread.cc 2013-07-11 21:18:03 +0000 | |||
440 | @@ -45,6 +45,7 @@ | |||
441 | 45 | #include "libgearman-server/common.h" | 45 | #include "libgearman-server/common.h" |
442 | 46 | 46 | ||
443 | 47 | #include <libgearman/command.h> | 47 | #include <libgearman/command.h> |
444 | 48 | #include "libgearman/strcommand.h" | ||
445 | 48 | 49 | ||
446 | 49 | #ifdef __cplusplus | 50 | #ifdef __cplusplus |
447 | 50 | # include <cassert> | 51 | # include <cassert> |
448 | @@ -308,10 +309,8 @@ | |||
449 | 308 | } | 309 | } |
450 | 309 | 310 | ||
451 | 310 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, | 311 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, |
456 | 311 | "Received %s %s:%u", | 312 | "Received %s", |
457 | 312 | gearmand_strcommand(&con->packet->packet), | 313 | gearmand_strcommand(&con->packet->packet)); |
454 | 313 | con->_host == NULL ? "-" : con->_host, | ||
455 | 314 | con->_port == NULL ? "-" : con->_port); | ||
458 | 315 | 314 | ||
459 | 316 | /* We read a complete packet. */ | 315 | /* We read a complete packet. */ |
460 | 317 | if (Server->flags.threaded) | 316 | if (Server->flags.threaded) |
461 | @@ -355,10 +354,8 @@ | |||
462 | 355 | } | 354 | } |
463 | 356 | 355 | ||
464 | 357 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, | 356 | gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, |
469 | 358 | "Sent %s to %s:%d", | 357 | "Sent %s", |
470 | 359 | gearman_command_info(con->io_packet_list->packet.command)->name, | 358 | gearman_strcommand(con->io_packet_list->packet.command)); |
467 | 360 | con->_host == NULL ? "-" : con->_host, | ||
468 | 361 | con->_port == NULL ? "-" : con->_port); | ||
471 | 362 | 359 | ||
472 | 363 | gearman_server_io_packet_remove(con); | 360 | gearman_server_io_packet_remove(con); |
473 | 364 | } | 361 | } |
474 | 365 | 362 | ||
475 | === modified file 'libgearman/check.h' | |||
476 | --- libgearman/check.h 2013-07-10 10:54:09 +0000 | |||
477 | +++ libgearman/check.h 2013-07-11 21:18:03 +0000 | |||
478 | @@ -65,6 +65,11 @@ | |||
479 | 65 | { | 65 | { |
480 | 66 | } | 66 | } |
481 | 67 | 67 | ||
482 | 68 | const gearman_string_t& option() const | ||
483 | 69 | { | ||
484 | 70 | return _option; | ||
485 | 71 | } | ||
486 | 72 | |||
487 | 68 | gearman_return_t success(gearman_connection_st* con); | 73 | gearman_return_t success(gearman_connection_st* con); |
488 | 69 | 74 | ||
489 | 70 | private: | 75 | private: |
490 | 71 | 76 | ||
491 | === modified file 'libgearman/client.cc' | |||
492 | --- libgearman/client.cc 2013-07-10 10:54:09 +0000 | |||
493 | +++ libgearman/client.cc 2013-07-11 21:18:03 +0000 | |||
494 | @@ -1744,36 +1744,32 @@ | |||
495 | 1744 | 1744 | ||
496 | 1745 | gearman_return_t gearman_client_run_block_tasks(Client* client, gearman_task_st* exit_task) | 1745 | gearman_return_t gearman_client_run_block_tasks(Client* client, gearman_task_st* exit_task) |
497 | 1746 | { | 1746 | { |
528 | 1747 | { | 1747 | if (client->task_list == NULL) // We are immediatly successful if all tasks are completed |
529 | 1748 | if (client->task_list == NULL) // We are immediatly successful if all tasks are completed | 1748 | { |
530 | 1749 | { | 1749 | return GEARMAN_SUCCESS; |
531 | 1750 | return GEARMAN_SUCCESS; | 1750 | } |
532 | 1751 | } | 1751 | |
533 | 1752 | 1752 | gearman_return_t rc; | |
534 | 1753 | gearman_return_t rc; | 1753 | { |
535 | 1754 | { | 1754 | PUSH_BLOCKING(client->universal); |
536 | 1755 | PUSH_BLOCKING(client->universal); | 1755 | |
537 | 1756 | 1756 | rc= _client_run_tasks(client->shell(), exit_task); | |
538 | 1757 | rc= _client_run_tasks(client->shell(), exit_task); | 1757 | } |
539 | 1758 | } | 1758 | |
540 | 1759 | 1759 | if (gearman_failed(rc)) | |
541 | 1760 | if (gearman_failed(rc)) | 1760 | { |
542 | 1761 | { | 1761 | if (rc == GEARMAN_COULD_NOT_CONNECT) |
543 | 1762 | if (rc == GEARMAN_COULD_NOT_CONNECT) | 1762 | { |
544 | 1763 | { | 1763 | gearman_reset(client->universal); |
545 | 1764 | gearman_reset(client->universal); | 1764 | } |
546 | 1765 | } | 1765 | |
547 | 1766 | 1766 | if (client->universal.error_code() != rc and rc != GEARMAN_COULD_NOT_CONNECT) | |
548 | 1767 | if (client->universal.error_code() != rc and rc != GEARMAN_COULD_NOT_CONNECT) | 1767 | { |
549 | 1768 | { | 1768 | assert(client->universal.error_code() == rc); |
550 | 1769 | assert(client->universal.error_code() == rc); | 1769 | } |
551 | 1770 | } | 1770 | } |
552 | 1771 | } | 1771 | |
553 | 1772 | 1772 | return rc; | |
524 | 1773 | return rc; | ||
525 | 1774 | } | ||
526 | 1775 | |||
527 | 1776 | return GEARMAN_INVALID_ARGUMENT; | ||
554 | 1777 | } | 1773 | } |
555 | 1778 | 1774 | ||
556 | 1779 | /* | 1775 | /* |
557 | 1780 | 1776 | ||
558 | === modified file 'libgearman/client.hpp' | |||
559 | --- libgearman/client.hpp 2013-07-08 09:58:12 +0000 | |||
560 | +++ libgearman/client.hpp 2013-07-11 21:18:03 +0000 | |||
561 | @@ -47,7 +47,7 @@ | |||
562 | 47 | 47 | ||
563 | 48 | namespace { | 48 | namespace { |
564 | 49 | 49 | ||
566 | 50 | inline void all_PRINTER(const char *line, gearman_verbose_t verbose, void*) | 50 | inline void all_client_PRINTER(const char *line, gearman_verbose_t verbose, void*) |
567 | 51 | { | 51 | { |
568 | 52 | fprintf(stderr, "%s:%d %s(%s)\n", __FILE__, __LINE__, gearman_verbose_name(verbose), line); | 52 | fprintf(stderr, "%s:%d %s(%s)\n", __FILE__, __LINE__, gearman_verbose_name(verbose), line); |
569 | 53 | } | 53 | } |
570 | @@ -67,7 +67,6 @@ | |||
571 | 67 | throw std::runtime_error("gearman_client_create() failed"); | 67 | throw std::runtime_error("gearman_client_create() failed"); |
572 | 68 | } | 68 | } |
573 | 69 | enable_logging(); | 69 | enable_logging(); |
574 | 70 | |||
575 | 71 | enable_ssl(); | 70 | enable_ssl(); |
576 | 72 | } | 71 | } |
577 | 73 | 72 | ||
578 | @@ -95,6 +94,7 @@ | |||
579 | 95 | 94 | ||
580 | 96 | gearman_client_add_server(_client, "localhost", arg); | 95 | gearman_client_add_server(_client, "localhost", arg); |
581 | 97 | 96 | ||
582 | 97 | enable_logging(); | ||
583 | 98 | enable_ssl(); | 98 | enable_ssl(); |
584 | 99 | } | 99 | } |
585 | 100 | 100 | ||
586 | @@ -117,7 +117,7 @@ | |||
587 | 117 | { | 117 | { |
588 | 118 | if (getenv("YATL_CLIENT_LOGGING")) | 118 | if (getenv("YATL_CLIENT_LOGGING")) |
589 | 119 | { | 119 | { |
591 | 120 | gearman_log_fn *func= all_PRINTER; | 120 | gearman_log_fn *func= all_client_PRINTER; |
592 | 121 | gearman_client_set_log_fn(_client, func, NULL, GEARMAN_VERBOSE_ERROR); | 121 | gearman_client_set_log_fn(_client, func, NULL, GEARMAN_VERBOSE_ERROR); |
593 | 122 | } | 122 | } |
594 | 123 | } | 123 | } |
595 | 124 | 124 | ||
596 | === modified file 'libgearman/function/function_v2.cc' | |||
597 | --- libgearman/function/function_v2.cc 2013-07-05 22:06:45 +0000 | |||
598 | +++ libgearman/function/function_v2.cc 2013-07-11 21:18:03 +0000 | |||
599 | @@ -59,6 +59,7 @@ | |||
600 | 59 | job->_error_code= GEARMAN_SUCCESS; | 59 | job->_error_code= GEARMAN_SUCCESS; |
601 | 60 | return GEARMAN_FUNCTION_SHUTDOWN; | 60 | return GEARMAN_FUNCTION_SHUTDOWN; |
602 | 61 | 61 | ||
603 | 62 | case GEARMAN_WORK_EXCEPTION: | ||
604 | 62 | case GEARMAN_FATAL: | 63 | case GEARMAN_FATAL: |
605 | 63 | job->_error_code= GEARMAN_FATAL; | 64 | job->_error_code= GEARMAN_FATAL; |
606 | 64 | return GEARMAN_FUNCTION_FATAL; | 65 | return GEARMAN_FUNCTION_FATAL; |
607 | @@ -91,7 +92,6 @@ | |||
608 | 91 | case GEARMAN_WORK_DATA: | 92 | case GEARMAN_WORK_DATA: |
609 | 92 | case GEARMAN_WORK_WARNING: | 93 | case GEARMAN_WORK_WARNING: |
610 | 93 | case GEARMAN_WORK_STATUS: | 94 | case GEARMAN_WORK_STATUS: |
611 | 94 | case GEARMAN_WORK_EXCEPTION: | ||
612 | 95 | case GEARMAN_NOT_CONNECTED: | 95 | case GEARMAN_NOT_CONNECTED: |
613 | 96 | case GEARMAN_COULD_NOT_CONNECT: | 96 | case GEARMAN_COULD_NOT_CONNECT: |
614 | 97 | case GEARMAN_SEND_IN_PROGRESS: | 97 | case GEARMAN_SEND_IN_PROGRESS: |
615 | @@ -123,5 +123,6 @@ | |||
616 | 123 | break; | 123 | break; |
617 | 124 | } | 124 | } |
618 | 125 | 125 | ||
619 | 126 | gearman_gerror(job->universal(), GEARMAN_INVALID_ARGUMENT); | ||
620 | 126 | return GEARMAN_FUNCTION_INVALID_ARGUMENT; | 127 | return GEARMAN_FUNCTION_INVALID_ARGUMENT; |
621 | 127 | } | 128 | } |
622 | 128 | 129 | ||
623 | === modified file 'libgearman/interface/universal.hpp' | |||
624 | --- libgearman/interface/universal.hpp 2013-07-08 09:58:12 +0000 | |||
625 | +++ libgearman/interface/universal.hpp 2013-07-11 21:18:03 +0000 | |||
626 | @@ -265,6 +265,10 @@ | |||
627 | 265 | ~gearman_universal_st(); | 265 | ~gearman_universal_st(); |
628 | 266 | 266 | ||
629 | 267 | void identifier(const char *identifier_, const size_t identifier_size_); | 267 | void identifier(const char *identifier_, const size_t identifier_size_); |
630 | 268 | bool has_identifier() const | ||
631 | 269 | { | ||
632 | 270 | return _identifier; | ||
633 | 271 | } | ||
634 | 268 | }; | 272 | }; |
635 | 269 | 273 | ||
636 | 270 | static inline bool gearman_universal_is_non_blocking(gearman_universal_st &self) | 274 | static inline bool gearman_universal_is_non_blocking(gearman_universal_st &self) |
637 | 271 | 275 | ||
638 | === modified file 'libgearman/interface/worker.hpp' | |||
639 | --- libgearman/interface/worker.hpp 2013-07-05 22:06:45 +0000 | |||
640 | +++ libgearman/interface/worker.hpp 2013-07-11 21:18:03 +0000 | |||
641 | @@ -127,6 +127,11 @@ | |||
642 | 127 | universal.options._ssl= ssl_; | 127 | universal.options._ssl= ssl_; |
643 | 128 | } | 128 | } |
644 | 129 | 129 | ||
645 | 130 | bool has_identifier() const | ||
646 | 131 | { | ||
647 | 132 | return universal.has_identifier(); | ||
648 | 133 | } | ||
649 | 134 | |||
650 | 130 | const char* error() const | 135 | const char* error() const |
651 | 131 | { | 136 | { |
652 | 132 | return universal.error(); | 137 | return universal.error(); |
653 | 133 | 138 | ||
654 | === modified file 'libgearman/job.cc' | |||
655 | --- libgearman/job.cc 2013-07-08 00:50:39 +0000 | |||
656 | +++ libgearman/job.cc 2013-07-11 21:18:03 +0000 | |||
657 | @@ -68,6 +68,16 @@ | |||
658 | 68 | gearman_string_append(reducer_function, gearman_string_param(reducer_function_name)); | 68 | gearman_string_append(reducer_function, gearman_string_param(reducer_function_name)); |
659 | 69 | } | 69 | } |
660 | 70 | 70 | ||
661 | 71 | const char* name() const | ||
662 | 72 | { | ||
663 | 73 | if (reducer_function) | ||
664 | 74 | { | ||
665 | 75 | return reducer_function->c_str(); | ||
666 | 76 | } | ||
667 | 77 | |||
668 | 78 | return "__UNKNOWN"; | ||
669 | 79 | } | ||
670 | 80 | |||
671 | 71 | ~gearman_job_reducer_st() | 81 | ~gearman_job_reducer_st() |
672 | 72 | { | 82 | { |
673 | 73 | gearman_client_free(client); | 83 | gearman_client_free(client); |
674 | @@ -79,7 +89,8 @@ | |||
675 | 79 | client= gearman_client_create(NULL); | 89 | client= gearman_client_create(NULL); |
676 | 80 | if (client) | 90 | if (client) |
677 | 81 | { | 91 | { |
679 | 82 | 92 | gearman_universal_clone(client->impl()->universal, universal, false); | |
680 | 93 | #if 0 | ||
681 | 83 | if (universal._namespace) | 94 | if (universal._namespace) |
682 | 84 | { | 95 | { |
683 | 85 | gearman_client_set_namespace(client, | 96 | gearman_client_set_namespace(client, |
684 | @@ -94,6 +105,7 @@ | |||
685 | 94 | return false; | 105 | return false; |
686 | 95 | } | 106 | } |
687 | 96 | } | 107 | } |
688 | 108 | #endif | ||
689 | 97 | 109 | ||
690 | 98 | return true; | 110 | return true; |
691 | 99 | } | 111 | } |
692 | @@ -415,7 +427,7 @@ | |||
693 | 415 | gearman_return_t rc= job->reducer->complete(); | 427 | gearman_return_t rc= job->reducer->complete(); |
694 | 416 | if (gearman_failed(rc)) | 428 | if (gearman_failed(rc)) |
695 | 417 | { | 429 | { |
697 | 418 | return gearman_error(job->universal(), rc, "The reducer's complete() returned an error"); | 430 | return gearman_universal_set_error(job->universal(), rc, GEARMAN_AT, "%s couldn't call complete()", job->reducer->name()); |
698 | 419 | } | 431 | } |
699 | 420 | 432 | ||
700 | 421 | const gearman_vector_st *reduced_value= job->reducer->result.string(); | 433 | const gearman_vector_st *reduced_value= job->reducer->result.string(); |
701 | @@ -472,6 +484,11 @@ | |||
702 | 472 | { | 484 | { |
703 | 473 | if (job) | 485 | if (job) |
704 | 474 | { | 486 | { |
705 | 487 | if (exception == NULL or exception_size == 0) | ||
706 | 488 | { | ||
707 | 489 | return gearman_error(job->universal(), GEARMAN_INVALID_ARGUMENT, "No exception was provided"); | ||
708 | 490 | } | ||
709 | 491 | |||
710 | 475 | if (job->finished() == false) | 492 | if (job->finished() == false) |
711 | 476 | { | 493 | { |
712 | 477 | if (job->options.work_in_use == false) | 494 | if (job->options.work_in_use == false) |
713 | 478 | 495 | ||
714 | === modified file 'libgearman/strcommand.h' | |||
715 | --- libgearman/strcommand.h 2012-03-31 06:09:14 +0000 | |||
716 | +++ libgearman/strcommand.h 2013-07-11 21:18:03 +0000 | |||
717 | @@ -37,4 +37,12 @@ | |||
718 | 37 | 37 | ||
719 | 38 | #pragma once | 38 | #pragma once |
720 | 39 | 39 | ||
721 | 40 | #ifdef __cplusplus | ||
722 | 41 | extern "C" { | ||
723 | 42 | #endif | ||
724 | 43 | |||
725 | 40 | const char *gearman_strcommand(gearman_command_t command); | 44 | const char *gearman_strcommand(gearman_command_t command); |
726 | 45 | |||
727 | 46 | #ifdef __cplusplus | ||
728 | 47 | } | ||
729 | 48 | #endif | ||
730 | 41 | 49 | ||
731 | === modified file 'libgearman/universal.cc' | |||
732 | --- libgearman/universal.cc 2013-07-10 10:54:09 +0000 | |||
733 | +++ libgearman/universal.cc 2013-07-11 21:18:03 +0000 | |||
734 | @@ -105,6 +105,8 @@ | |||
735 | 105 | 105 | ||
736 | 106 | (void)gearman_universal_set_option(destination, GEARMAN_UNIVERSAL_NON_BLOCKING, source.options.non_blocking); | 106 | (void)gearman_universal_set_option(destination, GEARMAN_UNIVERSAL_NON_BLOCKING, source.options.non_blocking); |
737 | 107 | 107 | ||
738 | 108 | destination.ssl(source.ssl()); | ||
739 | 109 | |||
740 | 108 | destination.timeout= source.timeout; | 110 | destination.timeout= source.timeout; |
741 | 109 | 111 | ||
742 | 110 | destination._namespace= gearman_string_clone(source._namespace); | 112 | destination._namespace= gearman_string_clone(source._namespace); |
743 | @@ -374,6 +376,11 @@ | |||
744 | 374 | return gearman_gerror(universal, GEARMAN_SHUTDOWN); | 376 | return gearman_gerror(universal, GEARMAN_SHUTDOWN); |
745 | 375 | } | 377 | } |
746 | 376 | 378 | ||
747 | 379 | if (read_length == -1) | ||
748 | 380 | { | ||
749 | 381 | gearman_perror(universal, "read() from shutdown pipe"); | ||
750 | 382 | } | ||
751 | 383 | |||
752 | 377 | #if 0 | 384 | #if 0 |
753 | 378 | perror("shudown read"); | 385 | perror("shudown read"); |
754 | 379 | #endif | 386 | #endif |
755 | 380 | 387 | ||
756 | === modified file 'libgearman/worker.cc' | |||
757 | --- libgearman/worker.cc 2013-07-08 00:50:39 +0000 | |||
758 | +++ libgearman/worker.cc 2013-07-11 21:18:03 +0000 | |||
759 | @@ -39,6 +39,7 @@ | |||
760 | 39 | #include "gear_config.h" | 39 | #include "gear_config.h" |
761 | 40 | 40 | ||
762 | 41 | #include <libgearman/common.h> | 41 | #include <libgearman/common.h> |
763 | 42 | #include "libgearman/uuid.hpp" | ||
764 | 42 | #include <libgearman/function/base.hpp> | 43 | #include <libgearman/function/base.hpp> |
765 | 43 | #include <libgearman/function/make.hpp> | 44 | #include <libgearman/function/make.hpp> |
766 | 44 | 45 | ||
767 | @@ -258,6 +259,8 @@ | |||
768 | 258 | options|= int(GEARMAN_WORKER_TIMEOUT_RETURN); | 259 | options|= int(GEARMAN_WORKER_TIMEOUT_RETURN); |
769 | 259 | if (worker->ssl()) | 260 | if (worker->ssl()) |
770 | 260 | options|= int(GEARMAN_WORKER_SSL); | 261 | options|= int(GEARMAN_WORKER_SSL); |
771 | 262 | if (worker->has_identifier()) | ||
772 | 263 | options|= int(GEARMAN_WORKER_IDENTIFIER); | ||
773 | 261 | 264 | ||
774 | 262 | return gearman_worker_options_t(options); | 265 | return gearman_worker_options_t(options); |
775 | 263 | } | 266 | } |
776 | @@ -276,6 +279,7 @@ | |||
777 | 276 | GEARMAN_WORKER_GRAB_ALL, | 279 | GEARMAN_WORKER_GRAB_ALL, |
778 | 277 | GEARMAN_WORKER_TIMEOUT_RETURN, | 280 | GEARMAN_WORKER_TIMEOUT_RETURN, |
779 | 278 | GEARMAN_WORKER_SSL, | 281 | GEARMAN_WORKER_SSL, |
780 | 282 | GEARMAN_WORKER_IDENTIFIER, | ||
781 | 279 | GEARMAN_WORKER_MAX | 283 | GEARMAN_WORKER_MAX |
782 | 280 | }; | 284 | }; |
783 | 281 | 285 | ||
784 | @@ -333,6 +337,14 @@ | |||
785 | 333 | { | 337 | { |
786 | 334 | worker->ssl(true); | 338 | worker->ssl(true); |
787 | 335 | } | 339 | } |
788 | 340 | |||
789 | 341 | if (options & GEARMAN_WORKER_IDENTIFIER) | ||
790 | 342 | { | ||
791 | 343 | char uuid_buffer[GEARMAN_MAX_IDENTIFIER]; | ||
792 | 344 | size_t length= GEARMAN_MAX_IDENTIFIER; | ||
793 | 345 | safe_uuid_generate(uuid_buffer, length); | ||
794 | 346 | worker->universal.identifier(uuid_buffer, length); | ||
795 | 347 | } | ||
796 | 336 | } | 348 | } |
797 | 337 | } | 349 | } |
798 | 338 | 350 | ||
799 | @@ -369,9 +381,9 @@ | |||
800 | 369 | worker->options.grab_all= false; | 381 | worker->options.grab_all= false; |
801 | 370 | } | 382 | } |
802 | 371 | 383 | ||
804 | 372 | if (options & GEARMAN_WORKER_SSL) | 384 | if (options & GEARMAN_WORKER_IDENTIFIER) |
805 | 373 | { | 385 | { |
807 | 374 | worker->ssl(false); | 386 | worker->universal.identifier(NULL, 0); |
808 | 375 | } | 387 | } |
809 | 376 | } | 388 | } |
810 | 377 | } | 389 | } |
811 | @@ -1240,77 +1252,73 @@ | |||
812 | 1240 | uint32_t timeout, | 1252 | uint32_t timeout, |
813 | 1241 | void *context) | 1253 | void *context) |
814 | 1242 | { | 1254 | { |
815 | 1255 | const void *args[2]; | ||
816 | 1256 | size_t args_size[2]; | ||
817 | 1257 | |||
818 | 1258 | if (function_length == 0 or function_name == NULL or function_length > GEARMAN_FUNCTION_MAX_SIZE) | ||
819 | 1243 | { | 1259 | { |
858 | 1244 | const void *args[2]; | 1260 | if (function_length > GEARMAN_FUNCTION_MAX_SIZE) |
859 | 1245 | size_t args_size[2]; | 1261 | { |
860 | 1246 | 1262 | gearman_error(worker->universal, GEARMAN_INVALID_ARGUMENT, "function name longer then GEARMAN_MAX_FUNCTION_SIZE"); | |
861 | 1247 | if (function_length == 0 or function_name == NULL or function_length > GEARMAN_FUNCTION_MAX_SIZE) | 1263 | } |
824 | 1248 | { | ||
825 | 1249 | if (function_length > GEARMAN_FUNCTION_MAX_SIZE) | ||
826 | 1250 | { | ||
827 | 1251 | gearman_error(worker->universal, GEARMAN_INVALID_ARGUMENT, "function name longer then GEARMAN_MAX_FUNCTION_SIZE"); | ||
828 | 1252 | } | ||
829 | 1253 | else | ||
830 | 1254 | { | ||
831 | 1255 | gearman_error(worker->universal, GEARMAN_INVALID_ARGUMENT, "invalid function"); | ||
832 | 1256 | } | ||
833 | 1257 | |||
834 | 1258 | return GEARMAN_INVALID_ARGUMENT; | ||
835 | 1259 | } | ||
836 | 1260 | |||
837 | 1261 | _worker_function_st *function= make(worker->universal._namespace, function_name, function_length, function_arg, context); | ||
838 | 1262 | if (function == NULL) | ||
839 | 1263 | { | ||
840 | 1264 | gearman_perror(worker->universal, "_worker_function_st::new()"); | ||
841 | 1265 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | ||
842 | 1266 | } | ||
843 | 1267 | |||
844 | 1268 | gearman_return_t ret; | ||
845 | 1269 | if (timeout > 0) | ||
846 | 1270 | { | ||
847 | 1271 | char timeout_buffer[11]; | ||
848 | 1272 | snprintf(timeout_buffer, sizeof(timeout_buffer), "%u", timeout); | ||
849 | 1273 | args[0]= function->name(); | ||
850 | 1274 | args_size[0]= function->length() + 1; | ||
851 | 1275 | args[1]= timeout_buffer; | ||
852 | 1276 | args_size[1]= strlen(timeout_buffer); | ||
853 | 1277 | ret= gearman_packet_create_args(worker->universal, function->packet(), | ||
854 | 1278 | GEARMAN_MAGIC_REQUEST, | ||
855 | 1279 | GEARMAN_COMMAND_CAN_DO_TIMEOUT, | ||
856 | 1280 | args, args_size, 2); | ||
857 | 1281 | } | ||
862 | 1282 | else | 1264 | else |
863 | 1283 | { | 1265 | { |
894 | 1284 | args[0]= function->name(); | 1266 | gearman_error(worker->universal, GEARMAN_INVALID_ARGUMENT, "invalid function"); |
895 | 1285 | args_size[0]= function->length(); | 1267 | } |
896 | 1286 | ret= gearman_packet_create_args(worker->universal, function->packet(), | 1268 | |
897 | 1287 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_CAN_DO, | 1269 | return GEARMAN_INVALID_ARGUMENT; |
898 | 1288 | args, args_size, 1); | 1270 | } |
899 | 1289 | } | 1271 | |
900 | 1290 | 1272 | _worker_function_st *function= make(worker->universal._namespace, function_name, function_length, function_arg, context); | |
901 | 1291 | if (gearman_failed(ret)) | 1273 | if (function == NULL) |
902 | 1292 | { | 1274 | { |
903 | 1293 | delete function; | 1275 | gearman_perror(worker->universal, "_worker_function_st::new()"); |
904 | 1294 | 1276 | return GEARMAN_MEMORY_ALLOCATION_FAILURE; | |
905 | 1295 | return ret; | 1277 | } |
906 | 1296 | } | 1278 | |
907 | 1297 | 1279 | gearman_return_t ret; | |
908 | 1298 | if (worker->function_list) | 1280 | if (timeout > 0) |
909 | 1299 | { | 1281 | { |
910 | 1300 | worker->function_list->prev= function; | 1282 | char timeout_buffer[11]; |
911 | 1301 | } | 1283 | snprintf(timeout_buffer, sizeof(timeout_buffer), "%u", timeout); |
912 | 1302 | 1284 | args[0]= function->name(); | |
913 | 1303 | function->next= worker->function_list; | 1285 | args_size[0]= function->length() + 1; |
914 | 1304 | function->prev= NULL; | 1286 | args[1]= timeout_buffer; |
915 | 1305 | worker->function_list= function; | 1287 | args_size[1]= strlen(timeout_buffer); |
916 | 1306 | worker->function_count++; | 1288 | ret= gearman_packet_create_args(worker->universal, function->packet(), |
917 | 1307 | 1289 | GEARMAN_MAGIC_REQUEST, | |
918 | 1308 | worker->options.change= true; | 1290 | GEARMAN_COMMAND_CAN_DO_TIMEOUT, |
919 | 1309 | 1291 | args, args_size, 2); | |
920 | 1310 | return GEARMAN_SUCCESS; | 1292 | } |
921 | 1311 | } | 1293 | else |
922 | 1312 | 1294 | { | |
923 | 1313 | return GEARMAN_INVALID_ARGUMENT; | 1295 | args[0]= function->name(); |
924 | 1296 | args_size[0]= function->length(); | ||
925 | 1297 | ret= gearman_packet_create_args(worker->universal, function->packet(), | ||
926 | 1298 | GEARMAN_MAGIC_REQUEST, GEARMAN_COMMAND_CAN_DO, | ||
927 | 1299 | args, args_size, 1); | ||
928 | 1300 | } | ||
929 | 1301 | |||
930 | 1302 | if (gearman_failed(ret)) | ||
931 | 1303 | { | ||
932 | 1304 | delete function; | ||
933 | 1305 | |||
934 | 1306 | return ret; | ||
935 | 1307 | } | ||
936 | 1308 | |||
937 | 1309 | if (worker->function_list) | ||
938 | 1310 | { | ||
939 | 1311 | worker->function_list->prev= function; | ||
940 | 1312 | } | ||
941 | 1313 | |||
942 | 1314 | function->next= worker->function_list; | ||
943 | 1315 | function->prev= NULL; | ||
944 | 1316 | worker->function_list= function; | ||
945 | 1317 | worker->function_count++; | ||
946 | 1318 | |||
947 | 1319 | worker->options.change= true; | ||
948 | 1320 | |||
949 | 1321 | return GEARMAN_SUCCESS; | ||
950 | 1314 | } | 1322 | } |
951 | 1315 | 1323 | ||
952 | 1316 | static void _worker_function_free(Worker* worker, | 1324 | static void _worker_function_free(Worker* worker, |
953 | @@ -1354,8 +1362,16 @@ | |||
954 | 1354 | { | 1362 | { |
955 | 1355 | if (worker_shell and worker_shell->impl()) | 1363 | if (worker_shell and worker_shell->impl()) |
956 | 1356 | { | 1364 | { |
957 | 1365 | Worker* worker= worker_shell->impl(); | ||
958 | 1357 | gearman_string_t option= { option_arg, option_arg_size }; | 1366 | gearman_string_t option= { option_arg, option_arg_size }; |
960 | 1358 | return gearman_request_option(worker_shell->impl()->universal, option); | 1367 | |
961 | 1368 | if (gearman_success(gearman_server_option(worker->universal, option))) | ||
962 | 1369 | { | ||
963 | 1370 | if (gearman_request_option(worker->universal, option)) | ||
964 | 1371 | { | ||
965 | 1372 | return true; | ||
966 | 1373 | } | ||
967 | 1374 | } | ||
968 | 1359 | } | 1375 | } |
969 | 1360 | 1376 | ||
970 | 1361 | return false; | 1377 | return false; |
971 | 1362 | 1378 | ||
972 | === modified file 'libgearman/worker.hpp' | |||
973 | --- libgearman/worker.hpp 2013-07-06 00:33:10 +0000 | |||
974 | +++ libgearman/worker.hpp 2013-07-11 21:18:03 +0000 | |||
975 | @@ -43,6 +43,15 @@ | |||
976 | 43 | 43 | ||
977 | 44 | #include <stdexcept> | 44 | #include <stdexcept> |
978 | 45 | 45 | ||
979 | 46 | namespace { | ||
980 | 47 | |||
981 | 48 | inline void all_worker_PRINTER(const char *line, gearman_verbose_t verbose, void*) | ||
982 | 49 | { | ||
983 | 50 | fprintf(stderr, "%s:%d WORKER %s(%s)\n", __FILE__, __LINE__, gearman_verbose_name(verbose), line); | ||
984 | 51 | } | ||
985 | 52 | |||
986 | 53 | } | ||
987 | 54 | |||
988 | 46 | namespace org { namespace gearmand { namespace libgearman { | 55 | namespace org { namespace gearmand { namespace libgearman { |
989 | 47 | 56 | ||
990 | 48 | class Worker { | 57 | class Worker { |
991 | @@ -55,6 +64,7 @@ | |||
992 | 55 | { | 64 | { |
993 | 56 | throw std::runtime_error("gearman_worker_create() failed"); | 65 | throw std::runtime_error("gearman_worker_create() failed"); |
994 | 57 | } | 66 | } |
995 | 67 | enable_logging(); | ||
996 | 58 | 68 | ||
997 | 59 | enable_ssl(); | 69 | enable_ssl(); |
998 | 60 | } | 70 | } |
999 | @@ -67,6 +77,8 @@ | |||
1000 | 67 | { | 77 | { |
1001 | 68 | throw std::runtime_error("gearman_worker_create() failed"); | 78 | throw std::runtime_error("gearman_worker_create() failed"); |
1002 | 69 | } | 79 | } |
1003 | 80 | enable_logging(); | ||
1004 | 81 | |||
1005 | 70 | gearman_worker_add_server(_worker, "localhost", arg); | 82 | gearman_worker_add_server(_worker, "localhost", arg); |
1006 | 71 | 83 | ||
1007 | 72 | enable_ssl(); | 84 | enable_ssl(); |
1008 | @@ -87,6 +99,15 @@ | |||
1009 | 87 | gearman_worker_free(_worker); | 99 | gearman_worker_free(_worker); |
1010 | 88 | } | 100 | } |
1011 | 89 | 101 | ||
1012 | 102 | void enable_logging() | ||
1013 | 103 | { | ||
1014 | 104 | if (getenv("YATL_WORKER_LOGGING")) | ||
1015 | 105 | { | ||
1016 | 106 | gearman_log_fn *func= all_worker_PRINTER; | ||
1017 | 107 | gearman_worker_set_log_fn(_worker, func, NULL, GEARMAN_VERBOSE_ERROR); | ||
1018 | 108 | } | ||
1019 | 109 | } | ||
1020 | 110 | |||
1021 | 90 | void enable_ssl() | 111 | void enable_ssl() |
1022 | 91 | { | 112 | { |
1023 | 92 | if (getenv("GEARMAND_CA_CERTIFICATE")) | 113 | if (getenv("GEARMAND_CA_CERTIFICATE")) |
1024 | 93 | 114 | ||
1025 | === modified file 'tests/libgearman-1.0/gearman_execute_partition.cc' | |||
1026 | --- tests/libgearman-1.0/gearman_execute_partition.cc 2013-07-10 10:54:09 +0000 | |||
1027 | +++ tests/libgearman-1.0/gearman_execute_partition.cc 2013-07-11 21:18:03 +0000 | |||
1028 | @@ -55,7 +55,7 @@ | |||
1029 | 55 | #pragma GCC diagnostic ignored "-Wold-style-cast" | 55 | #pragma GCC diagnostic ignored "-Wold-style-cast" |
1030 | 56 | #endif | 56 | #endif |
1031 | 57 | 57 | ||
1033 | 58 | #define WORKER_FUNCTION_NAME "client_test" | 58 | #define WORKER_FUNCTION_NAME "partition_client_test" |
1034 | 59 | #define WORKER_SPLIT_FUNCTION_NAME "split_worker" | 59 | #define WORKER_SPLIT_FUNCTION_NAME "split_worker" |
1035 | 60 | 60 | ||
1036 | 61 | test_return_t partition_SETUP(void *object) | 61 | test_return_t partition_SETUP(void *object) |
1037 | @@ -105,7 +105,7 @@ | |||
1038 | 105 | 105 | ||
1039 | 106 | // Test client as NULL | 106 | // Test client as NULL |
1040 | 107 | gearman_task_st *task= gearman_execute_by_partition(NULL, | 107 | gearman_task_st *task= gearman_execute_by_partition(NULL, |
1042 | 108 | test_literal_param("split_worker"), | 108 | test_literal_param(WORKER_SPLIT_FUNCTION_NAME), |
1043 | 109 | test_literal_param(WORKER_FUNCTION_NAME), | 109 | test_literal_param(WORKER_FUNCTION_NAME), |
1044 | 110 | NULL, 0, // unique | 110 | NULL, 0, // unique |
1045 | 111 | NULL, | 111 | NULL, |
1046 | @@ -141,7 +141,7 @@ | |||
1047 | 141 | gearman_argument_t workload= gearman_argument_make(0, 0, test_literal_param("this dog does not hunt")); | 141 | gearman_argument_t workload= gearman_argument_make(0, 0, test_literal_param("this dog does not hunt")); |
1048 | 142 | 142 | ||
1049 | 143 | gearman_task_st *task= gearman_execute_by_partition(client, | 143 | gearman_task_st *task= gearman_execute_by_partition(client, |
1051 | 144 | test_literal_param("split_worker"), | 144 | test_literal_param(WORKER_SPLIT_FUNCTION_NAME), |
1052 | 145 | test_literal_param(WORKER_FUNCTION_NAME), | 145 | test_literal_param(WORKER_FUNCTION_NAME), |
1053 | 146 | NULL, 0, // unique | 146 | NULL, 0, // unique |
1054 | 147 | NULL, | 147 | NULL, |
1055 | @@ -151,7 +151,7 @@ | |||
1056 | 151 | gearman_result_st *result= gearman_task_result(task); | 151 | gearman_result_st *result= gearman_task_result(task); |
1057 | 152 | ASSERT_TRUE(result); | 152 | ASSERT_TRUE(result); |
1058 | 153 | const char *value= gearman_result_value(result); | 153 | const char *value= gearman_result_value(result); |
1060 | 154 | test_truth(value); | 154 | ASSERT_TRUE(value); |
1061 | 155 | ASSERT_EQ(18UL, gearman_result_size(result)); | 155 | ASSERT_EQ(18UL, gearman_result_size(result)); |
1062 | 156 | 156 | ||
1063 | 157 | gearman_task_free(task); | 157 | gearman_task_free(task); |
1064 | @@ -171,14 +171,14 @@ | |||
1065 | 171 | gearman_argument_t workload= gearman_argument_make(0, 0, test_literal_param("this dog does not hunt mapper_fail")); | 171 | gearman_argument_t workload= gearman_argument_make(0, 0, test_literal_param("this dog does not hunt mapper_fail")); |
1066 | 172 | 172 | ||
1067 | 173 | gearman_task_st *task= gearman_execute_by_partition(client, | 173 | gearman_task_st *task= gearman_execute_by_partition(client, |
1069 | 174 | test_literal_param("split_worker"), | 174 | test_literal_param(WORKER_SPLIT_FUNCTION_NAME), |
1070 | 175 | gearman_string_param_cstr(worker_function), | 175 | gearman_string_param_cstr(worker_function), |
1071 | 176 | NULL, 0, // unique | 176 | NULL, 0, // unique |
1072 | 177 | NULL, | 177 | NULL, |
1073 | 178 | &workload, 0); | 178 | &workload, 0); |
1074 | 179 | test_true(task); | 179 | test_true(task); |
1075 | 180 | 180 | ||
1077 | 181 | ASSERT_EQ(GEARMAN_WORK_FAIL, gearman_task_return(task)); | 181 | ASSERT_EQ(GEARMAN_WORK_EXCEPTION, gearman_task_return(task)); |
1078 | 182 | 182 | ||
1079 | 183 | gearman_task_free(task); | 183 | gearman_task_free(task); |
1080 | 184 | gearman_client_task_free_all(client); | 184 | gearman_client_task_free_all(client); |
1081 | @@ -196,7 +196,7 @@ | |||
1082 | 196 | gearman_argument_t workload= gearman_argument_make(0, 0, test_literal_param("this dog does not hunt fail")); | 196 | gearman_argument_t workload= gearman_argument_make(0, 0, test_literal_param("this dog does not hunt fail")); |
1083 | 197 | 197 | ||
1084 | 198 | gearman_task_st *task= gearman_execute_by_partition(client, | 198 | gearman_task_st *task= gearman_execute_by_partition(client, |
1086 | 199 | test_literal_param("split_worker"), | 199 | test_literal_param(WORKER_SPLIT_FUNCTION_NAME), |
1087 | 200 | gearman_string_param_cstr(worker_function), | 200 | gearman_string_param_cstr(worker_function), |
1088 | 201 | NULL, 0, // unique | 201 | NULL, 0, // unique |
1089 | 202 | NULL, | 202 | NULL, |
1090 | @@ -224,7 +224,7 @@ | |||
1091 | 224 | gearman_argument_t workload= gearman_argument_make(0, 0, test_literal_param("this dog does not hunt")); | 224 | gearman_argument_t workload= gearman_argument_make(0, 0, test_literal_param("this dog does not hunt")); |
1092 | 225 | 225 | ||
1093 | 226 | gearman_task_st *task= gearman_execute(client, | 226 | gearman_task_st *task= gearman_execute(client, |
1095 | 227 | test_literal_param("split_worker"), | 227 | test_literal_param(WORKER_SPLIT_FUNCTION_NAME), |
1096 | 228 | NULL, 0, // unique | 228 | NULL, 0, // unique |
1097 | 229 | NULL, | 229 | NULL, |
1098 | 230 | &workload, 0); | 230 | &workload, 0); |
1099 | 231 | 231 | ||
1100 | === modified file 'tests/protocol.cc' | |||
1101 | --- tests/protocol.cc 2013-06-27 22:23:44 +0000 | |||
1102 | +++ tests/protocol.cc 2013-07-11 21:18:03 +0000 | |||
1103 | @@ -70,6 +70,7 @@ | |||
1104 | 70 | 70 | ||
1105 | 71 | gearman_universal_st universal; | 71 | gearman_universal_st universal; |
1106 | 72 | gearman_set_log_fn(universal, error_logger, NULL, GEARMAN_VERBOSE_ERROR); | 72 | gearman_set_log_fn(universal, error_logger, NULL, GEARMAN_VERBOSE_ERROR); |
1107 | 73 | universal.ssl(libtest::is_ssl()); | ||
1108 | 73 | 74 | ||
1109 | 74 | gearman_packet_st message; | 75 | gearman_packet_st message; |
1110 | 75 | 76 | ||
1111 | @@ -111,6 +112,7 @@ | |||
1112 | 111 | 112 | ||
1113 | 112 | gearman_universal_st universal; | 113 | gearman_universal_st universal; |
1114 | 113 | gearman_set_log_fn(universal, error_logger, NULL, GEARMAN_VERBOSE_ERROR); | 114 | gearman_set_log_fn(universal, error_logger, NULL, GEARMAN_VERBOSE_ERROR); |
1115 | 115 | universal.ssl(libtest::is_ssl()); | ||
1116 | 114 | 116 | ||
1117 | 115 | gearman_packet_st message; | 117 | gearman_packet_st message; |
1118 | 116 | 118 | ||
1119 | @@ -152,6 +154,7 @@ | |||
1120 | 152 | 154 | ||
1121 | 153 | gearman_universal_st universal; | 155 | gearman_universal_st universal; |
1122 | 154 | gearman_set_log_fn(universal, error_logger, NULL, GEARMAN_VERBOSE_ERROR); | 156 | gearman_set_log_fn(universal, error_logger, NULL, GEARMAN_VERBOSE_ERROR); |
1123 | 157 | universal.ssl(libtest::is_ssl()); | ||
1124 | 155 | 158 | ||
1125 | 156 | gearman_packet_st message; | 159 | gearman_packet_st message; |
1126 | 157 | 160 | ||
1127 | 158 | 161 | ||
1128 | === modified file 'tests/start_worker.cc' | |||
1129 | --- tests/start_worker.cc 2013-05-07 09:50:42 +0000 | |||
1130 | +++ tests/start_worker.cc 2013-07-11 21:18:03 +0000 | |||
1131 | @@ -165,16 +165,9 @@ | |||
1132 | 165 | gearman_worker_set_namespace(&worker, context->namespace_key.c_str(), context->namespace_key.length()); | 165 | gearman_worker_set_namespace(&worker, context->namespace_key.c_str(), context->namespace_key.length()); |
1133 | 166 | } | 166 | } |
1134 | 167 | 167 | ||
1136 | 168 | // Check for a working server by "asking" it for an option | 168 | // Set worker id |
1137 | 169 | { | 169 | { |
1146 | 170 | size_t count= 5; | 170 | if (gearman_failed(gearman_worker_set_identifier(&worker, gearman_literal_param("start_worker")))) |
1139 | 171 | bool success= false; | ||
1140 | 172 | while (--count and success == false) | ||
1141 | 173 | { | ||
1142 | 174 | success= gearman_worker_set_server_option(&worker, test_literal_param("exceptions")); | ||
1143 | 175 | } | ||
1144 | 176 | |||
1145 | 177 | if (success == false) | ||
1147 | 178 | { | 171 | { |
1148 | 179 | Out << "gearman_worker_set_server_option() failed"; | 172 | Out << "gearman_worker_set_server_option() failed"; |
1149 | 180 | context->fail(); | 173 | context->fail(); |
1150 | @@ -182,6 +175,14 @@ | |||
1151 | 182 | } | 175 | } |
1152 | 183 | } | 176 | } |
1153 | 184 | 177 | ||
1154 | 178 | // Check for a working server by pinging it with echo | ||
1155 | 179 | if (gearman_failed(gearman_worker_echo(&worker, gearman_literal_param("start_worker")))) | ||
1156 | 180 | { | ||
1157 | 181 | Out << "gearman_worker_set_server_option() failed"; | ||
1158 | 182 | context->fail(); | ||
1159 | 183 | return; | ||
1160 | 184 | } | ||
1161 | 185 | |||
1162 | 185 | if (gearman_failed(gearman_worker_define_function(&worker, | 186 | if (gearman_failed(gearman_worker_define_function(&worker, |
1163 | 186 | context->function_name.c_str(), context->function_name.length(), | 187 | context->function_name.c_str(), context->function_name.length(), |
1164 | 187 | context->worker_fn, | 188 | context->worker_fn, |
1165 | 188 | 189 | ||
1166 | === modified file 'tests/workers/v2/split.cc' | |||
1167 | --- tests/workers/v2/split.cc 2012-10-29 20:00:10 +0000 | |||
1168 | +++ tests/workers/v2/split.cc 2013-07-11 21:18:03 +0000 | |||
1169 | @@ -62,16 +62,16 @@ | |||
1170 | 62 | { | 62 | { |
1171 | 63 | if (int(workload[x]) == 0 or int(workload[x]) == int(' ')) | 63 | if (int(workload[x]) == 0 or int(workload[x]) == int(' ')) |
1172 | 64 | { | 64 | { |
1174 | 65 | if ((workload +x -chunk_begin) == 11 and not memcmp(chunk_begin, test_literal_param("mapper_fail"))) | 65 | if ((workload +x -chunk_begin) == 11 and memcmp(chunk_begin, test_literal_param("mapper_fail") == 0)) |
1175 | 66 | { | 66 | { |
1177 | 67 | return GEARMAN_FAIL; | 67 | return gearman_job_send_exception(job, test_literal_param("Error occured on purpose")); |
1178 | 68 | } | 68 | } |
1179 | 69 | 69 | ||
1180 | 70 | // NULL Chunk | 70 | // NULL Chunk |
1181 | 71 | gearman_return_t rc= gearman_job_send_data(job, chunk_begin, workload +x -chunk_begin); | 71 | gearman_return_t rc= gearman_job_send_data(job, chunk_begin, workload +x -chunk_begin); |
1182 | 72 | if (gearman_failed(rc)) | 72 | if (gearman_failed(rc)) |
1183 | 73 | { | 73 | { |
1185 | 74 | return GEARMAN_FAIL; | 74 | return gearman_job_send_exception(job, test_literal_param("gearman_job_send_data() failed")); |
1186 | 75 | } | 75 | } |
1187 | 76 | 76 | ||
1188 | 77 | chunk_begin= workload +x +1; | 77 | chunk_begin= workload +x +1; |
1189 | @@ -82,16 +82,15 @@ | |||
1190 | 82 | { | 82 | { |
1191 | 83 | if ((size_t(workload +workload_size) -size_t(chunk_begin) ) == 11 and not memcmp(chunk_begin, test_literal_param("mapper_fail"))) | 83 | if ((size_t(workload +workload_size) -size_t(chunk_begin) ) == 11 and not memcmp(chunk_begin, test_literal_param("mapper_fail"))) |
1192 | 84 | { | 84 | { |
1194 | 85 | return GEARMAN_FAIL; | 85 | return gearman_job_send_exception(job, test_literal_param("Error occured on purpose")); |
1195 | 86 | } | 86 | } |
1196 | 87 | 87 | ||
1197 | 88 | gearman_return_t rc= gearman_job_send_data(job, chunk_begin, size_t(workload +workload_size) -size_t(chunk_begin)); | 88 | gearman_return_t rc= gearman_job_send_data(job, chunk_begin, size_t(workload +workload_size) -size_t(chunk_begin)); |
1198 | 89 | if (gearman_failed(rc)) | 89 | if (gearman_failed(rc)) |
1199 | 90 | { | 90 | { |
1201 | 91 | return GEARMAN_FAIL; | 91 | return gearman_job_send_exception(job, test_literal_param("gearman_job_send_data() failed")); |
1202 | 92 | } | 92 | } |
1203 | 93 | } | 93 | } |
1204 | 94 | 94 | ||
1205 | 95 | return GEARMAN_SUCCESS; | 95 | return GEARMAN_SUCCESS; |
1206 | 96 | } | 96 | } |
1207 | 97 |