Merge lp:~trond-norbye/libmemcached/no-docs into lp:~brianaker/libmemcached/build
- no-docs
- Merge into build
Proposed by
Trond Norbye
Status: | Rejected |
---|---|
Rejected by: | Brian Aker |
Proposed branch: | lp:~trond-norbye/libmemcached/no-docs |
Merge into: | lp:~brianaker/libmemcached/build |
Diff against target: |
2309 lines (+841/-417) 44 files modified
.bzrignore (+1/-0) ChangeLog (+10/-1) Makefile.am (+8/-3) clients/execute.c (+3/-5) clients/execute.h (+3/-0) clients/generator.c (+1/-1) clients/memcat.c (+2/-1) clients/memcp.c (+6/-1) clients/memdump.c (+2/-1) clients/memerror.c (+1/-1) clients/memflush.c (+1/-1) clients/memrm.c (+1/-1) clients/memstat.c (+12/-31) clients/utilities.c (+1/-1) clients/utilities.h (+1/-0) configure.ac (+31/-4) libhashkit/hsieh.c (+5/-3) libmemcached/behavior.c (+1/-0) libmemcached/common.h (+9/-1) libmemcached/connect.c (+197/-152) libmemcached/delete.c (+1/-1) libmemcached/include.am (+4/-3) libmemcached/io.c (+22/-17) libmemcached/response.c (+2/-0) libmemcached/server.c (+20/-0) libmemcached/stats.c (+77/-16) libmemcached/stats.h (+3/-0) libmemcached/types.h (+4/-0) libmemcached/util/version.c (+7/-6) libmemcached/util/version.h (+2/-2) libmemcached/version.c (+11/-2) m4/pandora_warnings.m4 (+1/-1) support/libmemcached.spec.in (+23/-12) tests/atomsmasher.c (+5/-9) tests/hashkit_functions.c (+2/-0) tests/include.am (+8/-5) tests/mem_functions.c (+131/-120) tests/mem_udp.c (+3/-8) tests/server.c (+38/-7) tests/start.c (+2/-0) tests/test.c (+4/-0) unittests/include.am (+20/-0) unittests/main.cc (+21/-0) unittests/strings.cc (+134/-0) |
To merge this branch: | bzr merge lp:~trond-norbye/libmemcached/no-docs |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Libmemcached-developers | Pending | ||
Review via email: mp+30556@code.launchpad.net |
Commit message
Description of the change
Added --without-docs to configure
The purpose of this option is to be able to disable generation of manual
pages from pod2man (to enable compilation of libmemcached on systems
without a working pod2man)
To post a comment you must log in.
Revision history for this message
Brian Aker (brianaker) wrote : | # |
Unmerged revisions
- 883. By Trond Norbye
-
Added --without-docs to configure
The purpose of this option is to be able to disable generation of manual
pages from pod2man (to enable compilation of libmemcached on systems
without a working pod2man) - 882. By Brian Aker <brian@gaz>
-
Found issue from Fedora builder compiling with --with-debug
- 881. By Brian Aker <brian@gaz>
-
Merge in cast fix for H algo
- 880. By Brian Aker <brian@gaz>
-
Type on attribute.
- 879. By Brian Aker <brian@gaz>
-
Verify that servers have started up by reading their pid file.
- 878. By Brian Aker <brian@gaz>
-
Possible fix for OSX slow server startup
- 877. By Brian Aker <brian@gaz>
-
Tiny style fix
- 876. By Brian Aker <brian@gaz>
-
Merge in usage for execute_stat.
- 875. By Brian Aker <brian@gaz>
-
Merge in memcached_
stat_execute( ). - 874. By Brian Aker <brian@gaz>
-
Fix for versioning information.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2010-02-21 10:59:22 +0000 |
3 | +++ .bzrignore 2010-07-21 16:27:47 +0000 |
4 | @@ -181,3 +181,4 @@ |
5 | tests/testhashkit |
6 | tests/testplus |
7 | tests/testudp |
8 | +unittests/unittests |
9 | |
10 | === modified file 'ChangeLog' |
11 | --- ChangeLog 2010-06-11 01:43:08 +0000 |
12 | +++ ChangeLog 2010-07-21 16:27:47 +0000 |
13 | @@ -1,6 +1,15 @@ |
14 | -0.41 |
15 | +0.43 |
16 | + * memcached_stat_execute() merged. |
17 | + |
18 | +0.42 Tue Jul 6 12:29:50 PDT 2010 |
19 | + * Mistake in libtool caused issue with library version |
20 | + |
21 | +0.41 Wed Jun 30 13:15:19 PDT 2010 |
22 | * Added --file for memcat. |
23 | * Added limemcached_ping() to libmemcached_util |
24 | + * Bugfix for some cases where connect would have issues with timeout. |
25 | + * Wrong value for errno given as error on an IO failure inside of poll. |
26 | + * Bug fix for issue where multiple interfaces with bad DNS were not being caught. |
27 | |
28 | 0.40 Thu Apr 22 19:01:25 PDT 2010 |
29 | * Placed retry logic in for busted resolvers |
30 | |
31 | === modified file 'Makefile.am' |
32 | --- Makefile.am 2010-06-13 16:21:08 +0000 |
33 | +++ Makefile.am 2010-07-21 16:27:47 +0000 |
34 | @@ -12,6 +12,7 @@ |
35 | noinst_PROGRAMS = |
36 | include_HEADERS = |
37 | nobase_include_HEADERS = |
38 | +check_PROGRAMS = |
39 | EXTRA_HEADERS = |
40 | BUILT_SOURCES= |
41 | EXTRA_DIST= \ |
42 | @@ -29,19 +30,23 @@ |
43 | m4/po.m4 \ |
44 | m4/progtest.m4 |
45 | |
46 | - |
47 | +TEST_DOCS= |
48 | +if BUILD_DOCS |
49 | SUBDIRS = docs |
50 | +TEST_DOCS+=test-docs |
51 | +endif |
52 | |
53 | test-docs: |
54 | (cd docs && $(MAKE) test-docs) |
55 | include libmemcached/include.am |
56 | include clients/include.am |
57 | include libhashkit/include.am |
58 | +include unittests/include.am |
59 | include tests/include.am |
60 | include example/include.am |
61 | include support/include.am |
62 | |
63 | -check-local: test-no-outputdiff |
64 | +TESTS += ${check_PROGRAMS} |
65 | |
66 | |
67 | fedora: |
68 | @@ -82,7 +87,7 @@ |
69 | genhtml -o lcov --function-coverage -t libmemcached libmemcached/lcov.out |
70 | |
71 | lcov-clean: clean |
72 | - rm -rf lcov */lcov.out |
73 | + rm -rf lcov */lcov.out |
74 | find . -name '*.gcno' | xargs rm -f |
75 | find . -name '*.gcda' | xargs rm -f |
76 | |
77 | |
78 | === modified file 'clients/execute.c' |
79 | --- clients/execute.c 2010-01-16 01:50:37 +0000 |
80 | +++ clients/execute.c 2010-07-21 16:27:47 +0000 |
81 | @@ -14,8 +14,7 @@ |
82 | Return the number of rows set. |
83 | */ |
84 | |
85 | -#include "libmemcached/common.h" |
86 | - |
87 | +#include "config.h" |
88 | #include "execute.h" |
89 | |
90 | unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of) |
91 | @@ -108,12 +107,11 @@ |
92 | rc= memcached_mget_execute(memc, keys, key_length, |
93 | (size_t)number_of, callbacks, &retrieved, 1); |
94 | |
95 | - likely (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOTFOUND || |
96 | + if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOTFOUND || |
97 | rc == MEMCACHED_BUFFERED || rc == MEMCACHED_END) |
98 | { |
99 | rc= memcached_fetch_execute(memc, callbacks, (void *)&retrieved, 1); |
100 | - unlikely (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_NOTFOUND && |
101 | - rc != MEMCACHED_END) |
102 | + if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_NOTFOUND && rc != MEMCACHED_END) |
103 | { |
104 | fprintf(stderr, "Failed to execute mget: %s\n", |
105 | memcached_strerror(memc, rc)); |
106 | |
107 | === modified file 'clients/execute.h' |
108 | --- clients/execute.h 2009-12-16 19:03:49 +0000 |
109 | +++ clients/execute.h 2010-07-21 16:27:47 +0000 |
110 | @@ -11,6 +11,9 @@ |
111 | |
112 | #ifndef CLIENTS_EXECUTE_H |
113 | #define CLIENTS_EXECUTE_H |
114 | + |
115 | +#include <stdio.h> |
116 | + |
117 | #include "libmemcached/memcached.h" |
118 | #include "generator.h" |
119 | |
120 | |
121 | === modified file 'clients/generator.c' |
122 | --- clients/generator.c 2010-04-22 00:49:09 +0000 |
123 | +++ clients/generator.c 2010-07-21 16:27:47 +0000 |
124 | @@ -9,7 +9,7 @@ |
125 | * |
126 | */ |
127 | |
128 | -#include "libmemcached/common.h" |
129 | +#include "config.h" |
130 | |
131 | #include <stdio.h> |
132 | #include <stdlib.h> |
133 | |
134 | === modified file 'clients/memcat.c' |
135 | --- clients/memcat.c 2010-06-08 19:05:16 +0000 |
136 | +++ clients/memcat.c 2010-07-21 16:27:47 +0000 |
137 | @@ -9,7 +9,8 @@ |
138 | * |
139 | */ |
140 | |
141 | -#include "libmemcached/common.h" |
142 | +#include "config.h" |
143 | + |
144 | #include <stdio.h> |
145 | #include <inttypes.h> |
146 | #include <string.h> |
147 | |
148 | === modified file 'clients/memcp.c' |
149 | --- clients/memcp.c 2010-03-03 10:50:13 +0000 |
150 | +++ clients/memcp.c 2010-07-21 16:27:47 +0000 |
151 | @@ -9,7 +9,8 @@ |
152 | * |
153 | */ |
154 | |
155 | -#include "libmemcached/common.h" |
156 | +#include "config.h" |
157 | + |
158 | #include <stdio.h> |
159 | #include <stdlib.h> |
160 | #include <inttypes.h> |
161 | @@ -22,6 +23,10 @@ |
162 | #include <errno.h> |
163 | #include <strings.h> |
164 | #include <string.h> |
165 | +#include <sys/types.h> |
166 | +#include <stdlib.h> |
167 | +#include <limits.h> |
168 | + |
169 | |
170 | #include <libmemcached/memcached.h> |
171 | |
172 | |
173 | === modified file 'clients/memdump.c' |
174 | --- clients/memdump.c 2010-03-03 10:50:13 +0000 |
175 | +++ clients/memdump.c 2010-07-21 16:27:47 +0000 |
176 | @@ -9,7 +9,8 @@ |
177 | * |
178 | */ |
179 | |
180 | -#include "libmemcached/common.h" |
181 | +#include "config.h" |
182 | + |
183 | #include <stdio.h> |
184 | #include <stdlib.h> |
185 | #include <inttypes.h> |
186 | |
187 | === modified file 'clients/memerror.c' |
188 | --- clients/memerror.c 2010-01-14 21:37:53 +0000 |
189 | +++ clients/memerror.c 2010-07-21 16:27:47 +0000 |
190 | @@ -8,8 +8,8 @@ |
191 | * Summary: |
192 | * |
193 | */ |
194 | +#include "config.h" |
195 | |
196 | -#include "libmemcached/common.h" |
197 | #include <stdio.h> |
198 | #include <inttypes.h> |
199 | #include <string.h> |
200 | |
201 | === modified file 'clients/memflush.c' |
202 | --- clients/memflush.c 2010-03-03 10:50:13 +0000 |
203 | +++ clients/memflush.c 2010-07-21 16:27:47 +0000 |
204 | @@ -8,8 +8,8 @@ |
205 | * Summary: |
206 | * |
207 | */ |
208 | +#include "config.h" |
209 | |
210 | -#include "libmemcached/common.h" |
211 | #include <stdio.h> |
212 | #include <unistd.h> |
213 | #include <string.h> |
214 | |
215 | === modified file 'clients/memrm.c' |
216 | --- clients/memrm.c 2010-03-03 10:50:13 +0000 |
217 | +++ clients/memrm.c 2010-07-21 16:27:47 +0000 |
218 | @@ -8,8 +8,8 @@ |
219 | * Summary: |
220 | * |
221 | */ |
222 | +#include "config.h" |
223 | |
224 | -#include "libmemcached/common.h" |
225 | #include <stdio.h> |
226 | #include <unistd.h> |
227 | #include <getopt.h> |
228 | |
229 | === modified file 'clients/memstat.c' |
230 | --- clients/memstat.c 2010-03-10 00:45:36 +0000 |
231 | +++ clients/memstat.c 2010-07-21 16:27:47 +0000 |
232 | @@ -11,8 +11,8 @@ |
233 | * Brian Aker |
234 | * Toru Maesaka |
235 | */ |
236 | +#include "config.h" |
237 | |
238 | -#include "libmemcached/common.h" |
239 | #include <stdio.h> |
240 | #include <sys/types.h> |
241 | #include <sys/stat.h> |
242 | @@ -56,36 +56,22 @@ |
243 | }; |
244 | |
245 | |
246 | -static memcached_return_t server_print_callback(const memcached_st *memc, |
247 | - memcached_server_instance_st instance, |
248 | - void *context) |
249 | +static memcached_return_t stat_printer(memcached_server_instance_st instance, |
250 | + const char *key, size_t key_length, |
251 | + const char *value, size_t value_length, |
252 | + void *context) |
253 | { |
254 | - memcached_stat_st server_stat; |
255 | - memcached_return_t rc; |
256 | - char **list; |
257 | - char **ptr; |
258 | - |
259 | + static memcached_server_instance_st last= NULL; |
260 | (void)context; |
261 | |
262 | - rc= memcached_stat_servername(&server_stat, NULL, |
263 | - memcached_server_name(instance), |
264 | - memcached_server_port(instance)); |
265 | - |
266 | - list= memcached_stat_get_keys(memc, &server_stat, &rc); |
267 | - |
268 | - printf("Server: %s (%u)\n", memcached_server_name(instance), |
269 | - (uint32_t)memcached_server_port(instance)); |
270 | - |
271 | - for (ptr= list; *ptr; ptr++) |
272 | + if (last != instance) |
273 | { |
274 | - char *value= memcached_stat_get_value(memc, &server_stat, *ptr, &rc); |
275 | - |
276 | - printf("\t %s: %s\n", *ptr, value); |
277 | - free(value); |
278 | + printf("Server: %s (%u)\n", memcached_server_name(instance), |
279 | + (uint32_t)memcached_server_port(instance)); |
280 | + last= instance; |
281 | } |
282 | |
283 | - free(list); |
284 | - printf("\n"); |
285 | + printf("\t %.*s: %.*s\n", (int)key_length, key, (int)value_length, value); |
286 | |
287 | return MEMCACHED_SUCCESS; |
288 | } |
289 | @@ -140,12 +126,7 @@ |
290 | } |
291 | else |
292 | { |
293 | - memcached_server_fn callbacks[1]; |
294 | - |
295 | - callbacks[0]= server_print_callback; |
296 | - rc= memcached_server_cursor(memc, callbacks, |
297 | - NULL, 1); |
298 | - |
299 | + rc= memcached_stat_execute(memc, NULL, stat_printer, NULL); |
300 | } |
301 | |
302 | free(opt_servers); |
303 | |
304 | === modified file 'clients/utilities.c' |
305 | --- clients/utilities.c 2010-05-24 09:08:06 +0000 |
306 | +++ clients/utilities.c 2010-07-21 16:27:47 +0000 |
307 | @@ -8,8 +8,8 @@ |
308 | * Summary: |
309 | * |
310 | */ |
311 | +#include "config.h" |
312 | |
313 | -#include "libmemcached/common.h" |
314 | #include <stdio.h> |
315 | #include <ctype.h> |
316 | #include <string.h> |
317 | |
318 | === modified file 'clients/utilities.h' |
319 | --- clients/utilities.h 2010-03-03 10:50:13 +0000 |
320 | +++ clients/utilities.h 2010-07-21 16:27:47 +0000 |
321 | @@ -11,6 +11,7 @@ |
322 | |
323 | #include <getopt.h> |
324 | #include <libmemcached/memcached.h> |
325 | +#include "libmemcached/watchpoint.h" |
326 | #include "client_options.h" |
327 | |
328 | #if TIME_WITH_SYS_TIME |
329 | |
330 | === modified file 'configure.ac' |
331 | --- configure.ac 2010-06-13 15:01:04 +0000 |
332 | +++ configure.ac 2010-07-21 16:27:47 +0000 |
333 | @@ -7,14 +7,16 @@ |
334 | # the COPYING file in this directory for full text. |
335 | |
336 | AC_PREREQ(2.59) |
337 | -AC_INIT([libmemcached],[0.41],[http://libmemcached.org/]) |
338 | +AC_INIT([libmemcached],[0.42],[http://libmemcached.org/]) |
339 | AC_CONFIG_SRCDIR([libmemcached/memcached.c]) |
340 | AC_CONFIG_AUX_DIR(config) |
341 | |
342 | PANDORA_CANONICAL_TARGET |
343 | |
344 | #shared library versioning |
345 | -MEMCACHED_LIBRARY_VERSION=5:1:1 |
346 | +MEMCACHED_UTIL_LIBRARY_VERSION=1:0:0 |
347 | +MEMCACHED_PROTOCAL_LIBRARY_VERSION=0:0:0 |
348 | +MEMCACHED_LIBRARY_VERSION=5:1:0 |
349 | # | | | |
350 | # +------+ | +---+ |
351 | # | | | |
352 | @@ -25,6 +27,8 @@ |
353 | # | +- increment if source code has changed |
354 | # | set to zero if current is incremented |
355 | # +- increment if interfaces have been added, removed or changed |
356 | +AC_SUBST(MEMCACHED_UTIL_LIBRARY_VERSION) |
357 | +AC_SUBST(MEMCACHED_PROTOCAL_LIBRARY_VERSION) |
358 | AC_SUBST(MEMCACHED_LIBRARY_VERSION) |
359 | |
360 | |
361 | @@ -36,6 +40,7 @@ |
362 | |
363 | AC_CHECK_FUNCS([getline]) |
364 | |
365 | +PANDORA_HAVE_LIBGTEST |
366 | PANDORA_HAVE_LIBEVENT |
367 | PANDORA_REQUIRE_PTHREAD |
368 | PANDORA_CXX_DEMANGLE |
369 | @@ -45,8 +50,6 @@ |
370 | ENABLE_UTILLIB |
371 | SETSOCKOPT_SANITY |
372 | ENABLE_HSIEH_HASH |
373 | -REQUIRE_POD2MAN |
374 | -REQUIRE_PODCHECKER |
375 | PROTOCOL_BINARY_TEST |
376 | WITH_MEMCACHED |
377 | ENABLE_DEPRECATED |
378 | @@ -68,6 +71,20 @@ |
379 | [1], |
380 | [Define to true if you want to use functions from atomic.h])])]) |
381 | |
382 | +AC_ARG_WITH([docs], |
383 | + [AS_HELP_STRING([--with-docs], |
384 | + [Generate documentation (yes|no) @<:@default=yes@:>@])], |
385 | + [with_docs=$withval], |
386 | + [with_docs=yes]) |
387 | + |
388 | +AS_IF([test "$with_docs" = "yes"], |
389 | + [ |
390 | + REQUIRE_POD2MAN |
391 | + REQUIRE_PODCHECKER |
392 | + ]) |
393 | +AM_CONDITIONAL(BUILD_DOCS, test "$with_docs" = "yes") |
394 | + |
395 | + |
396 | AC_CONFIG_FILES([ |
397 | Makefile |
398 | docs/Makefile |
399 | @@ -104,3 +121,13 @@ |
400 | ;; |
401 | esac |
402 | |
403 | +AS_IF(test "$with_docs" = "no", |
404 | + [ |
405 | + echo "*****" |
406 | + echo "*" |
407 | + echo "* WARNING: You are not generating any documentation." |
408 | + echo "* Please don't ship libmemcached to an end user" |
409 | + echo "* without documentation..." |
410 | + echo "*" |
411 | + echo "*****" |
412 | + ]) |
413 | |
414 | === modified file 'libhashkit/hsieh.c' |
415 | --- libhashkit/hsieh.c 2010-01-19 23:39:13 +0000 |
416 | +++ libhashkit/hsieh.c 2010-07-21 16:27:47 +0000 |
417 | @@ -17,7 +17,7 @@ |
418 | +(uint32_t)(((const uint8_t *)(d))[0]) ) |
419 | #endif |
420 | |
421 | -uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context__attribute__((unused))) |
422 | +uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context __attribute__((unused))) |
423 | { |
424 | uint32_t hash = 0, tmp; |
425 | int rem; |
426 | @@ -43,16 +43,18 @@ |
427 | { |
428 | case 3: hash += get16bits (key); |
429 | hash ^= hash << 16; |
430 | - hash ^= key[sizeof (uint16_t)] << 18; |
431 | + hash ^= (uint32_t)key[sizeof (uint16_t)] << 18; |
432 | hash += hash >> 11; |
433 | break; |
434 | case 2: hash += get16bits (key); |
435 | hash ^= hash << 11; |
436 | hash += hash >> 17; |
437 | break; |
438 | - case 1: hash += *key; |
439 | + case 1: hash += (unsigned char)(*key); |
440 | hash ^= hash << 10; |
441 | hash += hash >> 1; |
442 | + default: |
443 | + break; |
444 | } |
445 | |
446 | /* Force "avalanching" of final 127 bits */ |
447 | |
448 | === modified file 'libmemcached/behavior.c' |
449 | --- libmemcached/behavior.c 2010-04-05 19:01:19 +0000 |
450 | +++ libmemcached/behavior.c 2010-07-21 16:27:47 +0000 |
451 | @@ -55,6 +55,7 @@ |
452 | ptr->server_failure_limit= (uint32_t)data; |
453 | break; |
454 | case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: |
455 | + memcached_quit(ptr); // We need t shutdown all of the connections to make sure we do the correct protocol |
456 | if (data) |
457 | { |
458 | ptr->flags.verify_key= false; |
459 | |
460 | === modified file 'libmemcached/common.h' |
461 | --- libmemcached/common.h 2010-04-21 03:14:19 +0000 |
462 | +++ libmemcached/common.h 2010-07-21 16:27:47 +0000 |
463 | @@ -56,9 +56,17 @@ |
464 | |
465 | typedef struct memcached_server_st * memcached_server_write_instance_st; |
466 | |
467 | +typedef memcached_return_t (*memcached_server_execute_fn)(memcached_st *ptr, memcached_server_write_instance_st server, void *context); |
468 | + |
469 | LIBMEMCACHED_LOCAL |
470 | memcached_server_write_instance_st memcached_server_instance_fetch(memcached_st *ptr, uint32_t server_key); |
471 | |
472 | +LIBMEMCACHED_LOCAL |
473 | +memcached_return_t memcached_server_execute(memcached_st *ptr, |
474 | + memcached_server_execute_fn callback, |
475 | + void *context); |
476 | + |
477 | + |
478 | /* These are private not to be installed headers */ |
479 | #include "libmemcached/io.h" |
480 | #include "libmemcached/do.h" |
481 | @@ -79,7 +87,7 @@ |
482 | typedef enum { |
483 | MEM_NOT= -1, |
484 | MEM_FALSE= false, |
485 | - MEM_TRUE= true, |
486 | + MEM_TRUE= true |
487 | } memcached_ternary_t; |
488 | |
489 | |
490 | |
491 | === modified file 'libmemcached/connect.c' |
492 | --- libmemcached/connect.c 2010-06-13 21:04:20 +0000 |
493 | +++ libmemcached/connect.c 2010-07-21 16:27:47 +0000 |
494 | @@ -1,9 +1,96 @@ |
495 | +/* LibMemcached |
496 | + * Copyright (C) 2006-2010 Brian Aker |
497 | + * All rights reserved. |
498 | + * |
499 | + * Use and distribution licensed under the BSD license. See |
500 | + * the COPYING file in the parent directory for full text. |
501 | + * |
502 | + * Summary: Server IO, Not public! |
503 | + * |
504 | + */ |
505 | + |
506 | #include "common.h" |
507 | #include <netdb.h> |
508 | #include <poll.h> |
509 | #include <sys/time.h> |
510 | #include <time.h> |
511 | |
512 | +static memcached_return_t connect_poll(memcached_server_st *ptr) |
513 | +{ |
514 | + struct pollfd fds[1]; |
515 | + fds[0].fd = ptr->fd; |
516 | + fds[0].events = POLLOUT; |
517 | + |
518 | + int timeout= ptr->root->connect_timeout; |
519 | + if (ptr->root->flags.no_block == true) |
520 | + timeout= -1; |
521 | + |
522 | + int error; |
523 | + size_t loop_max= 5; |
524 | + |
525 | + while (--loop_max) // Should only loop on cases of ERESTART or EINTR |
526 | + { |
527 | + error= poll(fds, 1, timeout); |
528 | + |
529 | + switch (error) |
530 | + { |
531 | + case 1: |
532 | + { |
533 | + int err; |
534 | + socklen_t len= sizeof (err); |
535 | + (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len); |
536 | + |
537 | + // We check the value to see what happened wth the socket. |
538 | + if (err == 0) |
539 | + { |
540 | + return MEMCACHED_SUCCESS; |
541 | + } |
542 | + else |
543 | + { |
544 | + ptr->cached_errno= errno; |
545 | + |
546 | + return MEMCACHED_ERRNO; |
547 | + } |
548 | + } |
549 | + case 0: |
550 | + return MEMCACHED_TIMEOUT; |
551 | + default: // A real error occurred and we need to completely bail |
552 | + WATCHPOINT_ERRNO(errno); |
553 | + switch (errno) |
554 | + { |
555 | +#ifdef TARGET_OS_LINUX |
556 | + case ERESTART: |
557 | +#endif |
558 | + case EINTR: |
559 | + continue; |
560 | + default: |
561 | + if (fds[0].revents & POLLERR) |
562 | + { |
563 | + int err; |
564 | + socklen_t len= sizeof (err); |
565 | + (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len); |
566 | + ptr->cached_errno= (err == 0) ? errno : err; |
567 | + } |
568 | + else |
569 | + { |
570 | + ptr->cached_errno= errno; |
571 | + } |
572 | + |
573 | + (void)close(ptr->fd); |
574 | + ptr->fd= -1; |
575 | + |
576 | + return MEMCACHED_ERRNO; |
577 | + } |
578 | + } |
579 | + WATCHPOINT_ASSERT(0); // Programming error |
580 | + } |
581 | + |
582 | + // This should only be possible from ERESTART or EINTR; |
583 | + ptr->cached_errno= errno; |
584 | + |
585 | + return MEMCACHED_ERRNO; |
586 | +} |
587 | + |
588 | static memcached_return_t set_hostinfo(memcached_server_st *server) |
589 | { |
590 | struct addrinfo *ai; |
591 | @@ -225,36 +312,35 @@ |
592 | { |
593 | struct sockaddr_un servAddr; |
594 | |
595 | - if (ptr->fd == -1) |
596 | + WATCHPOINT_ASSERT(ptr->fd == -1); |
597 | + |
598 | + if ((ptr->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) |
599 | { |
600 | - if ((ptr->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) |
601 | - { |
602 | - ptr->cached_errno= errno; |
603 | - return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE; |
604 | - } |
605 | + ptr->cached_errno= errno; |
606 | + return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE; |
607 | + } |
608 | |
609 | - memset(&servAddr, 0, sizeof (struct sockaddr_un)); |
610 | - servAddr.sun_family= AF_UNIX; |
611 | - strcpy(servAddr.sun_path, ptr->hostname); /* Copy filename */ |
612 | + memset(&servAddr, 0, sizeof (struct sockaddr_un)); |
613 | + servAddr.sun_family= AF_UNIX; |
614 | + strcpy(servAddr.sun_path, ptr->hostname); /* Copy filename */ |
615 | |
616 | test_connect: |
617 | - if (connect(ptr->fd, |
618 | - (struct sockaddr *)&servAddr, |
619 | - sizeof(servAddr)) < 0) |
620 | + if (connect(ptr->fd, |
621 | + (struct sockaddr *)&servAddr, |
622 | + sizeof(servAddr)) < 0) |
623 | + { |
624 | + switch (errno) |
625 | { |
626 | - switch (errno) |
627 | - { |
628 | - case EINPROGRESS: |
629 | - case EALREADY: |
630 | - case EINTR: |
631 | - goto test_connect; |
632 | - case EISCONN: /* We were spinning waiting on connect */ |
633 | - break; |
634 | - default: |
635 | - WATCHPOINT_ERRNO(errno); |
636 | - ptr->cached_errno= errno; |
637 | - return MEMCACHED_ERRNO; |
638 | - } |
639 | + case EINPROGRESS: |
640 | + case EALREADY: |
641 | + case EINTR: |
642 | + goto test_connect; |
643 | + case EISCONN: /* We were spinning waiting on connect */ |
644 | + break; |
645 | + default: |
646 | + WATCHPOINT_ERRNO(errno); |
647 | + ptr->cached_errno= errno; |
648 | + return MEMCACHED_ERRNO; |
649 | } |
650 | } |
651 | |
652 | @@ -265,134 +351,78 @@ |
653 | |
654 | static memcached_return_t network_connect(memcached_server_st *ptr) |
655 | { |
656 | - if (ptr->fd == -1) |
657 | - { |
658 | - struct addrinfo *use; |
659 | - |
660 | - WATCHPOINT_ASSERT(ptr->cursor_active == 0); |
661 | - |
662 | - if (! ptr->options.sockaddr_inited || |
663 | - (!(ptr->root->flags.use_cache_lookups))) |
664 | + bool timeout_error_occured= false; |
665 | + |
666 | + |
667 | + WATCHPOINT_ASSERT(ptr->fd == -1); |
668 | + WATCHPOINT_ASSERT(ptr->cursor_active == 0); |
669 | + |
670 | + if (! ptr->options.sockaddr_inited || (!(ptr->root->flags.use_cache_lookups))) |
671 | + { |
672 | + memcached_return_t rc; |
673 | + |
674 | + rc= set_hostinfo(ptr); |
675 | + if (rc != MEMCACHED_SUCCESS) |
676 | + return rc; |
677 | + ptr->options.sockaddr_inited= true; |
678 | + } |
679 | + |
680 | + struct addrinfo *use= ptr->address_info; |
681 | + /* Create the socket */ |
682 | + while (use != NULL) |
683 | + { |
684 | + /* Memcache server does not support IPV6 in udp mode, so skip if not ipv4 */ |
685 | + if (ptr->type == MEMCACHED_CONNECTION_UDP && use->ai_family != AF_INET) |
686 | + { |
687 | + use= use->ai_next; |
688 | + continue; |
689 | + } |
690 | + |
691 | + if ((ptr->fd= socket(use->ai_family, |
692 | + use->ai_socktype, |
693 | + use->ai_protocol)) < 0) |
694 | + { |
695 | + ptr->cached_errno= errno; |
696 | + WATCHPOINT_ERRNO(errno); |
697 | + return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE; |
698 | + } |
699 | + |
700 | + (void)set_socket_options(ptr); |
701 | + |
702 | + /* connect to server */ |
703 | + if ((connect(ptr->fd, use->ai_addr, use->ai_addrlen) > -1)) |
704 | + { |
705 | + break; // Success |
706 | + } |
707 | + |
708 | + /* An error occurred */ |
709 | + ptr->cached_errno= errno; |
710 | + if (errno == EINPROGRESS || /* nonblocking mode - first return, */ |
711 | + errno == EALREADY) /* nonblocking mode - subsequent returns */ |
712 | { |
713 | memcached_return_t rc; |
714 | - |
715 | - rc= set_hostinfo(ptr); |
716 | - if (rc != MEMCACHED_SUCCESS) |
717 | - return rc; |
718 | - ptr->options.sockaddr_inited= true; |
719 | - } |
720 | - |
721 | - use= ptr->address_info; |
722 | - /* Create the socket */ |
723 | - while (use != NULL) |
724 | - { |
725 | - /* Memcache server does not support IPV6 in udp mode, so skip if not ipv4 */ |
726 | - if (ptr->type == MEMCACHED_CONNECTION_UDP && use->ai_family != AF_INET) |
727 | - { |
728 | - use= use->ai_next; |
729 | - continue; |
730 | - } |
731 | - |
732 | - if ((ptr->fd= socket(use->ai_family, |
733 | - use->ai_socktype, |
734 | - use->ai_protocol)) < 0) |
735 | - { |
736 | - ptr->cached_errno= errno; |
737 | - WATCHPOINT_ERRNO(errno); |
738 | - return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE; |
739 | - } |
740 | - |
741 | - (void)set_socket_options(ptr); |
742 | - |
743 | - /* connect to server */ |
744 | - if ((connect(ptr->fd, use->ai_addr, use->ai_addrlen) == -1)) |
745 | - { |
746 | - ptr->cached_errno= errno; |
747 | - if (errno == EINPROGRESS || /* nonblocking mode - first return, */ |
748 | - errno == EALREADY) /* nonblocking mode - subsequent returns */ |
749 | - { |
750 | - struct pollfd fds[1]; |
751 | - fds[0].fd = ptr->fd; |
752 | - fds[0].events = POLLOUT; |
753 | - |
754 | - int timeout= ptr->root->connect_timeout; |
755 | - if (ptr->root->flags.no_block == true) |
756 | - timeout= -1; |
757 | - |
758 | - size_t loop_max= 5; |
759 | - while (--loop_max) |
760 | - { |
761 | - int error= poll(fds, 1, timeout); |
762 | - |
763 | - switch (error) |
764 | - { |
765 | - case 1: |
766 | - loop_max= 1; |
767 | - break; |
768 | - case 0: |
769 | - if (loop_max==1) |
770 | - return MEMCACHED_TIMEOUT; |
771 | - continue; |
772 | - // A real error occurred and we need to completely bail |
773 | - default: |
774 | - WATCHPOINT_ERRNO(errno); |
775 | - switch (errno) |
776 | - { |
777 | -#ifdef TARGET_OS_LINUX |
778 | - case ERESTART: |
779 | -#endif |
780 | - case EINTR: |
781 | - continue; |
782 | - default: |
783 | - if (fds[0].revents & POLLERR) |
784 | - { |
785 | - int err; |
786 | - socklen_t len= sizeof (err); |
787 | - (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len); |
788 | - ptr->cached_errno= (err == 0) ? errno : err; |
789 | - } |
790 | - |
791 | - (void)close(ptr->fd); |
792 | - ptr->fd= -1; |
793 | - |
794 | - break; |
795 | - } |
796 | - } |
797 | - } |
798 | - } |
799 | - else if (errno == EISCONN) /* we are connected :-) */ |
800 | - { |
801 | - break; |
802 | - } |
803 | - else if (errno != EINTR) |
804 | - { |
805 | - (void)close(ptr->fd); |
806 | - ptr->fd= -1; |
807 | - break; |
808 | - } |
809 | - } |
810 | - |
811 | -#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT |
812 | - if (ptr->fd != -1 && ptr->root->sasl && ptr->root->sasl->callbacks) |
813 | - { |
814 | - memcached_return rc= memcached_sasl_authenticate_connection(ptr); |
815 | - if (rc != MEMCACHED_SUCCESS) |
816 | - { |
817 | - (void)close(ptr->fd); |
818 | - ptr->fd= -1; |
819 | - |
820 | - return rc; |
821 | - } |
822 | - } |
823 | -#endif |
824 | - |
825 | - |
826 | - if (ptr->fd != -1) |
827 | - { |
828 | - return MEMCACHED_SUCCESS; |
829 | - } |
830 | - use = use->ai_next; |
831 | - } |
832 | + rc= connect_poll(ptr); |
833 | + |
834 | + if (rc == MEMCACHED_TIMEOUT) |
835 | + timeout_error_occured= true; |
836 | + |
837 | + if (rc == MEMCACHED_SUCCESS) |
838 | + break; |
839 | + } |
840 | + else if (errno == EISCONN) /* we are connected :-) */ |
841 | + { |
842 | + break; |
843 | + } |
844 | + else if (errno == EINTR) // Special case, we retry ai_addr |
845 | + { |
846 | + (void)close(ptr->fd); |
847 | + ptr->fd= -1; |
848 | + continue; |
849 | + } |
850 | + |
851 | + (void)close(ptr->fd); |
852 | + ptr->fd= -1; |
853 | + use= use->ai_next; |
854 | } |
855 | |
856 | if (ptr->fd == -1) |
857 | @@ -408,7 +438,7 @@ |
858 | ptr->next_retry= next_time.tv_sec + ptr->root->retry_timeout; |
859 | } |
860 | |
861 | - if (ptr->cached_errno == 0) |
862 | + if (timeout_error_occured) |
863 | return MEMCACHED_TIMEOUT; |
864 | |
865 | return MEMCACHED_ERRNO; /* The last error should be from connect() */ |
866 | @@ -435,6 +465,10 @@ |
867 | memcached_return_t memcached_connect(memcached_server_write_instance_st ptr) |
868 | { |
869 | memcached_return_t rc= MEMCACHED_NO_SERVERS; |
870 | + |
871 | + if (ptr->fd > -1) |
872 | + return MEMCACHED_SUCCESS; |
873 | + |
874 | LIBMEMCACHED_MEMCACHED_CONNECT_START(); |
875 | |
876 | /* both retry_timeout and server_failure_limit must be set in order to delay retrying a server on error. */ |
877 | @@ -481,6 +515,17 @@ |
878 | case MEMCACHED_CONNECTION_UDP: |
879 | case MEMCACHED_CONNECTION_TCP: |
880 | rc= network_connect(ptr); |
881 | +#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT |
882 | + if (ptr->fd != -1 && ptr->root->sasl && ptr->root->sasl->callbacks) |
883 | + { |
884 | + rc= memcached_sasl_authenticate_connection(ptr); |
885 | + if (rc != MEMCACHED_SUCCESS) |
886 | + { |
887 | + (void)close(ptr->fd); |
888 | + ptr->fd= -1; |
889 | + } |
890 | + } |
891 | +#endif |
892 | break; |
893 | case MEMCACHED_CONNECTION_UNIX_SOCKET: |
894 | rc= unix_socket_connect(ptr); |
895 | |
896 | === modified file 'libmemcached/delete.c' |
897 | --- libmemcached/delete.c 2010-04-02 19:55:21 +0000 |
898 | +++ libmemcached/delete.c 2010-07-21 16:27:47 +0000 |
899 | @@ -45,7 +45,7 @@ |
900 | |
901 | if (ptr->flags.binary_protocol) |
902 | { |
903 | - likely (!expiration) |
904 | + likely (! expiration) |
905 | { |
906 | rc= binary_delete(ptr, server_key, key, key_length, to_write); |
907 | } |
908 | |
909 | === modified file 'libmemcached/include.am' |
910 | --- libmemcached/include.am 2010-06-15 06:31:25 +0000 |
911 | +++ libmemcached/include.am 2010-07-21 16:27:47 +0000 |
912 | @@ -65,7 +65,7 @@ |
913 | libmemcached/protocol/pedantic.c \ |
914 | libmemcached/protocol/protocol_handler.c |
915 | |
916 | -libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS} -version-info 0:0:0 |
917 | +libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_PROTOCAL_LIBRARY_VERSION} |
918 | |
919 | noinst_LTLIBRARIES+= \ |
920 | libmemcached/libmemcachedcallbacks.la |
921 | @@ -133,7 +133,7 @@ |
922 | libmemcached/util/pool.c \ |
923 | libmemcached/util/version.c |
924 | libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la |
925 | -libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info 0:0:0 |
926 | +libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION} |
927 | libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la |
928 | |
929 | if BUILD_BYTEORDER |
930 | @@ -158,6 +158,7 @@ |
931 | if DTRACE_NEEDS_OBJECTS |
932 | libmemcached_libmemcached_la_SOURCES += libmemcached/libmemcached_probes.d |
933 | libmemcached_libmemcached_la_DEPENDENCIES += libmemcached/libmemcached_probes.o |
934 | +CLEANFILES+= libmemcached/libmemcached_probes.o |
935 | endif |
936 | |
937 | SUFFIXES+= .d |
938 | @@ -165,7 +166,7 @@ |
939 | libmemcached/dtrace_probes.h: libmemcached/libmemcached_probes.d |
940 | $(DTRACE) $(DTRACEFLAGS) -h -o libmemcached/dtrace_probes.h -s ${top_srcdir}/libmemcached/libmemcached_probes.d |
941 | |
942 | -libmemcached/libmemcached_probes.o: libmemcached/libmemcached_probes.d ${libmemcached_libmemcached_OBJECTS} config.h |
943 | +libmemcached/libmemcached_probes.o: libmemcached/libmemcached_probes.d ${libmemcached_libmemcached_la_OBJECTS} config.h |
944 | |
945 | .d.o: |
946 | $(DTRACE) $(DTRACEFLAGS) -o libmemcached/libmemcached_probes.o -G -s ${top_srcdir}/libmemcached/libmemcached_probes.d `grep '^pic_object' ${top_builddir}/libmemcached/*.lo | cut -f 2 -d\' | sed "s/^/${top_builddir}\//"` |
947 | |
948 | === modified file 'libmemcached/io.c' |
949 | --- libmemcached/io.c 2010-04-22 22:51:37 +0000 |
950 | +++ libmemcached/io.c 2010-07-21 16:27:47 +0000 |
951 | @@ -62,45 +62,50 @@ |
952 | timeout= -1; |
953 | |
954 | size_t loop_max= 5; |
955 | - while (--loop_max) |
956 | + while (--loop_max) // While loop is for ERESTART or EINTR |
957 | { |
958 | error= poll(&fds, 1, timeout); |
959 | |
960 | switch (error) |
961 | { |
962 | - case 1: |
963 | + case 1: // Success! |
964 | WATCHPOINT_IF_LABELED_NUMBER(read_or_write && loop_max < 4, "read() times we had to loop, decremented down from 5", loop_max); |
965 | WATCHPOINT_IF_LABELED_NUMBER(!read_or_write && loop_max < 4, "write() times we had to loop, decremented down from 5", loop_max); |
966 | |
967 | return MEMCACHED_SUCCESS; |
968 | - case 0: |
969 | + case 0: // Timeout occured, we let the while() loop do its thing. |
970 | return MEMCACHED_TIMEOUT; |
971 | default: |
972 | WATCHPOINT_ERRNO(errno); |
973 | + switch (errno) |
974 | { |
975 | - switch (errno) |
976 | - { |
977 | #ifdef TARGET_OS_LINUX |
978 | - case ERESTART: |
979 | + case ERESTART: |
980 | #endif |
981 | - case EINTR: |
982 | - continue; |
983 | - default: |
984 | - ptr->cached_errno= error; |
985 | - memcached_quit_server(ptr, true); |
986 | + case EINTR: |
987 | + break; |
988 | + default: |
989 | + if (fds.revents & POLLERR) |
990 | + { |
991 | + int err; |
992 | + socklen_t len= sizeof (err); |
993 | + (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len); |
994 | + ptr->cached_errno= (err == 0) ? errno : err; |
995 | + } |
996 | + else |
997 | + { |
998 | + ptr->cached_errno= errno; |
999 | + } |
1000 | + memcached_quit_server(ptr, true); |
1001 | |
1002 | - return MEMCACHED_FAILURE; |
1003 | - } |
1004 | + return MEMCACHED_FAILURE; |
1005 | } |
1006 | } |
1007 | } |
1008 | |
1009 | - if (loop_max == 0 && error == 0) |
1010 | - return MEMCACHED_TIMEOUT; |
1011 | - |
1012 | /* Imposssible for anything other then -1 */ |
1013 | WATCHPOINT_ASSERT(error == -1); |
1014 | - ptr->cached_errno= error; |
1015 | + ptr->cached_errno= errno; |
1016 | memcached_quit_server(ptr, true); |
1017 | |
1018 | return MEMCACHED_FAILURE; |
1019 | |
1020 | === modified file 'libmemcached/response.c' |
1021 | --- libmemcached/response.c 2010-04-22 22:51:37 +0000 |
1022 | +++ libmemcached/response.c 2010-07-21 16:27:47 +0000 |
1023 | @@ -61,6 +61,7 @@ |
1024 | * compatibility. |
1025 | */ |
1026 | if (ptr->root->flags.binary_protocol == false) |
1027 | + { |
1028 | while (memcached_server_response_count(ptr) > 1) |
1029 | { |
1030 | memcached_return_t rc= memcached_read_one_response(ptr, buffer, buffer_length, result); |
1031 | @@ -75,6 +76,7 @@ |
1032 | rc != MEMCACHED_DATA_EXISTS) |
1033 | return rc; |
1034 | } |
1035 | + } |
1036 | |
1037 | return memcached_read_one_response(ptr, buffer, buffer_length, result); |
1038 | } |
1039 | |
1040 | === modified file 'libmemcached/server.c' |
1041 | --- libmemcached/server.c 2010-04-22 00:49:09 +0000 |
1042 | +++ libmemcached/server.c 2010-07-21 16:27:47 +0000 |
1043 | @@ -172,6 +172,26 @@ |
1044 | return MEMCACHED_SUCCESS; |
1045 | } |
1046 | |
1047 | +memcached_return_t memcached_server_execute(memcached_st *ptr, |
1048 | + memcached_server_execute_fn callback, |
1049 | + void *context) |
1050 | +{ |
1051 | + for (uint32_t x= 0; x < memcached_server_count(ptr); x++) |
1052 | + { |
1053 | + memcached_server_write_instance_st instance= |
1054 | + memcached_server_instance_fetch(ptr, x); |
1055 | + |
1056 | + unsigned int iferror; |
1057 | + |
1058 | + iferror= (*callback)(ptr, instance, context); |
1059 | + |
1060 | + if (iferror) |
1061 | + continue; |
1062 | + } |
1063 | + |
1064 | + return MEMCACHED_SUCCESS; |
1065 | +} |
1066 | + |
1067 | memcached_server_instance_st memcached_server_by_key(const memcached_st *ptr, |
1068 | const char *key, |
1069 | size_t key_length, |
1070 | |
1071 | === modified file 'libmemcached/stats.c' |
1072 | --- libmemcached/stats.c 2010-04-02 19:55:21 +0000 |
1073 | +++ libmemcached/stats.c 2010-07-21 16:27:47 +0000 |
1074 | @@ -29,6 +29,13 @@ |
1075 | NULL |
1076 | }; |
1077 | |
1078 | +struct local_context |
1079 | +{ |
1080 | + memcached_stat_fn func; |
1081 | + void *context; |
1082 | + const char *args; |
1083 | +}; |
1084 | + |
1085 | |
1086 | static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char *value) |
1087 | { |
1088 | @@ -228,8 +235,9 @@ |
1089 | } |
1090 | |
1091 | static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, |
1092 | - char *args, |
1093 | - memcached_server_write_instance_st instance) |
1094 | + const char *args, |
1095 | + memcached_server_write_instance_st instance, |
1096 | + struct local_context *check) |
1097 | { |
1098 | memcached_return_t rc; |
1099 | |
1100 | @@ -286,10 +294,23 @@ |
1101 | return rc; |
1102 | } |
1103 | |
1104 | - unlikely((set_data(memc_stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY) |
1105 | - { |
1106 | - WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); |
1107 | - WATCHPOINT_ASSERT(0); |
1108 | + if (memc_stat) |
1109 | + { |
1110 | + unlikely((set_data(memc_stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY) |
1111 | + { |
1112 | + WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); |
1113 | + WATCHPOINT_ASSERT(0); |
1114 | + } |
1115 | + } |
1116 | + |
1117 | + if (check && check->func) |
1118 | + { |
1119 | + size_t key_length= strlen(buffer); |
1120 | + |
1121 | + check->func(instance, |
1122 | + buffer, key_length, |
1123 | + buffer+key_length+1, strlen(buffer+key_length+1), |
1124 | + check->context); |
1125 | } |
1126 | } while (1); |
1127 | |
1128 | @@ -302,8 +323,9 @@ |
1129 | } |
1130 | |
1131 | static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat, |
1132 | - char *args, |
1133 | - memcached_server_write_instance_st instance) |
1134 | + const char *args, |
1135 | + memcached_server_write_instance_st instance, |
1136 | + struct local_context *check) |
1137 | { |
1138 | memcached_return_t rc; |
1139 | char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; |
1140 | @@ -343,10 +365,21 @@ |
1141 | value= string_ptr; |
1142 | value[(size_t)(end_ptr-string_ptr)]= 0; |
1143 | string_ptr= end_ptr + 2; |
1144 | - unlikely((set_data(memc_stat, key, value)) == MEMCACHED_UNKNOWN_STAT_KEY) |
1145 | - { |
1146 | - WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); |
1147 | - WATCHPOINT_ASSERT(0); |
1148 | + if (memc_stat) |
1149 | + { |
1150 | + unlikely((set_data(memc_stat, key, value)) == MEMCACHED_UNKNOWN_STAT_KEY) |
1151 | + { |
1152 | + WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); |
1153 | + WATCHPOINT_ASSERT(0); |
1154 | + } |
1155 | + } |
1156 | + |
1157 | + if (check && check->func) |
1158 | + { |
1159 | + check->func(instance, |
1160 | + key, strlen(key), |
1161 | + value, strlen(value), |
1162 | + check->context); |
1163 | } |
1164 | } |
1165 | else |
1166 | @@ -394,11 +427,11 @@ |
1167 | |
1168 | if (ptr->flags.binary_protocol) |
1169 | { |
1170 | - temp_return= binary_stats_fetch(stat_instance, args, instance); |
1171 | + temp_return= binary_stats_fetch(stat_instance, args, instance, NULL); |
1172 | } |
1173 | else |
1174 | { |
1175 | - temp_return= ascii_stats_fetch(stat_instance, args, instance); |
1176 | + temp_return= ascii_stats_fetch(stat_instance, args, instance, NULL); |
1177 | } |
1178 | |
1179 | if (temp_return != MEMCACHED_SUCCESS) |
1180 | @@ -428,11 +461,11 @@ |
1181 | |
1182 | if (memc.flags.binary_protocol) |
1183 | { |
1184 | - rc= binary_stats_fetch(memc_stat, args, instance); |
1185 | + rc= binary_stats_fetch(memc_stat, args, instance, NULL); |
1186 | } |
1187 | else |
1188 | { |
1189 | - rc= ascii_stats_fetch(memc_stat, args, instance); |
1190 | + rc= ascii_stats_fetch(memc_stat, args, instance, NULL); |
1191 | } |
1192 | |
1193 | memcached_free(&memc); |
1194 | @@ -489,3 +522,31 @@ |
1195 | free(memc_stat); |
1196 | } |
1197 | } |
1198 | + |
1199 | +static memcached_return_t call_stat_fn(memcached_st *ptr, |
1200 | + memcached_server_write_instance_st instance, |
1201 | + void *context) |
1202 | +{ |
1203 | + memcached_return_t rc; |
1204 | + struct local_context *check= (struct local_context *)context; |
1205 | + |
1206 | + if (ptr->flags.binary_protocol) |
1207 | + { |
1208 | + rc= binary_stats_fetch(NULL, check->args, instance, check); |
1209 | + } |
1210 | + else |
1211 | + { |
1212 | + rc= ascii_stats_fetch(NULL, check->args, instance, check); |
1213 | + } |
1214 | + |
1215 | + return rc; |
1216 | +} |
1217 | + |
1218 | +memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context) |
1219 | +{ |
1220 | + memcached_version(memc); |
1221 | + |
1222 | + struct local_context check= { .func= func, .context= context, .args= args }; |
1223 | + |
1224 | + return memcached_server_execute(memc, call_stat_fn, (void *)&check); |
1225 | +} |
1226 | |
1227 | === modified file 'libmemcached/stats.h' |
1228 | --- libmemcached/stats.h 2010-02-17 01:58:35 +0000 |
1229 | +++ libmemcached/stats.h 2010-07-21 16:27:47 +0000 |
1230 | @@ -62,6 +62,9 @@ |
1231 | char ** memcached_stat_get_keys(const memcached_st *ptr, memcached_stat_st *memc_stat, |
1232 | memcached_return_t *error); |
1233 | |
1234 | +LIBMEMCACHED_API |
1235 | +memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context); |
1236 | + |
1237 | #ifdef __cplusplus |
1238 | } // extern "C" |
1239 | #endif |
1240 | |
1241 | === modified file 'libmemcached/types.h' |
1242 | --- libmemcached/types.h 2010-02-17 01:58:35 +0000 |
1243 | +++ libmemcached/types.h 2010-07-21 16:27:47 +0000 |
1244 | @@ -47,6 +47,10 @@ |
1245 | |
1246 | typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context); |
1247 | typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context); |
1248 | +typedef memcached_return_t (*memcached_stat_fn)(memcached_server_instance_st server, |
1249 | + const char *key, size_t key_length, |
1250 | + const char *value, size_t value_length, |
1251 | + void *context); |
1252 | |
1253 | /** |
1254 | Trigger functions. |
1255 | |
1256 | === modified file 'libmemcached/util/version.c' |
1257 | --- libmemcached/util/version.c 2010-06-15 06:31:25 +0000 |
1258 | +++ libmemcached/util/version.c 2010-07-21 16:27:47 +0000 |
1259 | @@ -16,8 +16,8 @@ |
1260 | struct local_context |
1261 | { |
1262 | uint8_t major_version; |
1263 | + uint8_t minor_version; |
1264 | uint8_t micro_version; |
1265 | - uint8_t minor_version; |
1266 | |
1267 | bool truth; |
1268 | }; |
1269 | @@ -30,8 +30,8 @@ |
1270 | struct local_context *check= (struct local_context *)context; |
1271 | |
1272 | if (instance->major_version >= check->major_version && |
1273 | - instance->micro_version >= check->micro_version && |
1274 | - instance->minor_version >= check->minor_version) |
1275 | + instance->minor_version >= check->minor_version && |
1276 | + instance->micro_version >= check->micro_version ) |
1277 | { |
1278 | return MEMCACHED_SUCCESS; |
1279 | } |
1280 | @@ -43,13 +43,14 @@ |
1281 | |
1282 | bool libmemcached_util_version_check(memcached_st *memc, |
1283 | uint8_t major_version, |
1284 | - uint8_t micro_version, |
1285 | - uint8_t minor_version) |
1286 | + uint8_t minor_version, |
1287 | + uint8_t micro_version) |
1288 | { |
1289 | memcached_server_fn callbacks[1]; |
1290 | memcached_version(memc); |
1291 | |
1292 | - struct local_context check= { .major_version= major_version, .micro_version= micro_version, .minor_version= minor_version, .truth= true }; |
1293 | + struct local_context check= { .major_version= major_version, .minor_version= minor_version, .micro_version= micro_version, .truth= true }; |
1294 | + memcached_version(memc); |
1295 | |
1296 | callbacks[0]= check_server_version; |
1297 | memcached_server_cursor(memc, callbacks, (void *)&check, 1); |
1298 | |
1299 | === modified file 'libmemcached/util/version.h' |
1300 | --- libmemcached/util/version.h 2010-06-15 06:31:25 +0000 |
1301 | +++ libmemcached/util/version.h 2010-07-21 16:27:47 +0000 |
1302 | @@ -19,8 +19,8 @@ |
1303 | LIBMEMCACHED_API |
1304 | bool libmemcached_util_version_check(memcached_st *memc, |
1305 | uint8_t major_version, |
1306 | - uint8_t micro_version, |
1307 | - uint8_t minor_version); |
1308 | + uint8_t minor_version, |
1309 | + uint8_t micro_version); |
1310 | |
1311 | #ifdef __cplusplus |
1312 | } |
1313 | |
1314 | === modified file 'libmemcached/version.c' |
1315 | --- libmemcached/version.c 2010-04-02 19:55:21 +0000 |
1316 | +++ libmemcached/version.c 2010-07-21 16:27:47 +0000 |
1317 | @@ -13,10 +13,19 @@ |
1318 | if (ptr->flags.use_udp) |
1319 | return MEMCACHED_NOT_SUPPORTED; |
1320 | |
1321 | + bool was_blocking= ptr->flags.no_block; |
1322 | + memcached_return_t rc; |
1323 | + |
1324 | + ptr->flags.no_block= false; |
1325 | + |
1326 | if (ptr->flags.binary_protocol) |
1327 | - return memcached_version_binary(ptr); |
1328 | + rc= memcached_version_binary(ptr); |
1329 | else |
1330 | - return memcached_version_textual(ptr); |
1331 | + rc= memcached_version_textual(ptr); |
1332 | + |
1333 | + ptr->flags.no_block= was_blocking; |
1334 | + |
1335 | + return rc; |
1336 | } |
1337 | |
1338 | static inline memcached_return_t memcached_version_textual(memcached_st *ptr) |
1339 | |
1340 | === modified file 'm4/pandora_warnings.m4' |
1341 | --- m4/pandora_warnings.m4 2010-06-13 16:24:20 +0000 |
1342 | +++ m4/pandora_warnings.m4 2010-07-21 16:27:47 +0000 |
1343 | @@ -145,7 +145,7 @@ |
1344 | m4_if(PW_LESS_WARNINGS,[no],[ |
1345 | BASE_WARNINGS_FULL="-Wformat=2 ${W_CONVERSION} -Wstrict-aliasing" |
1346 | CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings" |
1347 | - CXX_WARNINGS_FULL="-Weffc++ -Wold-style-cast" |
1348 | + CXX_WARNINGS_FULL="-Wold-style-cast" |
1349 | NO_OLD_STYLE_CAST="-Wno-old-style-cast" |
1350 | NO_EFF_CXX="-Wno-effc++" |
1351 | ],[ |
1352 | |
1353 | === modified file 'support/libmemcached.spec.in' |
1354 | --- support/libmemcached.spec.in 2010-04-05 16:41:24 +0000 |
1355 | +++ support/libmemcached.spec.in 2010-07-21 16:27:47 +0000 |
1356 | @@ -82,10 +82,14 @@ |
1357 | %exclude %{_libdir}/libhashkit.la |
1358 | %exclude %{_libdir}/libmemcachedutil.la |
1359 | %exclude %{_libdir}/libmemcachedprotocol.la |
1360 | -%{_libdir}/libhashkit.so.* |
1361 | -%{_libdir}/libmemcached.so.* |
1362 | -%{_libdir}/libmemcachedutil.so.* |
1363 | -%{_libdir}/libmemcachedprotocol.so.* |
1364 | +%{_libdir}/libhashkit.so.0.0.0 |
1365 | +%{_libdir}/libmemcached.so.5.0.1 |
1366 | +%{_libdir}/libmemcachedutil.so.1.0.0 |
1367 | +%{_libdir}/libmemcachedprotocol.so.0.0.0 |
1368 | +%{_libdir}/libhashkit.so.0 |
1369 | +%{_libdir}/libmemcached.so.5 |
1370 | +%{_libdir}/libmemcachedprotocol.so.0 |
1371 | +%{_libdir}/libmemcachedutil.so.1 |
1372 | %{_mandir}/man1/memcapable.1.gz |
1373 | %{_mandir}/man1/memcat.1.gz |
1374 | %{_mandir}/man1/memcp.1.gz |
1375 | @@ -104,14 +108,6 @@ |
1376 | %{_includedir}/libmemcached/delete.h |
1377 | %{_includedir}/libmemcached/fetch.h |
1378 | %{_includedir}/libmemcached/flush.h |
1379 | -%{_includedir}/libmemcached/flush_buffers.h |
1380 | -%{_includedir}/libmemcached/hash.h |
1381 | -%{_includedir}/libmemcached/parse.h |
1382 | -%{_includedir}/libmemcached/quit.h |
1383 | -%{_includedir}/libmemcached/sasl.h |
1384 | -%{_includedir}/libmemcached/strerror.h |
1385 | -%{_includedir}/libmemcached/verbosity.h |
1386 | -%{_includedir}/libmemcached/version.h |
1387 | %{_includedir}/libhashkit/algorithm.h |
1388 | %{_includedir}/libhashkit/behavior.h |
1389 | %{_includedir}/libhashkit/configure.h |
1390 | @@ -129,21 +125,32 @@ |
1391 | %{_includedir}/libmemcached/constants.h |
1392 | %{_includedir}/libmemcached/dump.h |
1393 | %{_includedir}/libmemcached/exception.hpp |
1394 | +%{_includedir}/libmemcached/flush_buffers.h |
1395 | %{_includedir}/libmemcached/get.h |
1396 | +%{_includedir}/libmemcached/hash.h |
1397 | %{_includedir}/libmemcached/memcached.h |
1398 | %{_includedir}/libmemcached/memcached.hpp |
1399 | %{_includedir}/libmemcached/memcached_util.h |
1400 | +%{_includedir}/libmemcached/parse.h |
1401 | %{_includedir}/libmemcached/protocol/cache.h |
1402 | %{_includedir}/libmemcached/protocol/callback.h |
1403 | %{_includedir}/libmemcached/protocol_handler.h |
1404 | +%{_includedir}/libmemcached/quit.h |
1405 | %{_includedir}/libmemcached/result.h |
1406 | +%{_includedir}/libmemcached/sasl.h |
1407 | %{_includedir}/libmemcached/server.h |
1408 | %{_includedir}/libmemcached/server_list.h |
1409 | %{_includedir}/libmemcached/stats.h |
1410 | %{_includedir}/libmemcached/storage.h |
1411 | +%{_includedir}/libmemcached/strerror.h |
1412 | %{_includedir}/libmemcached/string.h |
1413 | %{_includedir}/libmemcached/types.h |
1414 | +%{_includedir}/libmemcached/util.h |
1415 | +%{_includedir}/libmemcached/util/ping.h |
1416 | %{_includedir}/libmemcached/util/pool.h |
1417 | +%{_includedir}/libmemcached/util/version.h |
1418 | +%{_includedir}/libmemcached/verbosity.h |
1419 | +%{_includedir}/libmemcached/version.h |
1420 | %{_includedir}/libmemcached/visibility.h |
1421 | %{_includedir}/libmemcached/watchpoint.h |
1422 | %{_includedir}/libmemcached/memcached/protocol_binary.h |
1423 | @@ -187,6 +194,7 @@ |
1424 | %{_mandir}/man3/memcached_decrement_with_initial.3.gz |
1425 | %{_mandir}/man3/memcached_delete.3.gz |
1426 | %{_mandir}/man3/memcached_delete_by_key.3.gz |
1427 | +%{_mandir}/man3/memcached_destroy_sasl_auth_data.3.gz |
1428 | %{_mandir}/man3/memcached_dump.3.gz |
1429 | %{_mandir}/man3/memcached_fetch.3.gz |
1430 | %{_mandir}/man3/memcached_fetch_execute.3.gz |
1431 | @@ -197,6 +205,7 @@ |
1432 | %{_mandir}/man3/memcached_get.3.gz |
1433 | %{_mandir}/man3/memcached_get_by_key.3.gz |
1434 | %{_mandir}/man3/memcached_get_memory_allocators.3.gz |
1435 | +%{_mandir}/man3/memcached_get_sasl_callbacks.3.gz |
1436 | %{_mandir}/man3/memcached_get_user_data.3.gz |
1437 | %{_mandir}/man3/memcached_increment.3.gz |
1438 | %{_mandir}/man3/memcached_increment_with_initial.3.gz |
1439 | @@ -216,6 +225,7 @@ |
1440 | %{_mandir}/man3/memcached_quit.3.gz |
1441 | %{_mandir}/man3/memcached_replace.3.gz |
1442 | %{_mandir}/man3/memcached_replace_by_key.3.gz |
1443 | +%{_mandir}/man3/memcached_sasl_set_auth_data.3.gz |
1444 | %{_mandir}/man3/memcached_server_add.3.gz |
1445 | %{_mandir}/man3/memcached_server_count.3.gz |
1446 | %{_mandir}/man3/memcached_server_cursor.3.gz |
1447 | @@ -228,6 +238,7 @@ |
1448 | %{_mandir}/man3/memcached_set.3.gz |
1449 | %{_mandir}/man3/memcached_set_by_key.3.gz |
1450 | %{_mandir}/man3/memcached_set_memory_allocators.3.gz |
1451 | +%{_mandir}/man3/memcached_set_sasl_callbacks.3.gz |
1452 | %{_mandir}/man3/memcached_set_user_data.3.gz |
1453 | %{_mandir}/man3/memcached_stat.3.gz |
1454 | %{_mandir}/man3/memcached_stat_get_keys.3.gz |
1455 | |
1456 | === modified file 'tests/atomsmasher.c' |
1457 | --- tests/atomsmasher.c 2010-01-15 21:49:15 +0000 |
1458 | +++ tests/atomsmasher.c 2010-07-21 16:27:47 +0000 |
1459 | @@ -12,10 +12,14 @@ |
1460 | /* |
1461 | Sample test application. |
1462 | */ |
1463 | -#include "libmemcached/common.h" |
1464 | +#include "config.h" |
1465 | + |
1466 | +#include "libmemcached/memcached.h" |
1467 | +#include "libmemcached/watchpoint.h" |
1468 | |
1469 | #include <stdio.h> |
1470 | #include <stdlib.h> |
1471 | +#include <stdint.h> |
1472 | #include <string.h> |
1473 | #include <sys/time.h> |
1474 | #include <sys/types.h> |
1475 | @@ -26,14 +30,6 @@ |
1476 | #include "../clients/generator.h" |
1477 | #include "../clients/execute.h" |
1478 | |
1479 | -#ifndef INT64_MAX |
1480 | -#define INT64_MAX LONG_MAX |
1481 | -#endif |
1482 | -#ifndef INT32_MAX |
1483 | -#define INT32_MAX INT_MAX |
1484 | -#endif |
1485 | - |
1486 | - |
1487 | #include "test.h" |
1488 | |
1489 | /* Number of items generated for tests */ |
1490 | |
1491 | === modified file 'tests/hashkit_functions.c' |
1492 | --- tests/hashkit_functions.c 2010-04-11 17:56:46 +0000 |
1493 | +++ tests/hashkit_functions.c 2010-07-21 16:27:47 +0000 |
1494 | @@ -6,6 +6,8 @@ |
1495 | * the COPYING file in the parent directory for full text. |
1496 | */ |
1497 | |
1498 | +#include "config.h" |
1499 | + |
1500 | #include <assert.h> |
1501 | #include <stdio.h> |
1502 | #include <stdlib.h> |
1503 | |
1504 | === modified file 'tests/include.am' |
1505 | --- tests/include.am 2010-06-13 16:43:30 +0000 |
1506 | +++ tests/include.am 2010-07-21 16:27:47 +0000 |
1507 | @@ -4,7 +4,7 @@ |
1508 | |
1509 | TESTS_LDADDS = libmemcached/libmemcached.la |
1510 | |
1511 | -VALGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --leak-check=yes --show-reachable=yes |
1512 | +VALGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --leak-check=yes --show-reachable=yes --track-fds=yes |
1513 | |
1514 | DEBUG_COMMAND= $(LIBTOOL) --mode=execute gdb |
1515 | |
1516 | @@ -41,6 +41,7 @@ |
1517 | tests_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) |
1518 | tests_testapp_SOURCES= tests/mem_functions.c |
1519 | tests_testapp_DEPENDENCIES= \ |
1520 | + $(BUILT_SOURCES) \ |
1521 | clients/libgenexec.la \ |
1522 | tests/libserver.la \ |
1523 | tests/libtest.la \ |
1524 | @@ -86,12 +87,14 @@ |
1525 | tests_memplus_SOURCES = tests/mem_plus.cc |
1526 | tests_memplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX) |
1527 | tests_memplus_DEPENDENCIES = tests/libtest.la tests/libserver.la libmemcached/libmemcached.la |
1528 | -tests_memplus_LDADD = $(tests_memplus_DEPENDENCIES) |
1529 | - |
1530 | -test: test-docs test-mem test-hash memcapable |
1531 | +tests_memplus_LDADD = $(tests_memplus_DEPENDENCIES) $(LIBSASL) |
1532 | + |
1533 | +test: check |
1534 | + |
1535 | +check-local: $(TEST_DOCS) test-mem test-hash memcapable |
1536 | echo "Tests completed" |
1537 | |
1538 | -test-x: test-docs test-plus test-mem test-hash memcapable test-memcat test-memcp test-memrm test-memerror test-memdump test-memflush test-memstat |
1539 | +test-x: check-local test-plus test-memcat test-memcp test-memrm test-memerror test-memdump test-memflush test-memstat |
1540 | echo "Tests completed" |
1541 | |
1542 | memcapable: clients/memcapable |
1543 | |
1544 | === modified file 'tests/mem_functions.c' |
1545 | --- tests/mem_functions.c 2010-06-15 06:31:25 +0000 |
1546 | +++ tests/mem_functions.c 2010-07-21 16:27:47 +0000 |
1547 | @@ -10,10 +10,11 @@ |
1548 | Sample test application. |
1549 | */ |
1550 | |
1551 | -#include "libmemcached/common.h" |
1552 | +#include "config.h" |
1553 | |
1554 | #include <assert.h> |
1555 | #include <stdio.h> |
1556 | +#include <stdint.h> |
1557 | #include <stdlib.h> |
1558 | #include <string.h> |
1559 | #include <sys/time.h> |
1560 | @@ -22,20 +23,18 @@ |
1561 | #include <signal.h> |
1562 | #include <unistd.h> |
1563 | #include <time.h> |
1564 | + |
1565 | +#include "libmemcached/common.h" |
1566 | + |
1567 | #include "server.h" |
1568 | #include "clients/generator.h" |
1569 | #include "clients/execute.h" |
1570 | |
1571 | -#ifndef INT64_MAX |
1572 | -#define INT64_MAX LONG_MAX |
1573 | -#endif |
1574 | -#ifndef INT32_MAX |
1575 | -#define INT32_MAX INT_MAX |
1576 | -#endif |
1577 | - |
1578 | +#define SMALL_STRING_LEN 1024 |
1579 | |
1580 | #include "test.h" |
1581 | |
1582 | + |
1583 | #ifdef HAVE_LIBMEMCACHEDUTIL |
1584 | #include <pthread.h> |
1585 | #include "libmemcached/memcached_util.h" |
1586 | @@ -682,7 +681,6 @@ |
1587 | */ |
1588 | static test_return_t add_wrapper(memcached_st *memc) |
1589 | { |
1590 | - unsigned int x; |
1591 | unsigned int max= 10000; |
1592 | #ifdef __sun |
1593 | max= 10; |
1594 | @@ -691,7 +689,7 @@ |
1595 | max= 10; |
1596 | #endif |
1597 | |
1598 | - for (x= 0; x < max; x++) |
1599 | + for (uint32_t x= 0; x < max; x++) |
1600 | add_test(memc); |
1601 | |
1602 | return TEST_SUCCESS; |
1603 | @@ -3599,7 +3597,7 @@ |
1604 | // will not toggle protocol on an connection. |
1605 | memcached_version(memc_clone); |
1606 | |
1607 | - if (libmemcached_util_version_check(memc_clone, 1, 2, 0)) |
1608 | + if (libmemcached_util_version_check(memc_clone, 1, 3, 0)) |
1609 | { |
1610 | memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); |
1611 | rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1); |
1612 | @@ -3724,23 +3722,14 @@ |
1613 | static test_return_t pre_binary(memcached_st *memc) |
1614 | { |
1615 | memcached_return_t rc= MEMCACHED_FAILURE; |
1616 | - memcached_st *memc_clone; |
1617 | - |
1618 | - memc_clone= memcached_clone(NULL, memc); |
1619 | - test_true(memc_clone); |
1620 | - // The memcached_version needs to be done on a clone, because the server |
1621 | - // will not toggle protocol on an connection. |
1622 | - memcached_version(memc_clone); |
1623 | - |
1624 | - if (libmemcached_util_version_check(memc_clone, 1, 2, 0)) |
1625 | + |
1626 | + if (libmemcached_util_version_check(memc, 1, 3, 0)) |
1627 | { |
1628 | rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1); |
1629 | test_true(rc == MEMCACHED_SUCCESS); |
1630 | test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1); |
1631 | } |
1632 | |
1633 | - memcached_free(memc_clone); |
1634 | - |
1635 | return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED; |
1636 | } |
1637 | |
1638 | @@ -4432,24 +4421,24 @@ |
1639 | memcached_version(memc); |
1640 | |
1641 | // We only use one binary when we test, so this should be just fine. |
1642 | - if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->micro_version, instance->minor_version); |
1643 | - test_true(if_successful == true); |
1644 | - |
1645 | - if (instance->minor_version > 0) |
1646 | - if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->micro_version, instance->minor_version -1); |
1647 | - else if (instance->micro_version > 0) |
1648 | - if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->micro_version - 1, instance->minor_version); |
1649 | - else if (instance->major_version > 0) |
1650 | - if_successful= libmemcached_util_version_check(memc, instance->major_version -1, instance->micro_version, instance->minor_version); |
1651 | - |
1652 | - test_true(if_successful == true); |
1653 | - |
1654 | - if (instance->minor_version > 0) |
1655 | - if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->micro_version, instance->minor_version +1); |
1656 | - else if (instance->micro_version > 0) |
1657 | - if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->micro_version +1, instance->minor_version); |
1658 | - else if (instance->major_version > 0) |
1659 | - if_successful= libmemcached_util_version_check(memc, instance->major_version +1, instance->micro_version, instance->minor_version); |
1660 | + if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->minor_version, instance->micro_version); |
1661 | + test_true(if_successful == true); |
1662 | + |
1663 | + if (instance->micro_version > 0) |
1664 | + if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->minor_version, (uint8_t)(instance->micro_version -1)); |
1665 | + else if (instance->minor_version > 0) |
1666 | + if_successful= libmemcached_util_version_check(memc, instance->major_version, (uint8_t)(instance->minor_version - 1), instance->micro_version); |
1667 | + else if (instance->major_version > 0) |
1668 | + if_successful= libmemcached_util_version_check(memc, (uint8_t)(instance->major_version -1), instance->minor_version, instance->micro_version); |
1669 | + |
1670 | + test_true(if_successful == true); |
1671 | + |
1672 | + if (instance->micro_version > 0) |
1673 | + if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->minor_version, (uint8_t)(instance->micro_version +1)); |
1674 | + else if (instance->minor_version > 0) |
1675 | + if_successful= libmemcached_util_version_check(memc, instance->major_version, (uint8_t)(instance->minor_version +1), instance->micro_version); |
1676 | + else if (instance->major_version > 0) |
1677 | + if_successful= libmemcached_util_version_check(memc, (uint8_t)(instance->major_version +1), instance->minor_version, instance->micro_version); |
1678 | |
1679 | test_true(if_successful == false); |
1680 | |
1681 | @@ -5018,7 +5007,7 @@ |
1682 | We are testing the error condition when we connect to a server via memcached_get() |
1683 | but find that the server is not available. |
1684 | */ |
1685 | -static test_return_t memcached_get_MEMCACHED_SOME_ERRORS(memcached_st *memc) |
1686 | +static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *memc) |
1687 | { |
1688 | (void)memc; |
1689 | memcached_st *tl_memc_h; |
1690 | @@ -5032,21 +5021,18 @@ |
1691 | |
1692 | // Create a handle. |
1693 | tl_memc_h= memcached_create(NULL); |
1694 | - servers= memcached_servers_parse("localhost:9898"); // This server should not exist |
1695 | + servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist |
1696 | memcached_server_push(tl_memc_h, servers); |
1697 | memcached_server_list_free(servers); |
1698 | |
1699 | // See if memcached is reachable. |
1700 | value= memcached_get(tl_memc_h, key, strlen(key), &len, &flags, &rc); |
1701 | |
1702 | - if (value) |
1703 | - { |
1704 | - free(value); |
1705 | - test_true(value); // Pointer won't be zero so this is fine. |
1706 | - } |
1707 | - |
1708 | + test_false(value); |
1709 | test_true(len == 0); |
1710 | - test_true(rc == MEMCACHED_SOME_ERRORS); |
1711 | + test_true(rc == MEMCACHED_ERRNO); |
1712 | + |
1713 | + memcached_free(tl_memc_h); |
1714 | |
1715 | return TEST_SUCCESS; |
1716 | } |
1717 | @@ -5065,12 +5051,7 @@ |
1718 | // See if memcached is reachable. |
1719 | value= memcached_get(memc, key, strlen(key), &len, &flags, &rc); |
1720 | |
1721 | - if (value) |
1722 | - { |
1723 | - free(value); |
1724 | - test_true(value); // Pointer won't be zero so this is fine. |
1725 | - } |
1726 | - |
1727 | + test_false(value); |
1728 | test_true(len == 0); |
1729 | test_true(rc == MEMCACHED_NOTFOUND); |
1730 | |
1731 | @@ -5083,7 +5064,7 @@ |
1732 | We are testing the error condition when we connect to a server via memcached_get_by_key() |
1733 | but find that the server is not available. |
1734 | */ |
1735 | -static test_return_t memcached_get_by_key_MEMCACHED_SOME_ERRORS(memcached_st *memc) |
1736 | +static test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *memc) |
1737 | { |
1738 | (void)memc; |
1739 | memcached_st *tl_memc_h; |
1740 | @@ -5097,21 +5078,18 @@ |
1741 | |
1742 | // Create a handle. |
1743 | tl_memc_h= memcached_create(NULL); |
1744 | - servers= memcached_servers_parse("localhost:9898"); // This server should not exist |
1745 | + servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist |
1746 | memcached_server_push(tl_memc_h, servers); |
1747 | memcached_server_list_free(servers); |
1748 | |
1749 | // See if memcached is reachable. |
1750 | value= memcached_get_by_key(tl_memc_h, key, strlen(key), key, strlen(key), &len, &flags, &rc); |
1751 | |
1752 | - if (value) |
1753 | - { |
1754 | - free(value); |
1755 | - test_true(value); // Pointer won't be zero so this is fine. |
1756 | - } |
1757 | - |
1758 | + test_false(value); |
1759 | test_true(len == 0); |
1760 | - test_true(rc == MEMCACHED_SOME_ERRORS); |
1761 | + test_true(rc == MEMCACHED_ERRNO); |
1762 | + |
1763 | + memcached_free(tl_memc_h); |
1764 | |
1765 | return TEST_SUCCESS; |
1766 | } |
1767 | @@ -5130,12 +5108,7 @@ |
1768 | // See if memcached is reachable. |
1769 | value= memcached_get_by_key(memc, key, strlen(key), key, strlen(key), &len, &flags, &rc); |
1770 | |
1771 | - if (value) |
1772 | - { |
1773 | - free(value); |
1774 | - test_true(value); // Pointer won't be zero so this is fine. |
1775 | - } |
1776 | - |
1777 | + test_false(value); |
1778 | test_true(len == 0); |
1779 | test_true(rc == MEMCACHED_NOTFOUND); |
1780 | |
1781 | @@ -5575,54 +5548,58 @@ |
1782 | |
1783 | static test_return_t regression_bug_463297(memcached_st *memc) |
1784 | { |
1785 | - memcached_st *memc_clone= memcached_clone(NULL, memc); |
1786 | - test_true(memc_clone != NULL); |
1787 | - test_true(memcached_version(memc_clone) == MEMCACHED_SUCCESS); |
1788 | - |
1789 | - |
1790 | - if (libmemcached_util_version_check(memc_clone, 1, 1, 2)) |
1791 | + memcached_st *memc_clone= memcached_clone(NULL, memc); |
1792 | + test_true(memc_clone != NULL); |
1793 | + test_true(memcached_version(memc_clone) == MEMCACHED_SUCCESS); |
1794 | + |
1795 | + memcached_server_instance_st instance= |
1796 | + memcached_server_instance_by_position(memc_clone, 0); |
1797 | + |
1798 | + if (instance->major_version > 1 || |
1799 | + (instance->major_version == 1 && |
1800 | + instance->minor_version > 2)) |
1801 | { |
1802 | - /* Binary protocol doesn't support deferred delete */ |
1803 | - memcached_st *bin_clone= memcached_clone(NULL, memc); |
1804 | - test_true(bin_clone != NULL); |
1805 | - test_true(memcached_behavior_set(bin_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1) == MEMCACHED_SUCCESS); |
1806 | - test_true(memcached_delete(bin_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS); |
1807 | - memcached_free(bin_clone); |
1808 | - |
1809 | - memcached_quit(memc_clone); |
1810 | - |
1811 | - /* If we know the server version, deferred delete should fail |
1812 | - * with invalid arguments */ |
1813 | - test_true(memcached_delete(memc_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS); |
1814 | - |
1815 | - /* If we don't know the server version, we should get a protocol error */ |
1816 | - memcached_return_t rc= memcached_delete(memc, "foo", 3, 1); |
1817 | - |
1818 | - /* but there is a bug in some of the memcached servers (1.4) that treats |
1819 | - * the counter as noreply so it doesn't send the proper error message |
1820 | - */ |
1821 | - test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); |
1822 | - |
1823 | - /* And buffered mode should be disabled and we should get protocol error */ |
1824 | - test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1) == MEMCACHED_SUCCESS); |
1825 | - rc= memcached_delete(memc, "foo", 3, 1); |
1826 | - test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); |
1827 | - |
1828 | - /* Same goes for noreply... */ |
1829 | - test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1) == MEMCACHED_SUCCESS); |
1830 | - rc= memcached_delete(memc, "foo", 3, 1); |
1831 | - test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); |
1832 | - |
1833 | - /* but a normal request should go through (and be buffered) */ |
1834 | - test_true((rc= memcached_delete(memc, "foo", 3, 0)) == MEMCACHED_BUFFERED); |
1835 | - test_true(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS); |
1836 | - |
1837 | - test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0) == MEMCACHED_SUCCESS); |
1838 | - /* unbuffered noreply should be success */ |
1839 | - test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_SUCCESS); |
1840 | - /* unbuffered with reply should be not found... */ |
1841 | - test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0) == MEMCACHED_SUCCESS); |
1842 | - test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_NOTFOUND); |
1843 | + /* Binary protocol doesn't support deferred delete */ |
1844 | + memcached_st *bin_clone= memcached_clone(NULL, memc); |
1845 | + test_true(bin_clone != NULL); |
1846 | + test_true(memcached_behavior_set(bin_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1) == MEMCACHED_SUCCESS); |
1847 | + test_true(memcached_delete(bin_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS); |
1848 | + memcached_free(bin_clone); |
1849 | + |
1850 | + memcached_quit(memc_clone); |
1851 | + |
1852 | + /* If we know the server version, deferred delete should fail |
1853 | + * with invalid arguments */ |
1854 | + test_true(memcached_delete(memc_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS); |
1855 | + |
1856 | + /* If we don't know the server version, we should get a protocol error */ |
1857 | + memcached_return_t rc= memcached_delete(memc, "foo", 3, 1); |
1858 | + |
1859 | + /* but there is a bug in some of the memcached servers (1.4) that treats |
1860 | + * the counter as noreply so it doesn't send the proper error message |
1861 | + */ |
1862 | + test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); |
1863 | + |
1864 | + /* And buffered mode should be disabled and we should get protocol error */ |
1865 | + test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1) == MEMCACHED_SUCCESS); |
1866 | + rc= memcached_delete(memc, "foo", 3, 1); |
1867 | + test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); |
1868 | + |
1869 | + /* Same goes for noreply... */ |
1870 | + test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1) == MEMCACHED_SUCCESS); |
1871 | + rc= memcached_delete(memc, "foo", 3, 1); |
1872 | + test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); |
1873 | + |
1874 | + /* but a normal request should go through (and be buffered) */ |
1875 | + test_true((rc= memcached_delete(memc, "foo", 3, 0)) == MEMCACHED_BUFFERED); |
1876 | + test_true(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS); |
1877 | + |
1878 | + test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0) == MEMCACHED_SUCCESS); |
1879 | + /* unbuffered noreply should be success */ |
1880 | + test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_SUCCESS); |
1881 | + /* unbuffered with reply should be not found... */ |
1882 | + test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0) == MEMCACHED_SUCCESS); |
1883 | + test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_NOTFOUND); |
1884 | } |
1885 | |
1886 | memcached_free(memc_clone); |
1887 | @@ -5748,6 +5725,39 @@ |
1888 | return TEST_SUCCESS; |
1889 | } |
1890 | |
1891 | + |
1892 | +static memcached_return_t stat_printer(memcached_server_instance_st server, |
1893 | + const char *key, size_t key_length, |
1894 | + const char *value, size_t value_length, |
1895 | + void *context) |
1896 | +{ |
1897 | + (void)server; |
1898 | + (void)context; |
1899 | + (void)key; |
1900 | + (void)key_length; |
1901 | + (void)value; |
1902 | + (void)value_length; |
1903 | + |
1904 | + return MEMCACHED_SUCCESS; |
1905 | +} |
1906 | + |
1907 | +static test_return_t memcached_stat_execute_test(memcached_st *memc) |
1908 | +{ |
1909 | + memcached_return_t rc= memcached_stat_execute(memc, NULL, stat_printer, NULL); |
1910 | + test_true(rc == MEMCACHED_SUCCESS); |
1911 | + |
1912 | + rc= memcached_stat_execute(memc, "slabs", stat_printer, NULL); |
1913 | + test_true(rc == MEMCACHED_SUCCESS); |
1914 | + |
1915 | + rc= memcached_stat_execute(memc, "items", stat_printer, NULL); |
1916 | + test_true(rc == MEMCACHED_SUCCESS); |
1917 | + |
1918 | + rc= memcached_stat_execute(memc, "sizes", stat_printer, NULL); |
1919 | + test_true(rc == MEMCACHED_SUCCESS); |
1920 | + |
1921 | + return TEST_SUCCESS; |
1922 | +} |
1923 | + |
1924 | /* |
1925 | * This test ensures that the failure counter isn't incremented during |
1926 | * normal termination of the memcached instance. |
1927 | @@ -6080,6 +6090,7 @@ |
1928 | |
1929 | /* Clean the server before beginning testing */ |
1930 | test_st tests[] ={ |
1931 | + {"util_version", 1, (test_callback_fn)util_version_test }, |
1932 | {"flush", 0, (test_callback_fn)flush_test }, |
1933 | {"init", 0, (test_callback_fn)init_test }, |
1934 | {"allocation", 0, (test_callback_fn)allocation_test }, |
1935 | @@ -6135,12 +6146,12 @@ |
1936 | #ifdef HAVE_LIBMEMCACHEDUTIL |
1937 | {"connectionpool", 1, (test_callback_fn)connection_pool_test }, |
1938 | {"ping", 1, (test_callback_fn)ping_test }, |
1939 | - {"util_version", 1, (test_callback_fn)util_version_test }, |
1940 | #endif |
1941 | {"test_get_last_disconnect", 1, (test_callback_fn)test_get_last_disconnect}, |
1942 | {"verbosity", 1, (test_callback_fn)test_verbosity}, |
1943 | {"test_server_failure", 1, (test_callback_fn)test_server_failure}, |
1944 | {"cull_servers", 1, (test_callback_fn)test_cull_servers}, |
1945 | + {"memcached_stat_execute", 1, (test_callback_fn)memcached_stat_execute_test}, |
1946 | {0, 0, 0} |
1947 | }; |
1948 | |
1949 | @@ -6332,9 +6343,9 @@ |
1950 | }; |
1951 | |
1952 | test_st error_conditions[] ={ |
1953 | - {"memcached_get_MEMCACHED_SOME_ERRORS", 0, (test_callback_fn)memcached_get_MEMCACHED_SOME_ERRORS }, |
1954 | + {"memcached_get_MEMCACHED_ERRNO", 0, (test_callback_fn)memcached_get_MEMCACHED_ERRNO }, |
1955 | {"memcached_get_MEMCACHED_NOTFOUND", 0, (test_callback_fn)memcached_get_MEMCACHED_NOTFOUND }, |
1956 | - {"memcached_get_by_key_MEMCACHED_SOME_ERRORS", 0, (test_callback_fn)memcached_get_by_key_MEMCACHED_SOME_ERRORS }, |
1957 | + {"memcached_get_by_key_MEMCACHED_ERRNO", 0, (test_callback_fn)memcached_get_by_key_MEMCACHED_ERRNO }, |
1958 | {"memcached_get_by_key_MEMCACHED_NOTFOUND", 0, (test_callback_fn)memcached_get_by_key_MEMCACHED_NOTFOUND }, |
1959 | {0, 0, (test_callback_fn)0} |
1960 | }; |
1961 | |
1962 | === modified file 'tests/mem_udp.c' |
1963 | --- tests/mem_udp.c 2010-02-18 06:22:15 +0000 |
1964 | +++ tests/mem_udp.c 2010-07-21 16:27:47 +0000 |
1965 | @@ -10,10 +10,13 @@ |
1966 | Sample test application. |
1967 | */ |
1968 | |
1969 | +#include "config.h" |
1970 | + |
1971 | #include "libmemcached/common.h" |
1972 | |
1973 | #include <assert.h> |
1974 | #include <stdio.h> |
1975 | +#include <stdint.h> |
1976 | #include <stdlib.h> |
1977 | #include <string.h> |
1978 | #include <sys/time.h> |
1979 | @@ -25,14 +28,6 @@ |
1980 | |
1981 | #include "server.h" |
1982 | |
1983 | -#ifndef INT64_MAX |
1984 | -#define INT64_MAX LONG_MAX |
1985 | -#endif |
1986 | -#ifndef INT32_MAX |
1987 | -#define INT32_MAX INT_MAX |
1988 | -#endif |
1989 | - |
1990 | - |
1991 | #include "test.h" |
1992 | |
1993 | #define SERVERS_TO_CREATE 5 |
1994 | |
1995 | === modified file 'tests/server.c' |
1996 | --- tests/server.c 2010-06-15 06:31:25 +0000 |
1997 | +++ tests/server.c 2010-07-21 16:27:47 +0000 |
1998 | @@ -26,12 +26,12 @@ |
1999 | #include <libmemcached/memcached.h> |
2000 | #include <libmemcached/util.h> |
2001 | #include <unistd.h> |
2002 | +#include <time.h> |
2003 | + |
2004 | #include "server.h" |
2005 | |
2006 | void server_startup(server_startup_st *construct) |
2007 | { |
2008 | - unsigned int x; |
2009 | - |
2010 | if ((construct->server_list= getenv("MEMCACHED_SERVERS"))) |
2011 | { |
2012 | printf("servers %s\n", construct->server_list); |
2013 | @@ -46,7 +46,7 @@ |
2014 | char *end_ptr; |
2015 | end_ptr= server_string_buffer; |
2016 | |
2017 | - for (x= 0; x < construct->count; x++) |
2018 | + for (uint32_t x= 0; x < construct->count; x++) |
2019 | { |
2020 | char buffer[1024]; /* Nothing special for number */ |
2021 | int count; |
2022 | @@ -95,6 +95,39 @@ |
2023 | } |
2024 | *end_ptr= 0; |
2025 | |
2026 | + for (uint32_t x= 0; x < construct->count; x++) |
2027 | + { |
2028 | + uint32_t counter= 3; |
2029 | + char buffer[1024]; /* Nothing special for number */ |
2030 | + |
2031 | + snprintf(buffer, sizeof(buffer), "/tmp/%umemc.pid", x); |
2032 | + |
2033 | + while (--counter) |
2034 | + { |
2035 | + int memcached_pid; |
2036 | + |
2037 | + FILE *file; |
2038 | + file= fopen(buffer, "r"); |
2039 | + if (file == NULL) |
2040 | + { |
2041 | + struct timespec req= { .tv_sec= 0, .tv_nsec= 5000 }; |
2042 | + nanosleep(&req, NULL); |
2043 | + |
2044 | + continue; |
2045 | + } |
2046 | + char *found= fgets(buffer, sizeof(buffer), file); |
2047 | + if (!found) |
2048 | + { |
2049 | + abort(); |
2050 | + } |
2051 | + // Yes, we currently pitch this and don't make use of it. |
2052 | + memcached_pid= atoi(buffer); |
2053 | + fclose(file); |
2054 | + } |
2055 | + |
2056 | + |
2057 | + } |
2058 | + |
2059 | construct->server_list= strdup(server_string_buffer); |
2060 | } |
2061 | printf("servers %s\n", construct->server_list); |
2062 | @@ -105,7 +138,7 @@ |
2063 | |
2064 | srandom((unsigned int)time(NULL)); |
2065 | |
2066 | - for (x= 0; x < memcached_server_list_count(construct->servers); x++) |
2067 | + for (uint32_t x= 0; x < memcached_server_list_count(construct->servers); x++) |
2068 | { |
2069 | printf("\t%s : %d\n", memcached_server_name(&construct->servers[x]), memcached_server_port(&construct->servers[x])); |
2070 | assert(construct->servers[x].fd == -1); |
2071 | @@ -117,11 +150,9 @@ |
2072 | |
2073 | void server_shutdown(server_startup_st *construct) |
2074 | { |
2075 | - unsigned int x; |
2076 | - |
2077 | if (construct->server_list) |
2078 | { |
2079 | - for (x= 0; x < construct->count; x++) |
2080 | + for (uint32_t x= 0; x < construct->count; x++) |
2081 | { |
2082 | char buffer[1024]; /* Nothing special for number */ |
2083 | sprintf(buffer, "cat /tmp/%umemc.pid | xargs kill", x); |
2084 | |
2085 | === modified file 'tests/start.c' |
2086 | --- tests/start.c 2009-12-16 19:03:49 +0000 |
2087 | +++ tests/start.c 2010-07-21 16:27:47 +0000 |
2088 | @@ -9,6 +9,8 @@ |
2089 | * |
2090 | */ |
2091 | |
2092 | +#include "config.h" |
2093 | + |
2094 | #include <stdio.h> |
2095 | #include <string.h> |
2096 | #include "server.h" |
2097 | |
2098 | === modified file 'tests/test.c' |
2099 | --- tests/test.c 2010-04-22 00:49:09 +0000 |
2100 | +++ tests/test.c 2010-07-21 16:27:47 +0000 |
2101 | @@ -9,6 +9,9 @@ |
2102 | /* |
2103 | Sample test application. |
2104 | */ |
2105 | + |
2106 | +#include "config.h" |
2107 | + |
2108 | #include <assert.h> |
2109 | #include <stdlib.h> |
2110 | #include <string.h> |
2111 | @@ -22,6 +25,7 @@ |
2112 | #include <stdint.h> |
2113 | |
2114 | #include "libmemcached/memcached.h" |
2115 | + |
2116 | #include "test.h" |
2117 | |
2118 | static void world_stats_print(world_stats_st *stats) |
2119 | |
2120 | === added directory 'unittests' |
2121 | === added file 'unittests/include.am' |
2122 | --- unittests/include.am 1970-01-01 00:00:00 +0000 |
2123 | +++ unittests/include.am 2010-07-21 16:27:47 +0000 |
2124 | @@ -0,0 +1,20 @@ |
2125 | +# vim:ft=automake |
2126 | +# included from Top Level Makefile.am |
2127 | +# All paths should be given relative to the root |
2128 | + |
2129 | +if HAVE_LIBGTEST |
2130 | +check_PROGRAMS += unittests/unittests |
2131 | +endif |
2132 | + |
2133 | +unittests_unittests_SOURCES= \ |
2134 | + unittests/main.cc \ |
2135 | + unittests/strings.cc |
2136 | + |
2137 | +unittests_unittest_CXXFLAGS= ${AM_CXXFLAGS} ${NO_WERROR} |
2138 | +unittests_unittests_LDADD= \ |
2139 | + tests/libserver.la \ |
2140 | + libmemcached/libmemcachedinternal.la \ |
2141 | + ${TESTS_LDADDS} ${LTLIBGTEST} |
2142 | +# Shorthand |
2143 | +unit: check-TESTS |
2144 | + |
2145 | |
2146 | === added file 'unittests/main.cc' |
2147 | --- unittests/main.cc 1970-01-01 00:00:00 +0000 |
2148 | +++ unittests/main.cc 2010-07-21 16:27:47 +0000 |
2149 | @@ -0,0 +1,21 @@ |
2150 | +/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*- |
2151 | + * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
2152 | + * |
2153 | + * Copyright (C) 2010 Monty Taylor |
2154 | + * |
2155 | + * All rights reserved. |
2156 | + * |
2157 | + * Use and distribution licensed under the BSD license. See |
2158 | + * the COPYING file in the parent directory for full text. |
2159 | + */ |
2160 | + |
2161 | +#include "config.h" |
2162 | + |
2163 | +#include <gtest/gtest.h> |
2164 | + |
2165 | + |
2166 | +int main(int argc, char **argv) |
2167 | +{ |
2168 | + ::testing::InitGoogleTest(&argc, argv); |
2169 | + return RUN_ALL_TESTS(); |
2170 | +} |
2171 | |
2172 | === added file 'unittests/strings.cc' |
2173 | --- unittests/strings.cc 1970-01-01 00:00:00 +0000 |
2174 | +++ unittests/strings.cc 2010-07-21 16:27:47 +0000 |
2175 | @@ -0,0 +1,134 @@ |
2176 | +/* libMemcached |
2177 | + * Copyright (C) 2010 Brian Aker |
2178 | + * All rights reserved. |
2179 | + * |
2180 | + * Use and distribution licensed under the BSD license. See |
2181 | + * the COPYING file in the parent directory for full text. |
2182 | + */ |
2183 | + |
2184 | +#include "config.h" |
2185 | + |
2186 | +#define __STDC_LIMIT_MACROS |
2187 | +#include <stdint.h> |
2188 | + |
2189 | +#include <gtest/gtest.h> |
2190 | + |
2191 | +#include <libmemcached/common.h> |
2192 | + |
2193 | +TEST(memcached_string_st, memcached_create_static) |
2194 | +{ |
2195 | + memcached_string_st string; |
2196 | + memcached_string_st *string_ptr; |
2197 | + |
2198 | + memcached_st *memc= memcached_create(NULL); |
2199 | + string_ptr= memcached_string_create(memc, &string, 0); |
2200 | + ASSERT_TRUE(string.options.is_initialized); |
2201 | + ASSERT_TRUE(string_ptr); |
2202 | + |
2203 | + /* The following two better be the same! */ |
2204 | + ASSERT_FALSE(memcached_is_allocated(string_ptr)); |
2205 | + ASSERT_FALSE(memcached_is_allocated(&string)); |
2206 | + EXPECT_EQ(&string, string_ptr); |
2207 | + |
2208 | + ASSERT_TRUE(string.options.is_initialized); |
2209 | + ASSERT_TRUE(memcached_is_initialized(&string)); |
2210 | + memcached_string_free(&string); |
2211 | + ASSERT_FALSE(memcached_is_initialized(&string)); |
2212 | + |
2213 | + memcached_free(memc); |
2214 | +} |
2215 | + |
2216 | +TEST(memcached_string_st, memcached_create_null) |
2217 | +{ |
2218 | + memcached_string_st *string; |
2219 | + memcached_st *memc= memcached_create(NULL); |
2220 | + |
2221 | + string= memcached_string_create(memc, NULL, 0); |
2222 | + ASSERT_TRUE(string); |
2223 | + ASSERT_TRUE(memcached_is_allocated(string)); |
2224 | + ASSERT_TRUE(memcached_is_initialized(string)); |
2225 | + memcached_string_free(string); |
2226 | + |
2227 | + memcached_free(memc); |
2228 | +} |
2229 | + |
2230 | +TEST(memcached_string_st, string_alloc_with_size) |
2231 | +{ |
2232 | + memcached_string_st *string; |
2233 | + memcached_st *memc= memcached_create(NULL); |
2234 | + |
2235 | + string= memcached_string_create(memc, NULL, 1024); |
2236 | + ASSERT_TRUE(string); |
2237 | + ASSERT_TRUE(memcached_is_allocated(string)); |
2238 | + ASSERT_TRUE(memcached_is_initialized(string)); |
2239 | + memcached_string_free(string); |
2240 | + |
2241 | + memcached_free(memc); |
2242 | +} |
2243 | + |
2244 | +TEST(memcached_string_st, string_alloc_with_size_toobig) |
2245 | +{ |
2246 | + memcached_st *memc= memcached_create(NULL); |
2247 | + memcached_string_st *string; |
2248 | + |
2249 | + string= memcached_string_create(memc, NULL, SIZE_MAX); |
2250 | + ASSERT_FALSE(string); |
2251 | + |
2252 | + memcached_free(memc); |
2253 | +} |
2254 | + |
2255 | +TEST(memcached_string_st, string_alloc_append) |
2256 | +{ |
2257 | + char buffer[SMALL_STRING_LEN]; |
2258 | + memcached_string_st *string; |
2259 | + |
2260 | + memcached_st *memc= memcached_create(NULL); |
2261 | + |
2262 | + /* Ring the bell! */ |
2263 | + memset(buffer, 6, SMALL_STRING_LEN); |
2264 | + |
2265 | + string= memcached_string_create(memc, NULL, 100); |
2266 | + ASSERT_TRUE(string); |
2267 | + ASSERT_TRUE(memcached_is_allocated(string)); |
2268 | + ASSERT_TRUE(memcached_is_initialized(string)); |
2269 | + |
2270 | + for (uint32_t x= 0; x < 1024; x++) |
2271 | + { |
2272 | + memcached_return_t rc; |
2273 | + rc= memcached_string_append(string, buffer, SMALL_STRING_LEN); |
2274 | + EXPECT_EQ(rc, MEMCACHED_SUCCESS); |
2275 | + } |
2276 | + ASSERT_TRUE(memcached_is_allocated(string)); |
2277 | + memcached_string_free(string); |
2278 | + |
2279 | + memcached_free(memc); |
2280 | +} |
2281 | + |
2282 | +TEST(memcached_string_st, string_alloc_append_toobig) |
2283 | +{ |
2284 | + memcached_return_t rc; |
2285 | + char buffer[SMALL_STRING_LEN]; |
2286 | + memcached_string_st *string; |
2287 | + |
2288 | + memcached_st *memc= memcached_create(NULL); |
2289 | + |
2290 | + /* Ring the bell! */ |
2291 | + memset(buffer, 6, SMALL_STRING_LEN); |
2292 | + |
2293 | + string= memcached_string_create(memc, NULL, 100); |
2294 | + ASSERT_TRUE(string); |
2295 | + ASSERT_TRUE(memcached_is_allocated(string)); |
2296 | + ASSERT_TRUE(memcached_is_initialized(string)); |
2297 | + |
2298 | + for (uint32_t x= 0; x < 1024; x++) |
2299 | + { |
2300 | + rc= memcached_string_append(string, buffer, SMALL_STRING_LEN); |
2301 | + EXPECT_EQ(rc, MEMCACHED_SUCCESS); |
2302 | + } |
2303 | + rc= memcached_string_append(string, buffer, SIZE_MAX); |
2304 | + EXPECT_EQ(rc, MEMCACHED_MEMORY_ALLOCATION_FAILURE); |
2305 | + ASSERT_TRUE(memcached_is_allocated(string)); |
2306 | + memcached_string_free(string); |
2307 | + |
2308 | + memcached_free(memc); |
2309 | +} |
This was applied to the tree a while ago.