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 | 181 | tests/testhashkit | 181 | tests/testhashkit |
6 | 182 | tests/testplus | 182 | tests/testplus |
7 | 183 | tests/testudp | 183 | tests/testudp |
8 | 184 | unittests/unittests | ||
9 | 184 | 185 | ||
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 @@ | |||
15 | 1 | 0.41 | 1 | 0.43 |
16 | 2 | * memcached_stat_execute() merged. | ||
17 | 3 | |||
18 | 4 | 0.42 Tue Jul 6 12:29:50 PDT 2010 | ||
19 | 5 | * Mistake in libtool caused issue with library version | ||
20 | 6 | |||
21 | 7 | 0.41 Wed Jun 30 13:15:19 PDT 2010 | ||
22 | 2 | * Added --file for memcat. | 8 | * Added --file for memcat. |
23 | 3 | * Added limemcached_ping() to libmemcached_util | 9 | * Added limemcached_ping() to libmemcached_util |
24 | 10 | * Bugfix for some cases where connect would have issues with timeout. | ||
25 | 11 | * Wrong value for errno given as error on an IO failure inside of poll. | ||
26 | 12 | * Bug fix for issue where multiple interfaces with bad DNS were not being caught. | ||
27 | 4 | 13 | ||
28 | 5 | 0.40 Thu Apr 22 19:01:25 PDT 2010 | 14 | 0.40 Thu Apr 22 19:01:25 PDT 2010 |
29 | 6 | * Placed retry logic in for busted resolvers | 15 | * Placed retry logic in for busted resolvers |
30 | 7 | 16 | ||
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 | 12 | noinst_PROGRAMS = | 12 | noinst_PROGRAMS = |
36 | 13 | include_HEADERS = | 13 | include_HEADERS = |
37 | 14 | nobase_include_HEADERS = | 14 | nobase_include_HEADERS = |
38 | 15 | check_PROGRAMS = | ||
39 | 15 | EXTRA_HEADERS = | 16 | EXTRA_HEADERS = |
40 | 16 | BUILT_SOURCES= | 17 | BUILT_SOURCES= |
41 | 17 | EXTRA_DIST= \ | 18 | EXTRA_DIST= \ |
42 | @@ -29,19 +30,23 @@ | |||
43 | 29 | m4/po.m4 \ | 30 | m4/po.m4 \ |
44 | 30 | m4/progtest.m4 | 31 | m4/progtest.m4 |
45 | 31 | 32 | ||
47 | 32 | 33 | TEST_DOCS= | |
48 | 34 | if BUILD_DOCS | ||
49 | 33 | SUBDIRS = docs | 35 | SUBDIRS = docs |
50 | 36 | TEST_DOCS+=test-docs | ||
51 | 37 | endif | ||
52 | 34 | 38 | ||
53 | 35 | test-docs: | 39 | test-docs: |
54 | 36 | (cd docs && $(MAKE) test-docs) | 40 | (cd docs && $(MAKE) test-docs) |
55 | 37 | include libmemcached/include.am | 41 | include libmemcached/include.am |
56 | 38 | include clients/include.am | 42 | include clients/include.am |
57 | 39 | include libhashkit/include.am | 43 | include libhashkit/include.am |
58 | 44 | include unittests/include.am | ||
59 | 40 | include tests/include.am | 45 | include tests/include.am |
60 | 41 | include example/include.am | 46 | include example/include.am |
61 | 42 | include support/include.am | 47 | include support/include.am |
62 | 43 | 48 | ||
64 | 44 | check-local: test-no-outputdiff | 49 | TESTS += ${check_PROGRAMS} |
65 | 45 | 50 | ||
66 | 46 | 51 | ||
67 | 47 | fedora: | 52 | fedora: |
68 | @@ -82,7 +87,7 @@ | |||
69 | 82 | genhtml -o lcov --function-coverage -t libmemcached libmemcached/lcov.out | 87 | genhtml -o lcov --function-coverage -t libmemcached libmemcached/lcov.out |
70 | 83 | 88 | ||
71 | 84 | lcov-clean: clean | 89 | lcov-clean: clean |
73 | 85 | rm -rf lcov */lcov.out | 90 | rm -rf lcov */lcov.out |
74 | 86 | find . -name '*.gcno' | xargs rm -f | 91 | find . -name '*.gcno' | xargs rm -f |
75 | 87 | find . -name '*.gcda' | xargs rm -f | 92 | find . -name '*.gcda' | xargs rm -f |
76 | 88 | 93 | ||
77 | 89 | 94 | ||
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 | 14 | Return the number of rows set. | 14 | Return the number of rows set. |
83 | 15 | */ | 15 | */ |
84 | 16 | 16 | ||
87 | 17 | #include "libmemcached/common.h" | 17 | #include "config.h" |
86 | 18 | |||
88 | 19 | #include "execute.h" | 18 | #include "execute.h" |
89 | 20 | 19 | ||
90 | 21 | unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of) | 20 | unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of) |
91 | @@ -108,12 +107,11 @@ | |||
92 | 108 | rc= memcached_mget_execute(memc, keys, key_length, | 107 | rc= memcached_mget_execute(memc, keys, key_length, |
93 | 109 | (size_t)number_of, callbacks, &retrieved, 1); | 108 | (size_t)number_of, callbacks, &retrieved, 1); |
94 | 110 | 109 | ||
96 | 111 | likely (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOTFOUND || | 110 | if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOTFOUND || |
97 | 112 | rc == MEMCACHED_BUFFERED || rc == MEMCACHED_END) | 111 | rc == MEMCACHED_BUFFERED || rc == MEMCACHED_END) |
98 | 113 | { | 112 | { |
99 | 114 | rc= memcached_fetch_execute(memc, callbacks, (void *)&retrieved, 1); | 113 | rc= memcached_fetch_execute(memc, callbacks, (void *)&retrieved, 1); |
102 | 115 | unlikely (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_NOTFOUND && | 114 | if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_NOTFOUND && rc != MEMCACHED_END) |
101 | 116 | rc != MEMCACHED_END) | ||
103 | 117 | { | 115 | { |
104 | 118 | fprintf(stderr, "Failed to execute mget: %s\n", | 116 | fprintf(stderr, "Failed to execute mget: %s\n", |
105 | 119 | memcached_strerror(memc, rc)); | 117 | memcached_strerror(memc, rc)); |
106 | 120 | 118 | ||
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 | 11 | 11 | ||
112 | 12 | #ifndef CLIENTS_EXECUTE_H | 12 | #ifndef CLIENTS_EXECUTE_H |
113 | 13 | #define CLIENTS_EXECUTE_H | 13 | #define CLIENTS_EXECUTE_H |
114 | 14 | |||
115 | 15 | #include <stdio.h> | ||
116 | 16 | |||
117 | 14 | #include "libmemcached/memcached.h" | 17 | #include "libmemcached/memcached.h" |
118 | 15 | #include "generator.h" | 18 | #include "generator.h" |
119 | 16 | 19 | ||
120 | 17 | 20 | ||
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 | 9 | * | 9 | * |
126 | 10 | */ | 10 | */ |
127 | 11 | 11 | ||
129 | 12 | #include "libmemcached/common.h" | 12 | #include "config.h" |
130 | 13 | 13 | ||
131 | 14 | #include <stdio.h> | 14 | #include <stdio.h> |
132 | 15 | #include <stdlib.h> | 15 | #include <stdlib.h> |
133 | 16 | 16 | ||
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 | 9 | * | 9 | * |
139 | 10 | */ | 10 | */ |
140 | 11 | 11 | ||
142 | 12 | #include "libmemcached/common.h" | 12 | #include "config.h" |
143 | 13 | |||
144 | 13 | #include <stdio.h> | 14 | #include <stdio.h> |
145 | 14 | #include <inttypes.h> | 15 | #include <inttypes.h> |
146 | 15 | #include <string.h> | 16 | #include <string.h> |
147 | 16 | 17 | ||
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 | 9 | * | 9 | * |
153 | 10 | */ | 10 | */ |
154 | 11 | 11 | ||
156 | 12 | #include "libmemcached/common.h" | 12 | #include "config.h" |
157 | 13 | |||
158 | 13 | #include <stdio.h> | 14 | #include <stdio.h> |
159 | 14 | #include <stdlib.h> | 15 | #include <stdlib.h> |
160 | 15 | #include <inttypes.h> | 16 | #include <inttypes.h> |
161 | @@ -22,6 +23,10 @@ | |||
162 | 22 | #include <errno.h> | 23 | #include <errno.h> |
163 | 23 | #include <strings.h> | 24 | #include <strings.h> |
164 | 24 | #include <string.h> | 25 | #include <string.h> |
165 | 26 | #include <sys/types.h> | ||
166 | 27 | #include <stdlib.h> | ||
167 | 28 | #include <limits.h> | ||
168 | 29 | |||
169 | 25 | 30 | ||
170 | 26 | #include <libmemcached/memcached.h> | 31 | #include <libmemcached/memcached.h> |
171 | 27 | 32 | ||
172 | 28 | 33 | ||
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 | 9 | * | 9 | * |
178 | 10 | */ | 10 | */ |
179 | 11 | 11 | ||
181 | 12 | #include "libmemcached/common.h" | 12 | #include "config.h" |
182 | 13 | |||
183 | 13 | #include <stdio.h> | 14 | #include <stdio.h> |
184 | 14 | #include <stdlib.h> | 15 | #include <stdlib.h> |
185 | 15 | #include <inttypes.h> | 16 | #include <inttypes.h> |
186 | 16 | 17 | ||
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 | 8 | * Summary: | 8 | * Summary: |
192 | 9 | * | 9 | * |
193 | 10 | */ | 10 | */ |
194 | 11 | #include "config.h" | ||
195 | 11 | 12 | ||
196 | 12 | #include "libmemcached/common.h" | ||
197 | 13 | #include <stdio.h> | 13 | #include <stdio.h> |
198 | 14 | #include <inttypes.h> | 14 | #include <inttypes.h> |
199 | 15 | #include <string.h> | 15 | #include <string.h> |
200 | 16 | 16 | ||
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 | 8 | * Summary: | 8 | * Summary: |
206 | 9 | * | 9 | * |
207 | 10 | */ | 10 | */ |
208 | 11 | #include "config.h" | ||
209 | 11 | 12 | ||
210 | 12 | #include "libmemcached/common.h" | ||
211 | 13 | #include <stdio.h> | 13 | #include <stdio.h> |
212 | 14 | #include <unistd.h> | 14 | #include <unistd.h> |
213 | 15 | #include <string.h> | 15 | #include <string.h> |
214 | 16 | 16 | ||
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 | 8 | * Summary: | 8 | * Summary: |
220 | 9 | * | 9 | * |
221 | 10 | */ | 10 | */ |
222 | 11 | #include "config.h" | ||
223 | 11 | 12 | ||
224 | 12 | #include "libmemcached/common.h" | ||
225 | 13 | #include <stdio.h> | 13 | #include <stdio.h> |
226 | 14 | #include <unistd.h> | 14 | #include <unistd.h> |
227 | 15 | #include <getopt.h> | 15 | #include <getopt.h> |
228 | 16 | 16 | ||
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 | 11 | * Brian Aker | 11 | * Brian Aker |
234 | 12 | * Toru Maesaka | 12 | * Toru Maesaka |
235 | 13 | */ | 13 | */ |
236 | 14 | #include "config.h" | ||
237 | 14 | 15 | ||
238 | 15 | #include "libmemcached/common.h" | ||
239 | 16 | #include <stdio.h> | 16 | #include <stdio.h> |
240 | 17 | #include <sys/types.h> | 17 | #include <sys/types.h> |
241 | 18 | #include <sys/stat.h> | 18 | #include <sys/stat.h> |
242 | @@ -56,36 +56,22 @@ | |||
243 | 56 | }; | 56 | }; |
244 | 57 | 57 | ||
245 | 58 | 58 | ||
249 | 59 | static memcached_return_t server_print_callback(const memcached_st *memc, | 59 | static memcached_return_t stat_printer(memcached_server_instance_st instance, |
250 | 60 | memcached_server_instance_st instance, | 60 | const char *key, size_t key_length, |
251 | 61 | void *context) | 61 | const char *value, size_t value_length, |
252 | 62 | void *context) | ||
253 | 62 | { | 63 | { |
259 | 63 | memcached_stat_st server_stat; | 64 | static memcached_server_instance_st last= NULL; |
255 | 64 | memcached_return_t rc; | ||
256 | 65 | char **list; | ||
257 | 66 | char **ptr; | ||
258 | 67 | |||
260 | 68 | (void)context; | 65 | (void)context; |
261 | 69 | 66 | ||
272 | 70 | rc= memcached_stat_servername(&server_stat, NULL, | 67 | if (last != instance) |
263 | 71 | memcached_server_name(instance), | ||
264 | 72 | memcached_server_port(instance)); | ||
265 | 73 | |||
266 | 74 | list= memcached_stat_get_keys(memc, &server_stat, &rc); | ||
267 | 75 | |||
268 | 76 | printf("Server: %s (%u)\n", memcached_server_name(instance), | ||
269 | 77 | (uint32_t)memcached_server_port(instance)); | ||
270 | 78 | |||
271 | 79 | for (ptr= list; *ptr; ptr++) | ||
273 | 80 | { | 68 | { |
278 | 81 | char *value= memcached_stat_get_value(memc, &server_stat, *ptr, &rc); | 69 | printf("Server: %s (%u)\n", memcached_server_name(instance), |
279 | 82 | 70 | (uint32_t)memcached_server_port(instance)); | |
280 | 83 | printf("\t %s: %s\n", *ptr, value); | 71 | last= instance; |
277 | 84 | free(value); | ||
281 | 85 | } | 72 | } |
282 | 86 | 73 | ||
285 | 87 | free(list); | 74 | printf("\t %.*s: %.*s\n", (int)key_length, key, (int)value_length, value); |
284 | 88 | printf("\n"); | ||
286 | 89 | 75 | ||
287 | 90 | return MEMCACHED_SUCCESS; | 76 | return MEMCACHED_SUCCESS; |
288 | 91 | } | 77 | } |
289 | @@ -140,12 +126,7 @@ | |||
290 | 140 | } | 126 | } |
291 | 141 | else | 127 | else |
292 | 142 | { | 128 | { |
299 | 143 | memcached_server_fn callbacks[1]; | 129 | rc= memcached_stat_execute(memc, NULL, stat_printer, NULL); |
294 | 144 | |||
295 | 145 | callbacks[0]= server_print_callback; | ||
296 | 146 | rc= memcached_server_cursor(memc, callbacks, | ||
297 | 147 | NULL, 1); | ||
298 | 148 | |||
300 | 149 | } | 130 | } |
301 | 150 | 131 | ||
302 | 151 | free(opt_servers); | 132 | free(opt_servers); |
303 | 152 | 133 | ||
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 | 8 | * Summary: | 8 | * Summary: |
309 | 9 | * | 9 | * |
310 | 10 | */ | 10 | */ |
311 | 11 | #include "config.h" | ||
312 | 11 | 12 | ||
313 | 12 | #include "libmemcached/common.h" | ||
314 | 13 | #include <stdio.h> | 13 | #include <stdio.h> |
315 | 14 | #include <ctype.h> | 14 | #include <ctype.h> |
316 | 15 | #include <string.h> | 15 | #include <string.h> |
317 | 16 | 16 | ||
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 | 11 | 11 | ||
323 | 12 | #include <getopt.h> | 12 | #include <getopt.h> |
324 | 13 | #include <libmemcached/memcached.h> | 13 | #include <libmemcached/memcached.h> |
325 | 14 | #include "libmemcached/watchpoint.h" | ||
326 | 14 | #include "client_options.h" | 15 | #include "client_options.h" |
327 | 15 | 16 | ||
328 | 16 | #if TIME_WITH_SYS_TIME | 17 | #if TIME_WITH_SYS_TIME |
329 | 17 | 18 | ||
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 | 7 | # the COPYING file in this directory for full text. | 7 | # the COPYING file in this directory for full text. |
335 | 8 | 8 | ||
336 | 9 | AC_PREREQ(2.59) | 9 | AC_PREREQ(2.59) |
338 | 10 | AC_INIT([libmemcached],[0.41],[http://libmemcached.org/]) | 10 | AC_INIT([libmemcached],[0.42],[http://libmemcached.org/]) |
339 | 11 | AC_CONFIG_SRCDIR([libmemcached/memcached.c]) | 11 | AC_CONFIG_SRCDIR([libmemcached/memcached.c]) |
340 | 12 | AC_CONFIG_AUX_DIR(config) | 12 | AC_CONFIG_AUX_DIR(config) |
341 | 13 | 13 | ||
342 | 14 | PANDORA_CANONICAL_TARGET | 14 | PANDORA_CANONICAL_TARGET |
343 | 15 | 15 | ||
344 | 16 | #shared library versioning | 16 | #shared library versioning |
346 | 17 | MEMCACHED_LIBRARY_VERSION=5:1:1 | 17 | MEMCACHED_UTIL_LIBRARY_VERSION=1:0:0 |
347 | 18 | MEMCACHED_PROTOCAL_LIBRARY_VERSION=0:0:0 | ||
348 | 19 | MEMCACHED_LIBRARY_VERSION=5:1:0 | ||
349 | 18 | # | | | | 20 | # | | | |
350 | 19 | # +------+ | +---+ | 21 | # +------+ | +---+ |
351 | 20 | # | | | | 22 | # | | | |
352 | @@ -25,6 +27,8 @@ | |||
353 | 25 | # | +- increment if source code has changed | 27 | # | +- increment if source code has changed |
354 | 26 | # | set to zero if current is incremented | 28 | # | set to zero if current is incremented |
355 | 27 | # +- increment if interfaces have been added, removed or changed | 29 | # +- increment if interfaces have been added, removed or changed |
356 | 30 | AC_SUBST(MEMCACHED_UTIL_LIBRARY_VERSION) | ||
357 | 31 | AC_SUBST(MEMCACHED_PROTOCAL_LIBRARY_VERSION) | ||
358 | 28 | AC_SUBST(MEMCACHED_LIBRARY_VERSION) | 32 | AC_SUBST(MEMCACHED_LIBRARY_VERSION) |
359 | 29 | 33 | ||
360 | 30 | 34 | ||
361 | @@ -36,6 +40,7 @@ | |||
362 | 36 | 40 | ||
363 | 37 | AC_CHECK_FUNCS([getline]) | 41 | AC_CHECK_FUNCS([getline]) |
364 | 38 | 42 | ||
365 | 43 | PANDORA_HAVE_LIBGTEST | ||
366 | 39 | PANDORA_HAVE_LIBEVENT | 44 | PANDORA_HAVE_LIBEVENT |
367 | 40 | PANDORA_REQUIRE_PTHREAD | 45 | PANDORA_REQUIRE_PTHREAD |
368 | 41 | PANDORA_CXX_DEMANGLE | 46 | PANDORA_CXX_DEMANGLE |
369 | @@ -45,8 +50,6 @@ | |||
370 | 45 | ENABLE_UTILLIB | 50 | ENABLE_UTILLIB |
371 | 46 | SETSOCKOPT_SANITY | 51 | SETSOCKOPT_SANITY |
372 | 47 | ENABLE_HSIEH_HASH | 52 | ENABLE_HSIEH_HASH |
373 | 48 | REQUIRE_POD2MAN | ||
374 | 49 | REQUIRE_PODCHECKER | ||
375 | 50 | PROTOCOL_BINARY_TEST | 53 | PROTOCOL_BINARY_TEST |
376 | 51 | WITH_MEMCACHED | 54 | WITH_MEMCACHED |
377 | 52 | ENABLE_DEPRECATED | 55 | ENABLE_DEPRECATED |
378 | @@ -68,6 +71,20 @@ | |||
379 | 68 | [1], | 71 | [1], |
380 | 69 | [Define to true if you want to use functions from atomic.h])])]) | 72 | [Define to true if you want to use functions from atomic.h])])]) |
381 | 70 | 73 | ||
382 | 74 | AC_ARG_WITH([docs], | ||
383 | 75 | [AS_HELP_STRING([--with-docs], | ||
384 | 76 | [Generate documentation (yes|no) @<:@default=yes@:>@])], | ||
385 | 77 | [with_docs=$withval], | ||
386 | 78 | [with_docs=yes]) | ||
387 | 79 | |||
388 | 80 | AS_IF([test "$with_docs" = "yes"], | ||
389 | 81 | [ | ||
390 | 82 | REQUIRE_POD2MAN | ||
391 | 83 | REQUIRE_PODCHECKER | ||
392 | 84 | ]) | ||
393 | 85 | AM_CONDITIONAL(BUILD_DOCS, test "$with_docs" = "yes") | ||
394 | 86 | |||
395 | 87 | |||
396 | 71 | AC_CONFIG_FILES([ | 88 | AC_CONFIG_FILES([ |
397 | 72 | Makefile | 89 | Makefile |
398 | 73 | docs/Makefile | 90 | docs/Makefile |
399 | @@ -104,3 +121,13 @@ | |||
400 | 104 | ;; | 121 | ;; |
401 | 105 | esac | 122 | esac |
402 | 106 | 123 | ||
403 | 124 | AS_IF(test "$with_docs" = "no", | ||
404 | 125 | [ | ||
405 | 126 | echo "*****" | ||
406 | 127 | echo "*" | ||
407 | 128 | echo "* WARNING: You are not generating any documentation." | ||
408 | 129 | echo "* Please don't ship libmemcached to an end user" | ||
409 | 130 | echo "* without documentation..." | ||
410 | 131 | echo "*" | ||
411 | 132 | echo "*****" | ||
412 | 133 | ]) | ||
413 | 107 | 134 | ||
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 | 17 | +(uint32_t)(((const uint8_t *)(d))[0]) ) | 17 | +(uint32_t)(((const uint8_t *)(d))[0]) ) |
419 | 18 | #endif | 18 | #endif |
420 | 19 | 19 | ||
422 | 20 | uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context__attribute__((unused))) | 20 | uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context __attribute__((unused))) |
423 | 21 | { | 21 | { |
424 | 22 | uint32_t hash = 0, tmp; | 22 | uint32_t hash = 0, tmp; |
425 | 23 | int rem; | 23 | int rem; |
426 | @@ -43,16 +43,18 @@ | |||
427 | 43 | { | 43 | { |
428 | 44 | case 3: hash += get16bits (key); | 44 | case 3: hash += get16bits (key); |
429 | 45 | hash ^= hash << 16; | 45 | hash ^= hash << 16; |
431 | 46 | hash ^= key[sizeof (uint16_t)] << 18; | 46 | hash ^= (uint32_t)key[sizeof (uint16_t)] << 18; |
432 | 47 | hash += hash >> 11; | 47 | hash += hash >> 11; |
433 | 48 | break; | 48 | break; |
434 | 49 | case 2: hash += get16bits (key); | 49 | case 2: hash += get16bits (key); |
435 | 50 | hash ^= hash << 11; | 50 | hash ^= hash << 11; |
436 | 51 | hash += hash >> 17; | 51 | hash += hash >> 17; |
437 | 52 | break; | 52 | break; |
439 | 53 | case 1: hash += *key; | 53 | case 1: hash += (unsigned char)(*key); |
440 | 54 | hash ^= hash << 10; | 54 | hash ^= hash << 10; |
441 | 55 | hash += hash >> 1; | 55 | hash += hash >> 1; |
442 | 56 | default: | ||
443 | 57 | break; | ||
444 | 56 | } | 58 | } |
445 | 57 | 59 | ||
446 | 58 | /* Force "avalanching" of final 127 bits */ | 60 | /* Force "avalanching" of final 127 bits */ |
447 | 59 | 61 | ||
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 | 55 | ptr->server_failure_limit= (uint32_t)data; | 55 | ptr->server_failure_limit= (uint32_t)data; |
453 | 56 | break; | 56 | break; |
454 | 57 | case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: | 57 | case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: |
455 | 58 | memcached_quit(ptr); // We need t shutdown all of the connections to make sure we do the correct protocol | ||
456 | 58 | if (data) | 59 | if (data) |
457 | 59 | { | 60 | { |
458 | 60 | ptr->flags.verify_key= false; | 61 | ptr->flags.verify_key= false; |
459 | 61 | 62 | ||
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 | 56 | 56 | ||
465 | 57 | typedef struct memcached_server_st * memcached_server_write_instance_st; | 57 | typedef struct memcached_server_st * memcached_server_write_instance_st; |
466 | 58 | 58 | ||
467 | 59 | typedef memcached_return_t (*memcached_server_execute_fn)(memcached_st *ptr, memcached_server_write_instance_st server, void *context); | ||
468 | 60 | |||
469 | 59 | LIBMEMCACHED_LOCAL | 61 | LIBMEMCACHED_LOCAL |
470 | 60 | memcached_server_write_instance_st memcached_server_instance_fetch(memcached_st *ptr, uint32_t server_key); | 62 | memcached_server_write_instance_st memcached_server_instance_fetch(memcached_st *ptr, uint32_t server_key); |
471 | 61 | 63 | ||
472 | 64 | LIBMEMCACHED_LOCAL | ||
473 | 65 | memcached_return_t memcached_server_execute(memcached_st *ptr, | ||
474 | 66 | memcached_server_execute_fn callback, | ||
475 | 67 | void *context); | ||
476 | 68 | |||
477 | 69 | |||
478 | 62 | /* These are private not to be installed headers */ | 70 | /* These are private not to be installed headers */ |
479 | 63 | #include "libmemcached/io.h" | 71 | #include "libmemcached/io.h" |
480 | 64 | #include "libmemcached/do.h" | 72 | #include "libmemcached/do.h" |
481 | @@ -79,7 +87,7 @@ | |||
482 | 79 | typedef enum { | 87 | typedef enum { |
483 | 80 | MEM_NOT= -1, | 88 | MEM_NOT= -1, |
484 | 81 | MEM_FALSE= false, | 89 | MEM_FALSE= false, |
486 | 82 | MEM_TRUE= true, | 90 | MEM_TRUE= true |
487 | 83 | } memcached_ternary_t; | 91 | } memcached_ternary_t; |
488 | 84 | 92 | ||
489 | 85 | 93 | ||
490 | 86 | 94 | ||
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 | 1 | /* LibMemcached | ||
496 | 2 | * Copyright (C) 2006-2010 Brian Aker | ||
497 | 3 | * All rights reserved. | ||
498 | 4 | * | ||
499 | 5 | * Use and distribution licensed under the BSD license. See | ||
500 | 6 | * the COPYING file in the parent directory for full text. | ||
501 | 7 | * | ||
502 | 8 | * Summary: Server IO, Not public! | ||
503 | 9 | * | ||
504 | 10 | */ | ||
505 | 11 | |||
506 | 1 | #include "common.h" | 12 | #include "common.h" |
507 | 2 | #include <netdb.h> | 13 | #include <netdb.h> |
508 | 3 | #include <poll.h> | 14 | #include <poll.h> |
509 | 4 | #include <sys/time.h> | 15 | #include <sys/time.h> |
510 | 5 | #include <time.h> | 16 | #include <time.h> |
511 | 6 | 17 | ||
512 | 18 | static memcached_return_t connect_poll(memcached_server_st *ptr) | ||
513 | 19 | { | ||
514 | 20 | struct pollfd fds[1]; | ||
515 | 21 | fds[0].fd = ptr->fd; | ||
516 | 22 | fds[0].events = POLLOUT; | ||
517 | 23 | |||
518 | 24 | int timeout= ptr->root->connect_timeout; | ||
519 | 25 | if (ptr->root->flags.no_block == true) | ||
520 | 26 | timeout= -1; | ||
521 | 27 | |||
522 | 28 | int error; | ||
523 | 29 | size_t loop_max= 5; | ||
524 | 30 | |||
525 | 31 | while (--loop_max) // Should only loop on cases of ERESTART or EINTR | ||
526 | 32 | { | ||
527 | 33 | error= poll(fds, 1, timeout); | ||
528 | 34 | |||
529 | 35 | switch (error) | ||
530 | 36 | { | ||
531 | 37 | case 1: | ||
532 | 38 | { | ||
533 | 39 | int err; | ||
534 | 40 | socklen_t len= sizeof (err); | ||
535 | 41 | (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len); | ||
536 | 42 | |||
537 | 43 | // We check the value to see what happened wth the socket. | ||
538 | 44 | if (err == 0) | ||
539 | 45 | { | ||
540 | 46 | return MEMCACHED_SUCCESS; | ||
541 | 47 | } | ||
542 | 48 | else | ||
543 | 49 | { | ||
544 | 50 | ptr->cached_errno= errno; | ||
545 | 51 | |||
546 | 52 | return MEMCACHED_ERRNO; | ||
547 | 53 | } | ||
548 | 54 | } | ||
549 | 55 | case 0: | ||
550 | 56 | return MEMCACHED_TIMEOUT; | ||
551 | 57 | default: // A real error occurred and we need to completely bail | ||
552 | 58 | WATCHPOINT_ERRNO(errno); | ||
553 | 59 | switch (errno) | ||
554 | 60 | { | ||
555 | 61 | #ifdef TARGET_OS_LINUX | ||
556 | 62 | case ERESTART: | ||
557 | 63 | #endif | ||
558 | 64 | case EINTR: | ||
559 | 65 | continue; | ||
560 | 66 | default: | ||
561 | 67 | if (fds[0].revents & POLLERR) | ||
562 | 68 | { | ||
563 | 69 | int err; | ||
564 | 70 | socklen_t len= sizeof (err); | ||
565 | 71 | (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len); | ||
566 | 72 | ptr->cached_errno= (err == 0) ? errno : err; | ||
567 | 73 | } | ||
568 | 74 | else | ||
569 | 75 | { | ||
570 | 76 | ptr->cached_errno= errno; | ||
571 | 77 | } | ||
572 | 78 | |||
573 | 79 | (void)close(ptr->fd); | ||
574 | 80 | ptr->fd= -1; | ||
575 | 81 | |||
576 | 82 | return MEMCACHED_ERRNO; | ||
577 | 83 | } | ||
578 | 84 | } | ||
579 | 85 | WATCHPOINT_ASSERT(0); // Programming error | ||
580 | 86 | } | ||
581 | 87 | |||
582 | 88 | // This should only be possible from ERESTART or EINTR; | ||
583 | 89 | ptr->cached_errno= errno; | ||
584 | 90 | |||
585 | 91 | return MEMCACHED_ERRNO; | ||
586 | 92 | } | ||
587 | 93 | |||
588 | 7 | static memcached_return_t set_hostinfo(memcached_server_st *server) | 94 | static memcached_return_t set_hostinfo(memcached_server_st *server) |
589 | 8 | { | 95 | { |
590 | 9 | struct addrinfo *ai; | 96 | struct addrinfo *ai; |
591 | @@ -225,36 +312,35 @@ | |||
592 | 225 | { | 312 | { |
593 | 226 | struct sockaddr_un servAddr; | 313 | struct sockaddr_un servAddr; |
594 | 227 | 314 | ||
596 | 228 | if (ptr->fd == -1) | 315 | WATCHPOINT_ASSERT(ptr->fd == -1); |
597 | 316 | |||
598 | 317 | if ((ptr->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) | ||
599 | 229 | { | 318 | { |
605 | 230 | if ((ptr->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) | 319 | ptr->cached_errno= errno; |
606 | 231 | { | 320 | return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE; |
607 | 232 | ptr->cached_errno= errno; | 321 | } |
603 | 233 | return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE; | ||
604 | 234 | } | ||
608 | 235 | 322 | ||
612 | 236 | memset(&servAddr, 0, sizeof (struct sockaddr_un)); | 323 | memset(&servAddr, 0, sizeof (struct sockaddr_un)); |
613 | 237 | servAddr.sun_family= AF_UNIX; | 324 | servAddr.sun_family= AF_UNIX; |
614 | 238 | strcpy(servAddr.sun_path, ptr->hostname); /* Copy filename */ | 325 | strcpy(servAddr.sun_path, ptr->hostname); /* Copy filename */ |
615 | 239 | 326 | ||
616 | 240 | test_connect: | 327 | test_connect: |
620 | 241 | if (connect(ptr->fd, | 328 | if (connect(ptr->fd, |
621 | 242 | (struct sockaddr *)&servAddr, | 329 | (struct sockaddr *)&servAddr, |
622 | 243 | sizeof(servAddr)) < 0) | 330 | sizeof(servAddr)) < 0) |
623 | 331 | { | ||
624 | 332 | switch (errno) | ||
625 | 244 | { | 333 | { |
639 | 245 | switch (errno) | 334 | case EINPROGRESS: |
640 | 246 | { | 335 | case EALREADY: |
641 | 247 | case EINPROGRESS: | 336 | case EINTR: |
642 | 248 | case EALREADY: | 337 | goto test_connect; |
643 | 249 | case EINTR: | 338 | case EISCONN: /* We were spinning waiting on connect */ |
644 | 250 | goto test_connect; | 339 | break; |
645 | 251 | case EISCONN: /* We were spinning waiting on connect */ | 340 | default: |
646 | 252 | break; | 341 | WATCHPOINT_ERRNO(errno); |
647 | 253 | default: | 342 | ptr->cached_errno= errno; |
648 | 254 | WATCHPOINT_ERRNO(errno); | 343 | return MEMCACHED_ERRNO; |
636 | 255 | ptr->cached_errno= errno; | ||
637 | 256 | return MEMCACHED_ERRNO; | ||
638 | 257 | } | ||
649 | 258 | } | 344 | } |
650 | 259 | } | 345 | } |
651 | 260 | 346 | ||
652 | @@ -265,134 +351,78 @@ | |||
653 | 265 | 351 | ||
654 | 266 | static memcached_return_t network_connect(memcached_server_st *ptr) | 352 | static memcached_return_t network_connect(memcached_server_st *ptr) |
655 | 267 | { | 353 | { |
664 | 268 | if (ptr->fd == -1) | 354 | bool timeout_error_occured= false; |
665 | 269 | { | 355 | |
666 | 270 | struct addrinfo *use; | 356 | |
667 | 271 | 357 | WATCHPOINT_ASSERT(ptr->fd == -1); | |
668 | 272 | WATCHPOINT_ASSERT(ptr->cursor_active == 0); | 358 | WATCHPOINT_ASSERT(ptr->cursor_active == 0); |
669 | 273 | 359 | ||
670 | 274 | if (! ptr->options.sockaddr_inited || | 360 | if (! ptr->options.sockaddr_inited || (!(ptr->root->flags.use_cache_lookups))) |
671 | 275 | (!(ptr->root->flags.use_cache_lookups))) | 361 | { |
672 | 362 | memcached_return_t rc; | ||
673 | 363 | |||
674 | 364 | rc= set_hostinfo(ptr); | ||
675 | 365 | if (rc != MEMCACHED_SUCCESS) | ||
676 | 366 | return rc; | ||
677 | 367 | ptr->options.sockaddr_inited= true; | ||
678 | 368 | } | ||
679 | 369 | |||
680 | 370 | struct addrinfo *use= ptr->address_info; | ||
681 | 371 | /* Create the socket */ | ||
682 | 372 | while (use != NULL) | ||
683 | 373 | { | ||
684 | 374 | /* Memcache server does not support IPV6 in udp mode, so skip if not ipv4 */ | ||
685 | 375 | if (ptr->type == MEMCACHED_CONNECTION_UDP && use->ai_family != AF_INET) | ||
686 | 376 | { | ||
687 | 377 | use= use->ai_next; | ||
688 | 378 | continue; | ||
689 | 379 | } | ||
690 | 380 | |||
691 | 381 | if ((ptr->fd= socket(use->ai_family, | ||
692 | 382 | use->ai_socktype, | ||
693 | 383 | use->ai_protocol)) < 0) | ||
694 | 384 | { | ||
695 | 385 | ptr->cached_errno= errno; | ||
696 | 386 | WATCHPOINT_ERRNO(errno); | ||
697 | 387 | return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE; | ||
698 | 388 | } | ||
699 | 389 | |||
700 | 390 | (void)set_socket_options(ptr); | ||
701 | 391 | |||
702 | 392 | /* connect to server */ | ||
703 | 393 | if ((connect(ptr->fd, use->ai_addr, use->ai_addrlen) > -1)) | ||
704 | 394 | { | ||
705 | 395 | break; // Success | ||
706 | 396 | } | ||
707 | 397 | |||
708 | 398 | /* An error occurred */ | ||
709 | 399 | ptr->cached_errno= errno; | ||
710 | 400 | if (errno == EINPROGRESS || /* nonblocking mode - first return, */ | ||
711 | 401 | errno == EALREADY) /* nonblocking mode - subsequent returns */ | ||
712 | 276 | { | 402 | { |
713 | 277 | memcached_return_t rc; | 403 | memcached_return_t rc; |
832 | 278 | 404 | rc= connect_poll(ptr); | |
833 | 279 | rc= set_hostinfo(ptr); | 405 | |
834 | 280 | if (rc != MEMCACHED_SUCCESS) | 406 | if (rc == MEMCACHED_TIMEOUT) |
835 | 281 | return rc; | 407 | timeout_error_occured= true; |
836 | 282 | ptr->options.sockaddr_inited= true; | 408 | |
837 | 283 | } | 409 | if (rc == MEMCACHED_SUCCESS) |
838 | 284 | 410 | break; | |
839 | 285 | use= ptr->address_info; | 411 | } |
840 | 286 | /* Create the socket */ | 412 | else if (errno == EISCONN) /* we are connected :-) */ |
841 | 287 | while (use != NULL) | 413 | { |
842 | 288 | { | 414 | break; |
843 | 289 | /* Memcache server does not support IPV6 in udp mode, so skip if not ipv4 */ | 415 | } |
844 | 290 | if (ptr->type == MEMCACHED_CONNECTION_UDP && use->ai_family != AF_INET) | 416 | else if (errno == EINTR) // Special case, we retry ai_addr |
845 | 291 | { | 417 | { |
846 | 292 | use= use->ai_next; | 418 | (void)close(ptr->fd); |
847 | 293 | continue; | 419 | ptr->fd= -1; |
848 | 294 | } | 420 | continue; |
849 | 295 | 421 | } | |
850 | 296 | if ((ptr->fd= socket(use->ai_family, | 422 | |
851 | 297 | use->ai_socktype, | 423 | (void)close(ptr->fd); |
852 | 298 | use->ai_protocol)) < 0) | 424 | ptr->fd= -1; |
853 | 299 | { | 425 | use= use->ai_next; |
736 | 300 | ptr->cached_errno= errno; | ||
737 | 301 | WATCHPOINT_ERRNO(errno); | ||
738 | 302 | return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE; | ||
739 | 303 | } | ||
740 | 304 | |||
741 | 305 | (void)set_socket_options(ptr); | ||
742 | 306 | |||
743 | 307 | /* connect to server */ | ||
744 | 308 | if ((connect(ptr->fd, use->ai_addr, use->ai_addrlen) == -1)) | ||
745 | 309 | { | ||
746 | 310 | ptr->cached_errno= errno; | ||
747 | 311 | if (errno == EINPROGRESS || /* nonblocking mode - first return, */ | ||
748 | 312 | errno == EALREADY) /* nonblocking mode - subsequent returns */ | ||
749 | 313 | { | ||
750 | 314 | struct pollfd fds[1]; | ||
751 | 315 | fds[0].fd = ptr->fd; | ||
752 | 316 | fds[0].events = POLLOUT; | ||
753 | 317 | |||
754 | 318 | int timeout= ptr->root->connect_timeout; | ||
755 | 319 | if (ptr->root->flags.no_block == true) | ||
756 | 320 | timeout= -1; | ||
757 | 321 | |||
758 | 322 | size_t loop_max= 5; | ||
759 | 323 | while (--loop_max) | ||
760 | 324 | { | ||
761 | 325 | int error= poll(fds, 1, timeout); | ||
762 | 326 | |||
763 | 327 | switch (error) | ||
764 | 328 | { | ||
765 | 329 | case 1: | ||
766 | 330 | loop_max= 1; | ||
767 | 331 | break; | ||
768 | 332 | case 0: | ||
769 | 333 | if (loop_max==1) | ||
770 | 334 | return MEMCACHED_TIMEOUT; | ||
771 | 335 | continue; | ||
772 | 336 | // A real error occurred and we need to completely bail | ||
773 | 337 | default: | ||
774 | 338 | WATCHPOINT_ERRNO(errno); | ||
775 | 339 | switch (errno) | ||
776 | 340 | { | ||
777 | 341 | #ifdef TARGET_OS_LINUX | ||
778 | 342 | case ERESTART: | ||
779 | 343 | #endif | ||
780 | 344 | case EINTR: | ||
781 | 345 | continue; | ||
782 | 346 | default: | ||
783 | 347 | if (fds[0].revents & POLLERR) | ||
784 | 348 | { | ||
785 | 349 | int err; | ||
786 | 350 | socklen_t len= sizeof (err); | ||
787 | 351 | (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len); | ||
788 | 352 | ptr->cached_errno= (err == 0) ? errno : err; | ||
789 | 353 | } | ||
790 | 354 | |||
791 | 355 | (void)close(ptr->fd); | ||
792 | 356 | ptr->fd= -1; | ||
793 | 357 | |||
794 | 358 | break; | ||
795 | 359 | } | ||
796 | 360 | } | ||
797 | 361 | } | ||
798 | 362 | } | ||
799 | 363 | else if (errno == EISCONN) /* we are connected :-) */ | ||
800 | 364 | { | ||
801 | 365 | break; | ||
802 | 366 | } | ||
803 | 367 | else if (errno != EINTR) | ||
804 | 368 | { | ||
805 | 369 | (void)close(ptr->fd); | ||
806 | 370 | ptr->fd= -1; | ||
807 | 371 | break; | ||
808 | 372 | } | ||
809 | 373 | } | ||
810 | 374 | |||
811 | 375 | #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT | ||
812 | 376 | if (ptr->fd != -1 && ptr->root->sasl && ptr->root->sasl->callbacks) | ||
813 | 377 | { | ||
814 | 378 | memcached_return rc= memcached_sasl_authenticate_connection(ptr); | ||
815 | 379 | if (rc != MEMCACHED_SUCCESS) | ||
816 | 380 | { | ||
817 | 381 | (void)close(ptr->fd); | ||
818 | 382 | ptr->fd= -1; | ||
819 | 383 | |||
820 | 384 | return rc; | ||
821 | 385 | } | ||
822 | 386 | } | ||
823 | 387 | #endif | ||
824 | 388 | |||
825 | 389 | |||
826 | 390 | if (ptr->fd != -1) | ||
827 | 391 | { | ||
828 | 392 | return MEMCACHED_SUCCESS; | ||
829 | 393 | } | ||
830 | 394 | use = use->ai_next; | ||
831 | 395 | } | ||
854 | 396 | } | 426 | } |
855 | 397 | 427 | ||
856 | 398 | if (ptr->fd == -1) | 428 | if (ptr->fd == -1) |
857 | @@ -408,7 +438,7 @@ | |||
858 | 408 | ptr->next_retry= next_time.tv_sec + ptr->root->retry_timeout; | 438 | ptr->next_retry= next_time.tv_sec + ptr->root->retry_timeout; |
859 | 409 | } | 439 | } |
860 | 410 | 440 | ||
862 | 411 | if (ptr->cached_errno == 0) | 441 | if (timeout_error_occured) |
863 | 412 | return MEMCACHED_TIMEOUT; | 442 | return MEMCACHED_TIMEOUT; |
864 | 413 | 443 | ||
865 | 414 | return MEMCACHED_ERRNO; /* The last error should be from connect() */ | 444 | return MEMCACHED_ERRNO; /* The last error should be from connect() */ |
866 | @@ -435,6 +465,10 @@ | |||
867 | 435 | memcached_return_t memcached_connect(memcached_server_write_instance_st ptr) | 465 | memcached_return_t memcached_connect(memcached_server_write_instance_st ptr) |
868 | 436 | { | 466 | { |
869 | 437 | memcached_return_t rc= MEMCACHED_NO_SERVERS; | 467 | memcached_return_t rc= MEMCACHED_NO_SERVERS; |
870 | 468 | |||
871 | 469 | if (ptr->fd > -1) | ||
872 | 470 | return MEMCACHED_SUCCESS; | ||
873 | 471 | |||
874 | 438 | LIBMEMCACHED_MEMCACHED_CONNECT_START(); | 472 | LIBMEMCACHED_MEMCACHED_CONNECT_START(); |
875 | 439 | 473 | ||
876 | 440 | /* both retry_timeout and server_failure_limit must be set in order to delay retrying a server on error. */ | 474 | /* 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 | 481 | case MEMCACHED_CONNECTION_UDP: | 515 | case MEMCACHED_CONNECTION_UDP: |
879 | 482 | case MEMCACHED_CONNECTION_TCP: | 516 | case MEMCACHED_CONNECTION_TCP: |
880 | 483 | rc= network_connect(ptr); | 517 | rc= network_connect(ptr); |
881 | 518 | #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT | ||
882 | 519 | if (ptr->fd != -1 && ptr->root->sasl && ptr->root->sasl->callbacks) | ||
883 | 520 | { | ||
884 | 521 | rc= memcached_sasl_authenticate_connection(ptr); | ||
885 | 522 | if (rc != MEMCACHED_SUCCESS) | ||
886 | 523 | { | ||
887 | 524 | (void)close(ptr->fd); | ||
888 | 525 | ptr->fd= -1; | ||
889 | 526 | } | ||
890 | 527 | } | ||
891 | 528 | #endif | ||
892 | 484 | break; | 529 | break; |
893 | 485 | case MEMCACHED_CONNECTION_UNIX_SOCKET: | 530 | case MEMCACHED_CONNECTION_UNIX_SOCKET: |
894 | 486 | rc= unix_socket_connect(ptr); | 531 | rc= unix_socket_connect(ptr); |
895 | 487 | 532 | ||
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 | 45 | 45 | ||
901 | 46 | if (ptr->flags.binary_protocol) | 46 | if (ptr->flags.binary_protocol) |
902 | 47 | { | 47 | { |
904 | 48 | likely (!expiration) | 48 | likely (! expiration) |
905 | 49 | { | 49 | { |
906 | 50 | rc= binary_delete(ptr, server_key, key, key_length, to_write); | 50 | rc= binary_delete(ptr, server_key, key, key_length, to_write); |
907 | 51 | } | 51 | } |
908 | 52 | 52 | ||
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 | 65 | libmemcached/protocol/pedantic.c \ | 65 | libmemcached/protocol/pedantic.c \ |
914 | 66 | libmemcached/protocol/protocol_handler.c | 66 | libmemcached/protocol/protocol_handler.c |
915 | 67 | 67 | ||
917 | 68 | libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS} -version-info 0:0:0 | 68 | libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_PROTOCAL_LIBRARY_VERSION} |
918 | 69 | 69 | ||
919 | 70 | noinst_LTLIBRARIES+= \ | 70 | noinst_LTLIBRARIES+= \ |
920 | 71 | libmemcached/libmemcachedcallbacks.la | 71 | libmemcached/libmemcachedcallbacks.la |
921 | @@ -133,7 +133,7 @@ | |||
922 | 133 | libmemcached/util/pool.c \ | 133 | libmemcached/util/pool.c \ |
923 | 134 | libmemcached/util/version.c | 134 | libmemcached/util/version.c |
924 | 135 | libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la | 135 | libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la |
926 | 136 | libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info 0:0:0 | 136 | libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION} |
927 | 137 | libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la | 137 | libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la |
928 | 138 | 138 | ||
929 | 139 | if BUILD_BYTEORDER | 139 | if BUILD_BYTEORDER |
930 | @@ -158,6 +158,7 @@ | |||
931 | 158 | if DTRACE_NEEDS_OBJECTS | 158 | if DTRACE_NEEDS_OBJECTS |
932 | 159 | libmemcached_libmemcached_la_SOURCES += libmemcached/libmemcached_probes.d | 159 | libmemcached_libmemcached_la_SOURCES += libmemcached/libmemcached_probes.d |
933 | 160 | libmemcached_libmemcached_la_DEPENDENCIES += libmemcached/libmemcached_probes.o | 160 | libmemcached_libmemcached_la_DEPENDENCIES += libmemcached/libmemcached_probes.o |
934 | 161 | CLEANFILES+= libmemcached/libmemcached_probes.o | ||
935 | 161 | endif | 162 | endif |
936 | 162 | 163 | ||
937 | 163 | SUFFIXES+= .d | 164 | SUFFIXES+= .d |
938 | @@ -165,7 +166,7 @@ | |||
939 | 165 | libmemcached/dtrace_probes.h: libmemcached/libmemcached_probes.d | 166 | libmemcached/dtrace_probes.h: libmemcached/libmemcached_probes.d |
940 | 166 | $(DTRACE) $(DTRACEFLAGS) -h -o libmemcached/dtrace_probes.h -s ${top_srcdir}/libmemcached/libmemcached_probes.d | 167 | $(DTRACE) $(DTRACEFLAGS) -h -o libmemcached/dtrace_probes.h -s ${top_srcdir}/libmemcached/libmemcached_probes.d |
941 | 167 | 168 | ||
943 | 168 | libmemcached/libmemcached_probes.o: libmemcached/libmemcached_probes.d ${libmemcached_libmemcached_OBJECTS} config.h | 169 | libmemcached/libmemcached_probes.o: libmemcached/libmemcached_probes.d ${libmemcached_libmemcached_la_OBJECTS} config.h |
944 | 169 | 170 | ||
945 | 170 | .d.o: | 171 | .d.o: |
946 | 171 | $(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}\//"` | 172 | $(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 | 172 | 173 | ||
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 | 62 | timeout= -1; | 62 | timeout= -1; |
953 | 63 | 63 | ||
954 | 64 | size_t loop_max= 5; | 64 | size_t loop_max= 5; |
956 | 65 | while (--loop_max) | 65 | while (--loop_max) // While loop is for ERESTART or EINTR |
957 | 66 | { | 66 | { |
958 | 67 | error= poll(&fds, 1, timeout); | 67 | error= poll(&fds, 1, timeout); |
959 | 68 | 68 | ||
960 | 69 | switch (error) | 69 | switch (error) |
961 | 70 | { | 70 | { |
963 | 71 | case 1: | 71 | case 1: // Success! |
964 | 72 | WATCHPOINT_IF_LABELED_NUMBER(read_or_write && loop_max < 4, "read() times we had to loop, decremented down from 5", loop_max); | 72 | WATCHPOINT_IF_LABELED_NUMBER(read_or_write && loop_max < 4, "read() times we had to loop, decremented down from 5", loop_max); |
965 | 73 | WATCHPOINT_IF_LABELED_NUMBER(!read_or_write && loop_max < 4, "write() times we had to loop, decremented down from 5", loop_max); | 73 | WATCHPOINT_IF_LABELED_NUMBER(!read_or_write && loop_max < 4, "write() times we had to loop, decremented down from 5", loop_max); |
966 | 74 | 74 | ||
967 | 75 | return MEMCACHED_SUCCESS; | 75 | return MEMCACHED_SUCCESS; |
969 | 76 | case 0: | 76 | case 0: // Timeout occured, we let the while() loop do its thing. |
970 | 77 | return MEMCACHED_TIMEOUT; | 77 | return MEMCACHED_TIMEOUT; |
971 | 78 | default: | 78 | default: |
972 | 79 | WATCHPOINT_ERRNO(errno); | 79 | WATCHPOINT_ERRNO(errno); |
973 | 80 | switch (errno) | ||
974 | 80 | { | 81 | { |
975 | 81 | switch (errno) | ||
976 | 82 | { | ||
977 | 83 | #ifdef TARGET_OS_LINUX | 82 | #ifdef TARGET_OS_LINUX |
979 | 84 | case ERESTART: | 83 | case ERESTART: |
980 | 85 | #endif | 84 | #endif |
986 | 86 | case EINTR: | 85 | case EINTR: |
987 | 87 | continue; | 86 | break; |
988 | 88 | default: | 87 | default: |
989 | 89 | ptr->cached_errno= error; | 88 | if (fds.revents & POLLERR) |
990 | 90 | memcached_quit_server(ptr, true); | 89 | { |
991 | 90 | int err; | ||
992 | 91 | socklen_t len= sizeof (err); | ||
993 | 92 | (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len); | ||
994 | 93 | ptr->cached_errno= (err == 0) ? errno : err; | ||
995 | 94 | } | ||
996 | 95 | else | ||
997 | 96 | { | ||
998 | 97 | ptr->cached_errno= errno; | ||
999 | 98 | } | ||
1000 | 99 | memcached_quit_server(ptr, true); | ||
1001 | 91 | 100 | ||
1004 | 92 | return MEMCACHED_FAILURE; | 101 | return MEMCACHED_FAILURE; |
1003 | 93 | } | ||
1005 | 94 | } | 102 | } |
1006 | 95 | } | 103 | } |
1007 | 96 | } | 104 | } |
1008 | 97 | 105 | ||
1009 | 98 | if (loop_max == 0 && error == 0) | ||
1010 | 99 | return MEMCACHED_TIMEOUT; | ||
1011 | 100 | |||
1012 | 101 | /* Imposssible for anything other then -1 */ | 106 | /* Imposssible for anything other then -1 */ |
1013 | 102 | WATCHPOINT_ASSERT(error == -1); | 107 | WATCHPOINT_ASSERT(error == -1); |
1015 | 103 | ptr->cached_errno= error; | 108 | ptr->cached_errno= errno; |
1016 | 104 | memcached_quit_server(ptr, true); | 109 | memcached_quit_server(ptr, true); |
1017 | 105 | 110 | ||
1018 | 106 | return MEMCACHED_FAILURE; | 111 | return MEMCACHED_FAILURE; |
1019 | 107 | 112 | ||
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 | 61 | * compatibility. | 61 | * compatibility. |
1025 | 62 | */ | 62 | */ |
1026 | 63 | if (ptr->root->flags.binary_protocol == false) | 63 | if (ptr->root->flags.binary_protocol == false) |
1027 | 64 | { | ||
1028 | 64 | while (memcached_server_response_count(ptr) > 1) | 65 | while (memcached_server_response_count(ptr) > 1) |
1029 | 65 | { | 66 | { |
1030 | 66 | memcached_return_t rc= memcached_read_one_response(ptr, buffer, buffer_length, result); | 67 | memcached_return_t rc= memcached_read_one_response(ptr, buffer, buffer_length, result); |
1031 | @@ -75,6 +76,7 @@ | |||
1032 | 75 | rc != MEMCACHED_DATA_EXISTS) | 76 | rc != MEMCACHED_DATA_EXISTS) |
1033 | 76 | return rc; | 77 | return rc; |
1034 | 77 | } | 78 | } |
1035 | 79 | } | ||
1036 | 78 | 80 | ||
1037 | 79 | return memcached_read_one_response(ptr, buffer, buffer_length, result); | 81 | return memcached_read_one_response(ptr, buffer, buffer_length, result); |
1038 | 80 | } | 82 | } |
1039 | 81 | 83 | ||
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 | 172 | return MEMCACHED_SUCCESS; | 172 | return MEMCACHED_SUCCESS; |
1045 | 173 | } | 173 | } |
1046 | 174 | 174 | ||
1047 | 175 | memcached_return_t memcached_server_execute(memcached_st *ptr, | ||
1048 | 176 | memcached_server_execute_fn callback, | ||
1049 | 177 | void *context) | ||
1050 | 178 | { | ||
1051 | 179 | for (uint32_t x= 0; x < memcached_server_count(ptr); x++) | ||
1052 | 180 | { | ||
1053 | 181 | memcached_server_write_instance_st instance= | ||
1054 | 182 | memcached_server_instance_fetch(ptr, x); | ||
1055 | 183 | |||
1056 | 184 | unsigned int iferror; | ||
1057 | 185 | |||
1058 | 186 | iferror= (*callback)(ptr, instance, context); | ||
1059 | 187 | |||
1060 | 188 | if (iferror) | ||
1061 | 189 | continue; | ||
1062 | 190 | } | ||
1063 | 191 | |||
1064 | 192 | return MEMCACHED_SUCCESS; | ||
1065 | 193 | } | ||
1066 | 194 | |||
1067 | 175 | memcached_server_instance_st memcached_server_by_key(const memcached_st *ptr, | 195 | memcached_server_instance_st memcached_server_by_key(const memcached_st *ptr, |
1068 | 176 | const char *key, | 196 | const char *key, |
1069 | 177 | size_t key_length, | 197 | size_t key_length, |
1070 | 178 | 198 | ||
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 | 29 | NULL | 29 | NULL |
1076 | 30 | }; | 30 | }; |
1077 | 31 | 31 | ||
1078 | 32 | struct local_context | ||
1079 | 33 | { | ||
1080 | 34 | memcached_stat_fn func; | ||
1081 | 35 | void *context; | ||
1082 | 36 | const char *args; | ||
1083 | 37 | }; | ||
1084 | 38 | |||
1085 | 32 | 39 | ||
1086 | 33 | static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char *value) | 40 | static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char *value) |
1087 | 34 | { | 41 | { |
1088 | @@ -228,8 +235,9 @@ | |||
1089 | 228 | } | 235 | } |
1090 | 229 | 236 | ||
1091 | 230 | static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, | 237 | static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, |
1094 | 231 | char *args, | 238 | const char *args, |
1095 | 232 | memcached_server_write_instance_st instance) | 239 | memcached_server_write_instance_st instance, |
1096 | 240 | struct local_context *check) | ||
1097 | 233 | { | 241 | { |
1098 | 234 | memcached_return_t rc; | 242 | memcached_return_t rc; |
1099 | 235 | 243 | ||
1100 | @@ -286,10 +294,23 @@ | |||
1101 | 286 | return rc; | 294 | return rc; |
1102 | 287 | } | 295 | } |
1103 | 288 | 296 | ||
1108 | 289 | unlikely((set_data(memc_stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY) | 297 | if (memc_stat) |
1109 | 290 | { | 298 | { |
1110 | 291 | WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); | 299 | unlikely((set_data(memc_stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY) |
1111 | 292 | WATCHPOINT_ASSERT(0); | 300 | { |
1112 | 301 | WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); | ||
1113 | 302 | WATCHPOINT_ASSERT(0); | ||
1114 | 303 | } | ||
1115 | 304 | } | ||
1116 | 305 | |||
1117 | 306 | if (check && check->func) | ||
1118 | 307 | { | ||
1119 | 308 | size_t key_length= strlen(buffer); | ||
1120 | 309 | |||
1121 | 310 | check->func(instance, | ||
1122 | 311 | buffer, key_length, | ||
1123 | 312 | buffer+key_length+1, strlen(buffer+key_length+1), | ||
1124 | 313 | check->context); | ||
1125 | 293 | } | 314 | } |
1126 | 294 | } while (1); | 315 | } while (1); |
1127 | 295 | 316 | ||
1128 | @@ -302,8 +323,9 @@ | |||
1129 | 302 | } | 323 | } |
1130 | 303 | 324 | ||
1131 | 304 | static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat, | 325 | static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat, |
1134 | 305 | char *args, | 326 | const char *args, |
1135 | 306 | memcached_server_write_instance_st instance) | 327 | memcached_server_write_instance_st instance, |
1136 | 328 | struct local_context *check) | ||
1137 | 307 | { | 329 | { |
1138 | 308 | memcached_return_t rc; | 330 | memcached_return_t rc; |
1139 | 309 | char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; | 331 | char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; |
1140 | @@ -343,10 +365,21 @@ | |||
1141 | 343 | value= string_ptr; | 365 | value= string_ptr; |
1142 | 344 | value[(size_t)(end_ptr-string_ptr)]= 0; | 366 | value[(size_t)(end_ptr-string_ptr)]= 0; |
1143 | 345 | string_ptr= end_ptr + 2; | 367 | string_ptr= end_ptr + 2; |
1148 | 346 | unlikely((set_data(memc_stat, key, value)) == MEMCACHED_UNKNOWN_STAT_KEY) | 368 | if (memc_stat) |
1149 | 347 | { | 369 | { |
1150 | 348 | WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); | 370 | unlikely((set_data(memc_stat, key, value)) == MEMCACHED_UNKNOWN_STAT_KEY) |
1151 | 349 | WATCHPOINT_ASSERT(0); | 371 | { |
1152 | 372 | WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); | ||
1153 | 373 | WATCHPOINT_ASSERT(0); | ||
1154 | 374 | } | ||
1155 | 375 | } | ||
1156 | 376 | |||
1157 | 377 | if (check && check->func) | ||
1158 | 378 | { | ||
1159 | 379 | check->func(instance, | ||
1160 | 380 | key, strlen(key), | ||
1161 | 381 | value, strlen(value), | ||
1162 | 382 | check->context); | ||
1163 | 350 | } | 383 | } |
1164 | 351 | } | 384 | } |
1165 | 352 | else | 385 | else |
1166 | @@ -394,11 +427,11 @@ | |||
1167 | 394 | 427 | ||
1168 | 395 | if (ptr->flags.binary_protocol) | 428 | if (ptr->flags.binary_protocol) |
1169 | 396 | { | 429 | { |
1171 | 397 | temp_return= binary_stats_fetch(stat_instance, args, instance); | 430 | temp_return= binary_stats_fetch(stat_instance, args, instance, NULL); |
1172 | 398 | } | 431 | } |
1173 | 399 | else | 432 | else |
1174 | 400 | { | 433 | { |
1176 | 401 | temp_return= ascii_stats_fetch(stat_instance, args, instance); | 434 | temp_return= ascii_stats_fetch(stat_instance, args, instance, NULL); |
1177 | 402 | } | 435 | } |
1178 | 403 | 436 | ||
1179 | 404 | if (temp_return != MEMCACHED_SUCCESS) | 437 | if (temp_return != MEMCACHED_SUCCESS) |
1180 | @@ -428,11 +461,11 @@ | |||
1181 | 428 | 461 | ||
1182 | 429 | if (memc.flags.binary_protocol) | 462 | if (memc.flags.binary_protocol) |
1183 | 430 | { | 463 | { |
1185 | 431 | rc= binary_stats_fetch(memc_stat, args, instance); | 464 | rc= binary_stats_fetch(memc_stat, args, instance, NULL); |
1186 | 432 | } | 465 | } |
1187 | 433 | else | 466 | else |
1188 | 434 | { | 467 | { |
1190 | 435 | rc= ascii_stats_fetch(memc_stat, args, instance); | 468 | rc= ascii_stats_fetch(memc_stat, args, instance, NULL); |
1191 | 436 | } | 469 | } |
1192 | 437 | 470 | ||
1193 | 438 | memcached_free(&memc); | 471 | memcached_free(&memc); |
1194 | @@ -489,3 +522,31 @@ | |||
1195 | 489 | free(memc_stat); | 522 | free(memc_stat); |
1196 | 490 | } | 523 | } |
1197 | 491 | } | 524 | } |
1198 | 525 | |||
1199 | 526 | static memcached_return_t call_stat_fn(memcached_st *ptr, | ||
1200 | 527 | memcached_server_write_instance_st instance, | ||
1201 | 528 | void *context) | ||
1202 | 529 | { | ||
1203 | 530 | memcached_return_t rc; | ||
1204 | 531 | struct local_context *check= (struct local_context *)context; | ||
1205 | 532 | |||
1206 | 533 | if (ptr->flags.binary_protocol) | ||
1207 | 534 | { | ||
1208 | 535 | rc= binary_stats_fetch(NULL, check->args, instance, check); | ||
1209 | 536 | } | ||
1210 | 537 | else | ||
1211 | 538 | { | ||
1212 | 539 | rc= ascii_stats_fetch(NULL, check->args, instance, check); | ||
1213 | 540 | } | ||
1214 | 541 | |||
1215 | 542 | return rc; | ||
1216 | 543 | } | ||
1217 | 544 | |||
1218 | 545 | memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context) | ||
1219 | 546 | { | ||
1220 | 547 | memcached_version(memc); | ||
1221 | 548 | |||
1222 | 549 | struct local_context check= { .func= func, .context= context, .args= args }; | ||
1223 | 550 | |||
1224 | 551 | return memcached_server_execute(memc, call_stat_fn, (void *)&check); | ||
1225 | 552 | } | ||
1226 | 492 | 553 | ||
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 | 62 | char ** memcached_stat_get_keys(const memcached_st *ptr, memcached_stat_st *memc_stat, | 62 | char ** memcached_stat_get_keys(const memcached_st *ptr, memcached_stat_st *memc_stat, |
1232 | 63 | memcached_return_t *error); | 63 | memcached_return_t *error); |
1233 | 64 | 64 | ||
1234 | 65 | LIBMEMCACHED_API | ||
1235 | 66 | memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context); | ||
1236 | 67 | |||
1237 | 65 | #ifdef __cplusplus | 68 | #ifdef __cplusplus |
1238 | 66 | } // extern "C" | 69 | } // extern "C" |
1239 | 67 | #endif | 70 | #endif |
1240 | 68 | 71 | ||
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 | 47 | 47 | ||
1246 | 48 | typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context); | 48 | typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context); |
1247 | 49 | typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context); | 49 | typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context); |
1248 | 50 | typedef memcached_return_t (*memcached_stat_fn)(memcached_server_instance_st server, | ||
1249 | 51 | const char *key, size_t key_length, | ||
1250 | 52 | const char *value, size_t value_length, | ||
1251 | 53 | void *context); | ||
1252 | 50 | 54 | ||
1253 | 51 | /** | 55 | /** |
1254 | 52 | Trigger functions. | 56 | Trigger functions. |
1255 | 53 | 57 | ||
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 | 16 | struct local_context | 16 | struct local_context |
1261 | 17 | { | 17 | { |
1262 | 18 | uint8_t major_version; | 18 | uint8_t major_version; |
1263 | 19 | uint8_t minor_version; | ||
1264 | 19 | uint8_t micro_version; | 20 | uint8_t micro_version; |
1265 | 20 | uint8_t minor_version; | ||
1266 | 21 | 21 | ||
1267 | 22 | bool truth; | 22 | bool truth; |
1268 | 23 | }; | 23 | }; |
1269 | @@ -30,8 +30,8 @@ | |||
1270 | 30 | struct local_context *check= (struct local_context *)context; | 30 | struct local_context *check= (struct local_context *)context; |
1271 | 31 | 31 | ||
1272 | 32 | if (instance->major_version >= check->major_version && | 32 | if (instance->major_version >= check->major_version && |
1275 | 33 | instance->micro_version >= check->micro_version && | 33 | instance->minor_version >= check->minor_version && |
1276 | 34 | instance->minor_version >= check->minor_version) | 34 | instance->micro_version >= check->micro_version ) |
1277 | 35 | { | 35 | { |
1278 | 36 | return MEMCACHED_SUCCESS; | 36 | return MEMCACHED_SUCCESS; |
1279 | 37 | } | 37 | } |
1280 | @@ -43,13 +43,14 @@ | |||
1281 | 43 | 43 | ||
1282 | 44 | bool libmemcached_util_version_check(memcached_st *memc, | 44 | bool libmemcached_util_version_check(memcached_st *memc, |
1283 | 45 | uint8_t major_version, | 45 | uint8_t major_version, |
1286 | 46 | uint8_t micro_version, | 46 | uint8_t minor_version, |
1287 | 47 | uint8_t minor_version) | 47 | uint8_t micro_version) |
1288 | 48 | { | 48 | { |
1289 | 49 | memcached_server_fn callbacks[1]; | 49 | memcached_server_fn callbacks[1]; |
1290 | 50 | memcached_version(memc); | 50 | memcached_version(memc); |
1291 | 51 | 51 | ||
1293 | 52 | struct local_context check= { .major_version= major_version, .micro_version= micro_version, .minor_version= minor_version, .truth= true }; | 52 | struct local_context check= { .major_version= major_version, .minor_version= minor_version, .micro_version= micro_version, .truth= true }; |
1294 | 53 | memcached_version(memc); | ||
1295 | 53 | 54 | ||
1296 | 54 | callbacks[0]= check_server_version; | 55 | callbacks[0]= check_server_version; |
1297 | 55 | memcached_server_cursor(memc, callbacks, (void *)&check, 1); | 56 | memcached_server_cursor(memc, callbacks, (void *)&check, 1); |
1298 | 56 | 57 | ||
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 | 19 | LIBMEMCACHED_API | 19 | LIBMEMCACHED_API |
1304 | 20 | bool libmemcached_util_version_check(memcached_st *memc, | 20 | bool libmemcached_util_version_check(memcached_st *memc, |
1305 | 21 | uint8_t major_version, | 21 | uint8_t major_version, |
1308 | 22 | uint8_t micro_version, | 22 | uint8_t minor_version, |
1309 | 23 | uint8_t minor_version); | 23 | uint8_t micro_version); |
1310 | 24 | 24 | ||
1311 | 25 | #ifdef __cplusplus | 25 | #ifdef __cplusplus |
1312 | 26 | } | 26 | } |
1313 | 27 | 27 | ||
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 | 13 | if (ptr->flags.use_udp) | 13 | if (ptr->flags.use_udp) |
1319 | 14 | return MEMCACHED_NOT_SUPPORTED; | 14 | return MEMCACHED_NOT_SUPPORTED; |
1320 | 15 | 15 | ||
1321 | 16 | bool was_blocking= ptr->flags.no_block; | ||
1322 | 17 | memcached_return_t rc; | ||
1323 | 18 | |||
1324 | 19 | ptr->flags.no_block= false; | ||
1325 | 20 | |||
1326 | 16 | if (ptr->flags.binary_protocol) | 21 | if (ptr->flags.binary_protocol) |
1328 | 17 | return memcached_version_binary(ptr); | 22 | rc= memcached_version_binary(ptr); |
1329 | 18 | else | 23 | else |
1331 | 19 | return memcached_version_textual(ptr); | 24 | rc= memcached_version_textual(ptr); |
1332 | 25 | |||
1333 | 26 | ptr->flags.no_block= was_blocking; | ||
1334 | 27 | |||
1335 | 28 | return rc; | ||
1336 | 20 | } | 29 | } |
1337 | 21 | 30 | ||
1338 | 22 | static inline memcached_return_t memcached_version_textual(memcached_st *ptr) | 31 | static inline memcached_return_t memcached_version_textual(memcached_st *ptr) |
1339 | 23 | 32 | ||
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 | 145 | m4_if(PW_LESS_WARNINGS,[no],[ | 145 | m4_if(PW_LESS_WARNINGS,[no],[ |
1345 | 146 | BASE_WARNINGS_FULL="-Wformat=2 ${W_CONVERSION} -Wstrict-aliasing" | 146 | BASE_WARNINGS_FULL="-Wformat=2 ${W_CONVERSION} -Wstrict-aliasing" |
1346 | 147 | CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings" | 147 | CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings" |
1348 | 148 | CXX_WARNINGS_FULL="-Weffc++ -Wold-style-cast" | 148 | CXX_WARNINGS_FULL="-Wold-style-cast" |
1349 | 149 | NO_OLD_STYLE_CAST="-Wno-old-style-cast" | 149 | NO_OLD_STYLE_CAST="-Wno-old-style-cast" |
1350 | 150 | NO_EFF_CXX="-Wno-effc++" | 150 | NO_EFF_CXX="-Wno-effc++" |
1351 | 151 | ],[ | 151 | ],[ |
1352 | 152 | 152 | ||
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 | 82 | %exclude %{_libdir}/libhashkit.la | 82 | %exclude %{_libdir}/libhashkit.la |
1358 | 83 | %exclude %{_libdir}/libmemcachedutil.la | 83 | %exclude %{_libdir}/libmemcachedutil.la |
1359 | 84 | %exclude %{_libdir}/libmemcachedprotocol.la | 84 | %exclude %{_libdir}/libmemcachedprotocol.la |
1364 | 85 | %{_libdir}/libhashkit.so.* | 85 | %{_libdir}/libhashkit.so.0.0.0 |
1365 | 86 | %{_libdir}/libmemcached.so.* | 86 | %{_libdir}/libmemcached.so.5.0.1 |
1366 | 87 | %{_libdir}/libmemcachedutil.so.* | 87 | %{_libdir}/libmemcachedutil.so.1.0.0 |
1367 | 88 | %{_libdir}/libmemcachedprotocol.so.* | 88 | %{_libdir}/libmemcachedprotocol.so.0.0.0 |
1368 | 89 | %{_libdir}/libhashkit.so.0 | ||
1369 | 90 | %{_libdir}/libmemcached.so.5 | ||
1370 | 91 | %{_libdir}/libmemcachedprotocol.so.0 | ||
1371 | 92 | %{_libdir}/libmemcachedutil.so.1 | ||
1372 | 89 | %{_mandir}/man1/memcapable.1.gz | 93 | %{_mandir}/man1/memcapable.1.gz |
1373 | 90 | %{_mandir}/man1/memcat.1.gz | 94 | %{_mandir}/man1/memcat.1.gz |
1374 | 91 | %{_mandir}/man1/memcp.1.gz | 95 | %{_mandir}/man1/memcp.1.gz |
1375 | @@ -104,14 +108,6 @@ | |||
1376 | 104 | %{_includedir}/libmemcached/delete.h | 108 | %{_includedir}/libmemcached/delete.h |
1377 | 105 | %{_includedir}/libmemcached/fetch.h | 109 | %{_includedir}/libmemcached/fetch.h |
1378 | 106 | %{_includedir}/libmemcached/flush.h | 110 | %{_includedir}/libmemcached/flush.h |
1379 | 107 | %{_includedir}/libmemcached/flush_buffers.h | ||
1380 | 108 | %{_includedir}/libmemcached/hash.h | ||
1381 | 109 | %{_includedir}/libmemcached/parse.h | ||
1382 | 110 | %{_includedir}/libmemcached/quit.h | ||
1383 | 111 | %{_includedir}/libmemcached/sasl.h | ||
1384 | 112 | %{_includedir}/libmemcached/strerror.h | ||
1385 | 113 | %{_includedir}/libmemcached/verbosity.h | ||
1386 | 114 | %{_includedir}/libmemcached/version.h | ||
1387 | 115 | %{_includedir}/libhashkit/algorithm.h | 111 | %{_includedir}/libhashkit/algorithm.h |
1388 | 116 | %{_includedir}/libhashkit/behavior.h | 112 | %{_includedir}/libhashkit/behavior.h |
1389 | 117 | %{_includedir}/libhashkit/configure.h | 113 | %{_includedir}/libhashkit/configure.h |
1390 | @@ -129,21 +125,32 @@ | |||
1391 | 129 | %{_includedir}/libmemcached/constants.h | 125 | %{_includedir}/libmemcached/constants.h |
1392 | 130 | %{_includedir}/libmemcached/dump.h | 126 | %{_includedir}/libmemcached/dump.h |
1393 | 131 | %{_includedir}/libmemcached/exception.hpp | 127 | %{_includedir}/libmemcached/exception.hpp |
1394 | 128 | %{_includedir}/libmemcached/flush_buffers.h | ||
1395 | 132 | %{_includedir}/libmemcached/get.h | 129 | %{_includedir}/libmemcached/get.h |
1396 | 130 | %{_includedir}/libmemcached/hash.h | ||
1397 | 133 | %{_includedir}/libmemcached/memcached.h | 131 | %{_includedir}/libmemcached/memcached.h |
1398 | 134 | %{_includedir}/libmemcached/memcached.hpp | 132 | %{_includedir}/libmemcached/memcached.hpp |
1399 | 135 | %{_includedir}/libmemcached/memcached_util.h | 133 | %{_includedir}/libmemcached/memcached_util.h |
1400 | 134 | %{_includedir}/libmemcached/parse.h | ||
1401 | 136 | %{_includedir}/libmemcached/protocol/cache.h | 135 | %{_includedir}/libmemcached/protocol/cache.h |
1402 | 137 | %{_includedir}/libmemcached/protocol/callback.h | 136 | %{_includedir}/libmemcached/protocol/callback.h |
1403 | 138 | %{_includedir}/libmemcached/protocol_handler.h | 137 | %{_includedir}/libmemcached/protocol_handler.h |
1404 | 138 | %{_includedir}/libmemcached/quit.h | ||
1405 | 139 | %{_includedir}/libmemcached/result.h | 139 | %{_includedir}/libmemcached/result.h |
1406 | 140 | %{_includedir}/libmemcached/sasl.h | ||
1407 | 140 | %{_includedir}/libmemcached/server.h | 141 | %{_includedir}/libmemcached/server.h |
1408 | 141 | %{_includedir}/libmemcached/server_list.h | 142 | %{_includedir}/libmemcached/server_list.h |
1409 | 142 | %{_includedir}/libmemcached/stats.h | 143 | %{_includedir}/libmemcached/stats.h |
1410 | 143 | %{_includedir}/libmemcached/storage.h | 144 | %{_includedir}/libmemcached/storage.h |
1411 | 145 | %{_includedir}/libmemcached/strerror.h | ||
1412 | 144 | %{_includedir}/libmemcached/string.h | 146 | %{_includedir}/libmemcached/string.h |
1413 | 145 | %{_includedir}/libmemcached/types.h | 147 | %{_includedir}/libmemcached/types.h |
1414 | 148 | %{_includedir}/libmemcached/util.h | ||
1415 | 149 | %{_includedir}/libmemcached/util/ping.h | ||
1416 | 146 | %{_includedir}/libmemcached/util/pool.h | 150 | %{_includedir}/libmemcached/util/pool.h |
1417 | 151 | %{_includedir}/libmemcached/util/version.h | ||
1418 | 152 | %{_includedir}/libmemcached/verbosity.h | ||
1419 | 153 | %{_includedir}/libmemcached/version.h | ||
1420 | 147 | %{_includedir}/libmemcached/visibility.h | 154 | %{_includedir}/libmemcached/visibility.h |
1421 | 148 | %{_includedir}/libmemcached/watchpoint.h | 155 | %{_includedir}/libmemcached/watchpoint.h |
1422 | 149 | %{_includedir}/libmemcached/memcached/protocol_binary.h | 156 | %{_includedir}/libmemcached/memcached/protocol_binary.h |
1423 | @@ -187,6 +194,7 @@ | |||
1424 | 187 | %{_mandir}/man3/memcached_decrement_with_initial.3.gz | 194 | %{_mandir}/man3/memcached_decrement_with_initial.3.gz |
1425 | 188 | %{_mandir}/man3/memcached_delete.3.gz | 195 | %{_mandir}/man3/memcached_delete.3.gz |
1426 | 189 | %{_mandir}/man3/memcached_delete_by_key.3.gz | 196 | %{_mandir}/man3/memcached_delete_by_key.3.gz |
1427 | 197 | %{_mandir}/man3/memcached_destroy_sasl_auth_data.3.gz | ||
1428 | 190 | %{_mandir}/man3/memcached_dump.3.gz | 198 | %{_mandir}/man3/memcached_dump.3.gz |
1429 | 191 | %{_mandir}/man3/memcached_fetch.3.gz | 199 | %{_mandir}/man3/memcached_fetch.3.gz |
1430 | 192 | %{_mandir}/man3/memcached_fetch_execute.3.gz | 200 | %{_mandir}/man3/memcached_fetch_execute.3.gz |
1431 | @@ -197,6 +205,7 @@ | |||
1432 | 197 | %{_mandir}/man3/memcached_get.3.gz | 205 | %{_mandir}/man3/memcached_get.3.gz |
1433 | 198 | %{_mandir}/man3/memcached_get_by_key.3.gz | 206 | %{_mandir}/man3/memcached_get_by_key.3.gz |
1434 | 199 | %{_mandir}/man3/memcached_get_memory_allocators.3.gz | 207 | %{_mandir}/man3/memcached_get_memory_allocators.3.gz |
1435 | 208 | %{_mandir}/man3/memcached_get_sasl_callbacks.3.gz | ||
1436 | 200 | %{_mandir}/man3/memcached_get_user_data.3.gz | 209 | %{_mandir}/man3/memcached_get_user_data.3.gz |
1437 | 201 | %{_mandir}/man3/memcached_increment.3.gz | 210 | %{_mandir}/man3/memcached_increment.3.gz |
1438 | 202 | %{_mandir}/man3/memcached_increment_with_initial.3.gz | 211 | %{_mandir}/man3/memcached_increment_with_initial.3.gz |
1439 | @@ -216,6 +225,7 @@ | |||
1440 | 216 | %{_mandir}/man3/memcached_quit.3.gz | 225 | %{_mandir}/man3/memcached_quit.3.gz |
1441 | 217 | %{_mandir}/man3/memcached_replace.3.gz | 226 | %{_mandir}/man3/memcached_replace.3.gz |
1442 | 218 | %{_mandir}/man3/memcached_replace_by_key.3.gz | 227 | %{_mandir}/man3/memcached_replace_by_key.3.gz |
1443 | 228 | %{_mandir}/man3/memcached_sasl_set_auth_data.3.gz | ||
1444 | 219 | %{_mandir}/man3/memcached_server_add.3.gz | 229 | %{_mandir}/man3/memcached_server_add.3.gz |
1445 | 220 | %{_mandir}/man3/memcached_server_count.3.gz | 230 | %{_mandir}/man3/memcached_server_count.3.gz |
1446 | 221 | %{_mandir}/man3/memcached_server_cursor.3.gz | 231 | %{_mandir}/man3/memcached_server_cursor.3.gz |
1447 | @@ -228,6 +238,7 @@ | |||
1448 | 228 | %{_mandir}/man3/memcached_set.3.gz | 238 | %{_mandir}/man3/memcached_set.3.gz |
1449 | 229 | %{_mandir}/man3/memcached_set_by_key.3.gz | 239 | %{_mandir}/man3/memcached_set_by_key.3.gz |
1450 | 230 | %{_mandir}/man3/memcached_set_memory_allocators.3.gz | 240 | %{_mandir}/man3/memcached_set_memory_allocators.3.gz |
1451 | 241 | %{_mandir}/man3/memcached_set_sasl_callbacks.3.gz | ||
1452 | 231 | %{_mandir}/man3/memcached_set_user_data.3.gz | 242 | %{_mandir}/man3/memcached_set_user_data.3.gz |
1453 | 232 | %{_mandir}/man3/memcached_stat.3.gz | 243 | %{_mandir}/man3/memcached_stat.3.gz |
1454 | 233 | %{_mandir}/man3/memcached_stat_get_keys.3.gz | 244 | %{_mandir}/man3/memcached_stat_get_keys.3.gz |
1455 | 234 | 245 | ||
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 | 12 | /* | 12 | /* |
1461 | 13 | Sample test application. | 13 | Sample test application. |
1462 | 14 | */ | 14 | */ |
1464 | 15 | #include "libmemcached/common.h" | 15 | #include "config.h" |
1465 | 16 | |||
1466 | 17 | #include "libmemcached/memcached.h" | ||
1467 | 18 | #include "libmemcached/watchpoint.h" | ||
1468 | 16 | 19 | ||
1469 | 17 | #include <stdio.h> | 20 | #include <stdio.h> |
1470 | 18 | #include <stdlib.h> | 21 | #include <stdlib.h> |
1471 | 22 | #include <stdint.h> | ||
1472 | 19 | #include <string.h> | 23 | #include <string.h> |
1473 | 20 | #include <sys/time.h> | 24 | #include <sys/time.h> |
1474 | 21 | #include <sys/types.h> | 25 | #include <sys/types.h> |
1475 | @@ -26,14 +30,6 @@ | |||
1476 | 26 | #include "../clients/generator.h" | 30 | #include "../clients/generator.h" |
1477 | 27 | #include "../clients/execute.h" | 31 | #include "../clients/execute.h" |
1478 | 28 | 32 | ||
1479 | 29 | #ifndef INT64_MAX | ||
1480 | 30 | #define INT64_MAX LONG_MAX | ||
1481 | 31 | #endif | ||
1482 | 32 | #ifndef INT32_MAX | ||
1483 | 33 | #define INT32_MAX INT_MAX | ||
1484 | 34 | #endif | ||
1485 | 35 | |||
1486 | 36 | |||
1487 | 37 | #include "test.h" | 33 | #include "test.h" |
1488 | 38 | 34 | ||
1489 | 39 | /* Number of items generated for tests */ | 35 | /* Number of items generated for tests */ |
1490 | 40 | 36 | ||
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 | 6 | * the COPYING file in the parent directory for full text. | 6 | * the COPYING file in the parent directory for full text. |
1496 | 7 | */ | 7 | */ |
1497 | 8 | 8 | ||
1498 | 9 | #include "config.h" | ||
1499 | 10 | |||
1500 | 9 | #include <assert.h> | 11 | #include <assert.h> |
1501 | 10 | #include <stdio.h> | 12 | #include <stdio.h> |
1502 | 11 | #include <stdlib.h> | 13 | #include <stdlib.h> |
1503 | 12 | 14 | ||
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 | 4 | 4 | ||
1509 | 5 | TESTS_LDADDS = libmemcached/libmemcached.la | 5 | TESTS_LDADDS = libmemcached/libmemcached.la |
1510 | 6 | 6 | ||
1512 | 7 | VALGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --leak-check=yes --show-reachable=yes | 7 | VALGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --leak-check=yes --show-reachable=yes --track-fds=yes |
1513 | 8 | 8 | ||
1514 | 9 | DEBUG_COMMAND= $(LIBTOOL) --mode=execute gdb | 9 | DEBUG_COMMAND= $(LIBTOOL) --mode=execute gdb |
1515 | 10 | 10 | ||
1516 | @@ -41,6 +41,7 @@ | |||
1517 | 41 | tests_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) | 41 | tests_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) |
1518 | 42 | tests_testapp_SOURCES= tests/mem_functions.c | 42 | tests_testapp_SOURCES= tests/mem_functions.c |
1519 | 43 | tests_testapp_DEPENDENCIES= \ | 43 | tests_testapp_DEPENDENCIES= \ |
1520 | 44 | $(BUILT_SOURCES) \ | ||
1521 | 44 | clients/libgenexec.la \ | 45 | clients/libgenexec.la \ |
1522 | 45 | tests/libserver.la \ | 46 | tests/libserver.la \ |
1523 | 46 | tests/libtest.la \ | 47 | tests/libtest.la \ |
1524 | @@ -86,12 +87,14 @@ | |||
1525 | 86 | tests_memplus_SOURCES = tests/mem_plus.cc | 87 | tests_memplus_SOURCES = tests/mem_plus.cc |
1526 | 87 | tests_memplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX) | 88 | tests_memplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX) |
1527 | 88 | tests_memplus_DEPENDENCIES = tests/libtest.la tests/libserver.la libmemcached/libmemcached.la | 89 | tests_memplus_DEPENDENCIES = tests/libtest.la tests/libserver.la libmemcached/libmemcached.la |
1531 | 89 | tests_memplus_LDADD = $(tests_memplus_DEPENDENCIES) | 90 | tests_memplus_LDADD = $(tests_memplus_DEPENDENCIES) $(LIBSASL) |
1532 | 90 | 91 | ||
1533 | 91 | test: test-docs test-mem test-hash memcapable | 92 | test: check |
1534 | 93 | |||
1535 | 94 | check-local: $(TEST_DOCS) test-mem test-hash memcapable | ||
1536 | 92 | echo "Tests completed" | 95 | echo "Tests completed" |
1537 | 93 | 96 | ||
1539 | 94 | 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 | 97 | test-x: check-local test-plus test-memcat test-memcp test-memrm test-memerror test-memdump test-memflush test-memstat |
1540 | 95 | echo "Tests completed" | 98 | echo "Tests completed" |
1541 | 96 | 99 | ||
1542 | 97 | memcapable: clients/memcapable | 100 | memcapable: clients/memcapable |
1543 | 98 | 101 | ||
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 | 10 | Sample test application. | 10 | Sample test application. |
1549 | 11 | */ | 11 | */ |
1550 | 12 | 12 | ||
1552 | 13 | #include "libmemcached/common.h" | 13 | #include "config.h" |
1553 | 14 | 14 | ||
1554 | 15 | #include <assert.h> | 15 | #include <assert.h> |
1555 | 16 | #include <stdio.h> | 16 | #include <stdio.h> |
1556 | 17 | #include <stdint.h> | ||
1557 | 17 | #include <stdlib.h> | 18 | #include <stdlib.h> |
1558 | 18 | #include <string.h> | 19 | #include <string.h> |
1559 | 19 | #include <sys/time.h> | 20 | #include <sys/time.h> |
1560 | @@ -22,20 +23,18 @@ | |||
1561 | 22 | #include <signal.h> | 23 | #include <signal.h> |
1562 | 23 | #include <unistd.h> | 24 | #include <unistd.h> |
1563 | 24 | #include <time.h> | 25 | #include <time.h> |
1564 | 26 | |||
1565 | 27 | #include "libmemcached/common.h" | ||
1566 | 28 | |||
1567 | 25 | #include "server.h" | 29 | #include "server.h" |
1568 | 26 | #include "clients/generator.h" | 30 | #include "clients/generator.h" |
1569 | 27 | #include "clients/execute.h" | 31 | #include "clients/execute.h" |
1570 | 28 | 32 | ||
1578 | 29 | #ifndef INT64_MAX | 33 | #define SMALL_STRING_LEN 1024 |
1572 | 30 | #define INT64_MAX LONG_MAX | ||
1573 | 31 | #endif | ||
1574 | 32 | #ifndef INT32_MAX | ||
1575 | 33 | #define INT32_MAX INT_MAX | ||
1576 | 34 | #endif | ||
1577 | 35 | |||
1579 | 36 | 34 | ||
1580 | 37 | #include "test.h" | 35 | #include "test.h" |
1581 | 38 | 36 | ||
1582 | 37 | |||
1583 | 39 | #ifdef HAVE_LIBMEMCACHEDUTIL | 38 | #ifdef HAVE_LIBMEMCACHEDUTIL |
1584 | 40 | #include <pthread.h> | 39 | #include <pthread.h> |
1585 | 41 | #include "libmemcached/memcached_util.h" | 40 | #include "libmemcached/memcached_util.h" |
1586 | @@ -682,7 +681,6 @@ | |||
1587 | 682 | */ | 681 | */ |
1588 | 683 | static test_return_t add_wrapper(memcached_st *memc) | 682 | static test_return_t add_wrapper(memcached_st *memc) |
1589 | 684 | { | 683 | { |
1590 | 685 | unsigned int x; | ||
1591 | 686 | unsigned int max= 10000; | 684 | unsigned int max= 10000; |
1592 | 687 | #ifdef __sun | 685 | #ifdef __sun |
1593 | 688 | max= 10; | 686 | max= 10; |
1594 | @@ -691,7 +689,7 @@ | |||
1595 | 691 | max= 10; | 689 | max= 10; |
1596 | 692 | #endif | 690 | #endif |
1597 | 693 | 691 | ||
1599 | 694 | for (x= 0; x < max; x++) | 692 | for (uint32_t x= 0; x < max; x++) |
1600 | 695 | add_test(memc); | 693 | add_test(memc); |
1601 | 696 | 694 | ||
1602 | 697 | return TEST_SUCCESS; | 695 | return TEST_SUCCESS; |
1603 | @@ -3599,7 +3597,7 @@ | |||
1604 | 3599 | // will not toggle protocol on an connection. | 3597 | // will not toggle protocol on an connection. |
1605 | 3600 | memcached_version(memc_clone); | 3598 | memcached_version(memc_clone); |
1606 | 3601 | 3599 | ||
1608 | 3602 | if (libmemcached_util_version_check(memc_clone, 1, 2, 0)) | 3600 | if (libmemcached_util_version_check(memc_clone, 1, 3, 0)) |
1609 | 3603 | { | 3601 | { |
1610 | 3604 | memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); | 3602 | memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); |
1611 | 3605 | rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1); | 3603 | rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1); |
1612 | @@ -3724,23 +3722,14 @@ | |||
1613 | 3724 | static test_return_t pre_binary(memcached_st *memc) | 3722 | static test_return_t pre_binary(memcached_st *memc) |
1614 | 3725 | { | 3723 | { |
1615 | 3726 | memcached_return_t rc= MEMCACHED_FAILURE; | 3724 | memcached_return_t rc= MEMCACHED_FAILURE; |
1625 | 3727 | memcached_st *memc_clone; | 3725 | |
1626 | 3728 | 3726 | if (libmemcached_util_version_check(memc, 1, 3, 0)) | |
1618 | 3729 | memc_clone= memcached_clone(NULL, memc); | ||
1619 | 3730 | test_true(memc_clone); | ||
1620 | 3731 | // The memcached_version needs to be done on a clone, because the server | ||
1621 | 3732 | // will not toggle protocol on an connection. | ||
1622 | 3733 | memcached_version(memc_clone); | ||
1623 | 3734 | |||
1624 | 3735 | if (libmemcached_util_version_check(memc_clone, 1, 2, 0)) | ||
1627 | 3736 | { | 3727 | { |
1628 | 3737 | rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1); | 3728 | rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1); |
1629 | 3738 | test_true(rc == MEMCACHED_SUCCESS); | 3729 | test_true(rc == MEMCACHED_SUCCESS); |
1630 | 3739 | test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1); | 3730 | test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1); |
1631 | 3740 | } | 3731 | } |
1632 | 3741 | 3732 | ||
1633 | 3742 | memcached_free(memc_clone); | ||
1634 | 3743 | |||
1635 | 3744 | return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED; | 3733 | return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED; |
1636 | 3745 | } | 3734 | } |
1637 | 3746 | 3735 | ||
1638 | @@ -4432,24 +4421,24 @@ | |||
1639 | 4432 | memcached_version(memc); | 4421 | memcached_version(memc); |
1640 | 4433 | 4422 | ||
1641 | 4434 | // We only use one binary when we test, so this should be just fine. | 4423 | // We only use one binary when we test, so this should be just fine. |
1660 | 4435 | if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->micro_version, instance->minor_version); | 4424 | if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->minor_version, instance->micro_version); |
1661 | 4436 | test_true(if_successful == true); | 4425 | test_true(if_successful == true); |
1662 | 4437 | 4426 | ||
1663 | 4438 | if (instance->minor_version > 0) | 4427 | if (instance->micro_version > 0) |
1664 | 4439 | if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->micro_version, instance->minor_version -1); | 4428 | if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->minor_version, (uint8_t)(instance->micro_version -1)); |
1665 | 4440 | else if (instance->micro_version > 0) | 4429 | else if (instance->minor_version > 0) |
1666 | 4441 | if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->micro_version - 1, instance->minor_version); | 4430 | if_successful= libmemcached_util_version_check(memc, instance->major_version, (uint8_t)(instance->minor_version - 1), instance->micro_version); |
1667 | 4442 | else if (instance->major_version > 0) | 4431 | else if (instance->major_version > 0) |
1668 | 4443 | if_successful= libmemcached_util_version_check(memc, instance->major_version -1, instance->micro_version, instance->minor_version); | 4432 | if_successful= libmemcached_util_version_check(memc, (uint8_t)(instance->major_version -1), instance->minor_version, instance->micro_version); |
1669 | 4444 | 4433 | ||
1670 | 4445 | test_true(if_successful == true); | 4434 | test_true(if_successful == true); |
1671 | 4446 | 4435 | ||
1672 | 4447 | if (instance->minor_version > 0) | 4436 | if (instance->micro_version > 0) |
1673 | 4448 | if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->micro_version, instance->minor_version +1); | 4437 | if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->minor_version, (uint8_t)(instance->micro_version +1)); |
1674 | 4449 | else if (instance->micro_version > 0) | 4438 | else if (instance->minor_version > 0) |
1675 | 4450 | if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->micro_version +1, instance->minor_version); | 4439 | if_successful= libmemcached_util_version_check(memc, instance->major_version, (uint8_t)(instance->minor_version +1), instance->micro_version); |
1676 | 4451 | else if (instance->major_version > 0) | 4440 | else if (instance->major_version > 0) |
1677 | 4452 | if_successful= libmemcached_util_version_check(memc, instance->major_version +1, instance->micro_version, instance->minor_version); | 4441 | if_successful= libmemcached_util_version_check(memc, (uint8_t)(instance->major_version +1), instance->minor_version, instance->micro_version); |
1678 | 4453 | 4442 | ||
1679 | 4454 | test_true(if_successful == false); | 4443 | test_true(if_successful == false); |
1680 | 4455 | 4444 | ||
1681 | @@ -5018,7 +5007,7 @@ | |||
1682 | 5018 | We are testing the error condition when we connect to a server via memcached_get() | 5007 | We are testing the error condition when we connect to a server via memcached_get() |
1683 | 5019 | but find that the server is not available. | 5008 | but find that the server is not available. |
1684 | 5020 | */ | 5009 | */ |
1686 | 5021 | static test_return_t memcached_get_MEMCACHED_SOME_ERRORS(memcached_st *memc) | 5010 | static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *memc) |
1687 | 5022 | { | 5011 | { |
1688 | 5023 | (void)memc; | 5012 | (void)memc; |
1689 | 5024 | memcached_st *tl_memc_h; | 5013 | memcached_st *tl_memc_h; |
1690 | @@ -5032,21 +5021,18 @@ | |||
1691 | 5032 | 5021 | ||
1692 | 5033 | // Create a handle. | 5022 | // Create a handle. |
1693 | 5034 | tl_memc_h= memcached_create(NULL); | 5023 | tl_memc_h= memcached_create(NULL); |
1695 | 5035 | servers= memcached_servers_parse("localhost:9898"); // This server should not exist | 5024 | servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist |
1696 | 5036 | memcached_server_push(tl_memc_h, servers); | 5025 | memcached_server_push(tl_memc_h, servers); |
1697 | 5037 | memcached_server_list_free(servers); | 5026 | memcached_server_list_free(servers); |
1698 | 5038 | 5027 | ||
1699 | 5039 | // See if memcached is reachable. | 5028 | // See if memcached is reachable. |
1700 | 5040 | value= memcached_get(tl_memc_h, key, strlen(key), &len, &flags, &rc); | 5029 | value= memcached_get(tl_memc_h, key, strlen(key), &len, &flags, &rc); |
1701 | 5041 | 5030 | ||
1708 | 5042 | if (value) | 5031 | test_false(value); |
1703 | 5043 | { | ||
1704 | 5044 | free(value); | ||
1705 | 5045 | test_true(value); // Pointer won't be zero so this is fine. | ||
1706 | 5046 | } | ||
1707 | 5047 | |||
1709 | 5048 | test_true(len == 0); | 5032 | test_true(len == 0); |
1711 | 5049 | test_true(rc == MEMCACHED_SOME_ERRORS); | 5033 | test_true(rc == MEMCACHED_ERRNO); |
1712 | 5034 | |||
1713 | 5035 | memcached_free(tl_memc_h); | ||
1714 | 5050 | 5036 | ||
1715 | 5051 | return TEST_SUCCESS; | 5037 | return TEST_SUCCESS; |
1716 | 5052 | } | 5038 | } |
1717 | @@ -5065,12 +5051,7 @@ | |||
1718 | 5065 | // See if memcached is reachable. | 5051 | // See if memcached is reachable. |
1719 | 5066 | value= memcached_get(memc, key, strlen(key), &len, &flags, &rc); | 5052 | value= memcached_get(memc, key, strlen(key), &len, &flags, &rc); |
1720 | 5067 | 5053 | ||
1727 | 5068 | if (value) | 5054 | test_false(value); |
1722 | 5069 | { | ||
1723 | 5070 | free(value); | ||
1724 | 5071 | test_true(value); // Pointer won't be zero so this is fine. | ||
1725 | 5072 | } | ||
1726 | 5073 | |||
1728 | 5074 | test_true(len == 0); | 5055 | test_true(len == 0); |
1729 | 5075 | test_true(rc == MEMCACHED_NOTFOUND); | 5056 | test_true(rc == MEMCACHED_NOTFOUND); |
1730 | 5076 | 5057 | ||
1731 | @@ -5083,7 +5064,7 @@ | |||
1732 | 5083 | We are testing the error condition when we connect to a server via memcached_get_by_key() | 5064 | We are testing the error condition when we connect to a server via memcached_get_by_key() |
1733 | 5084 | but find that the server is not available. | 5065 | but find that the server is not available. |
1734 | 5085 | */ | 5066 | */ |
1736 | 5086 | static test_return_t memcached_get_by_key_MEMCACHED_SOME_ERRORS(memcached_st *memc) | 5067 | static test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *memc) |
1737 | 5087 | { | 5068 | { |
1738 | 5088 | (void)memc; | 5069 | (void)memc; |
1739 | 5089 | memcached_st *tl_memc_h; | 5070 | memcached_st *tl_memc_h; |
1740 | @@ -5097,21 +5078,18 @@ | |||
1741 | 5097 | 5078 | ||
1742 | 5098 | // Create a handle. | 5079 | // Create a handle. |
1743 | 5099 | tl_memc_h= memcached_create(NULL); | 5080 | tl_memc_h= memcached_create(NULL); |
1745 | 5100 | servers= memcached_servers_parse("localhost:9898"); // This server should not exist | 5081 | servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist |
1746 | 5101 | memcached_server_push(tl_memc_h, servers); | 5082 | memcached_server_push(tl_memc_h, servers); |
1747 | 5102 | memcached_server_list_free(servers); | 5083 | memcached_server_list_free(servers); |
1748 | 5103 | 5084 | ||
1749 | 5104 | // See if memcached is reachable. | 5085 | // See if memcached is reachable. |
1750 | 5105 | value= memcached_get_by_key(tl_memc_h, key, strlen(key), key, strlen(key), &len, &flags, &rc); | 5086 | value= memcached_get_by_key(tl_memc_h, key, strlen(key), key, strlen(key), &len, &flags, &rc); |
1751 | 5106 | 5087 | ||
1758 | 5107 | if (value) | 5088 | test_false(value); |
1753 | 5108 | { | ||
1754 | 5109 | free(value); | ||
1755 | 5110 | test_true(value); // Pointer won't be zero so this is fine. | ||
1756 | 5111 | } | ||
1757 | 5112 | |||
1759 | 5113 | test_true(len == 0); | 5089 | test_true(len == 0); |
1761 | 5114 | test_true(rc == MEMCACHED_SOME_ERRORS); | 5090 | test_true(rc == MEMCACHED_ERRNO); |
1762 | 5091 | |||
1763 | 5092 | memcached_free(tl_memc_h); | ||
1764 | 5115 | 5093 | ||
1765 | 5116 | return TEST_SUCCESS; | 5094 | return TEST_SUCCESS; |
1766 | 5117 | } | 5095 | } |
1767 | @@ -5130,12 +5108,7 @@ | |||
1768 | 5130 | // See if memcached is reachable. | 5108 | // See if memcached is reachable. |
1769 | 5131 | value= memcached_get_by_key(memc, key, strlen(key), key, strlen(key), &len, &flags, &rc); | 5109 | value= memcached_get_by_key(memc, key, strlen(key), key, strlen(key), &len, &flags, &rc); |
1770 | 5132 | 5110 | ||
1777 | 5133 | if (value) | 5111 | test_false(value); |
1772 | 5134 | { | ||
1773 | 5135 | free(value); | ||
1774 | 5136 | test_true(value); // Pointer won't be zero so this is fine. | ||
1775 | 5137 | } | ||
1776 | 5138 | |||
1778 | 5139 | test_true(len == 0); | 5112 | test_true(len == 0); |
1779 | 5140 | test_true(rc == MEMCACHED_NOTFOUND); | 5113 | test_true(rc == MEMCACHED_NOTFOUND); |
1780 | 5141 | 5114 | ||
1781 | @@ -5575,54 +5548,58 @@ | |||
1782 | 5575 | 5548 | ||
1783 | 5576 | static test_return_t regression_bug_463297(memcached_st *memc) | 5549 | static test_return_t regression_bug_463297(memcached_st *memc) |
1784 | 5577 | { | 5550 | { |
1791 | 5578 | memcached_st *memc_clone= memcached_clone(NULL, memc); | 5551 | memcached_st *memc_clone= memcached_clone(NULL, memc); |
1792 | 5579 | test_true(memc_clone != NULL); | 5552 | test_true(memc_clone != NULL); |
1793 | 5580 | test_true(memcached_version(memc_clone) == MEMCACHED_SUCCESS); | 5553 | test_true(memcached_version(memc_clone) == MEMCACHED_SUCCESS); |
1794 | 5581 | 5554 | ||
1795 | 5582 | 5555 | memcached_server_instance_st instance= | |
1796 | 5583 | if (libmemcached_util_version_check(memc_clone, 1, 1, 2)) | 5556 | memcached_server_instance_by_position(memc_clone, 0); |
1797 | 5557 | |||
1798 | 5558 | if (instance->major_version > 1 || | ||
1799 | 5559 | (instance->major_version == 1 && | ||
1800 | 5560 | instance->minor_version > 2)) | ||
1801 | 5584 | { | 5561 | { |
1843 | 5585 | /* Binary protocol doesn't support deferred delete */ | 5562 | /* Binary protocol doesn't support deferred delete */ |
1844 | 5586 | memcached_st *bin_clone= memcached_clone(NULL, memc); | 5563 | memcached_st *bin_clone= memcached_clone(NULL, memc); |
1845 | 5587 | test_true(bin_clone != NULL); | 5564 | test_true(bin_clone != NULL); |
1846 | 5588 | test_true(memcached_behavior_set(bin_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1) == MEMCACHED_SUCCESS); | 5565 | test_true(memcached_behavior_set(bin_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1) == MEMCACHED_SUCCESS); |
1847 | 5589 | test_true(memcached_delete(bin_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS); | 5566 | test_true(memcached_delete(bin_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS); |
1848 | 5590 | memcached_free(bin_clone); | 5567 | memcached_free(bin_clone); |
1849 | 5591 | 5568 | ||
1850 | 5592 | memcached_quit(memc_clone); | 5569 | memcached_quit(memc_clone); |
1851 | 5593 | 5570 | ||
1852 | 5594 | /* If we know the server version, deferred delete should fail | 5571 | /* If we know the server version, deferred delete should fail |
1853 | 5595 | * with invalid arguments */ | 5572 | * with invalid arguments */ |
1854 | 5596 | test_true(memcached_delete(memc_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS); | 5573 | test_true(memcached_delete(memc_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS); |
1855 | 5597 | 5574 | ||
1856 | 5598 | /* If we don't know the server version, we should get a protocol error */ | 5575 | /* If we don't know the server version, we should get a protocol error */ |
1857 | 5599 | memcached_return_t rc= memcached_delete(memc, "foo", 3, 1); | 5576 | memcached_return_t rc= memcached_delete(memc, "foo", 3, 1); |
1858 | 5600 | 5577 | ||
1859 | 5601 | /* but there is a bug in some of the memcached servers (1.4) that treats | 5578 | /* but there is a bug in some of the memcached servers (1.4) that treats |
1860 | 5602 | * the counter as noreply so it doesn't send the proper error message | 5579 | * the counter as noreply so it doesn't send the proper error message |
1861 | 5603 | */ | 5580 | */ |
1862 | 5604 | test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); | 5581 | test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); |
1863 | 5605 | 5582 | ||
1864 | 5606 | /* And buffered mode should be disabled and we should get protocol error */ | 5583 | /* And buffered mode should be disabled and we should get protocol error */ |
1865 | 5607 | test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1) == MEMCACHED_SUCCESS); | 5584 | test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1) == MEMCACHED_SUCCESS); |
1866 | 5608 | rc= memcached_delete(memc, "foo", 3, 1); | 5585 | rc= memcached_delete(memc, "foo", 3, 1); |
1867 | 5609 | test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); | 5586 | test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); |
1868 | 5610 | 5587 | ||
1869 | 5611 | /* Same goes for noreply... */ | 5588 | /* Same goes for noreply... */ |
1870 | 5612 | test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1) == MEMCACHED_SUCCESS); | 5589 | test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1) == MEMCACHED_SUCCESS); |
1871 | 5613 | rc= memcached_delete(memc, "foo", 3, 1); | 5590 | rc= memcached_delete(memc, "foo", 3, 1); |
1872 | 5614 | test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); | 5591 | test_true(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR); |
1873 | 5615 | 5592 | ||
1874 | 5616 | /* but a normal request should go through (and be buffered) */ | 5593 | /* but a normal request should go through (and be buffered) */ |
1875 | 5617 | test_true((rc= memcached_delete(memc, "foo", 3, 0)) == MEMCACHED_BUFFERED); | 5594 | test_true((rc= memcached_delete(memc, "foo", 3, 0)) == MEMCACHED_BUFFERED); |
1876 | 5618 | test_true(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS); | 5595 | test_true(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS); |
1877 | 5619 | 5596 | ||
1878 | 5620 | test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0) == MEMCACHED_SUCCESS); | 5597 | test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0) == MEMCACHED_SUCCESS); |
1879 | 5621 | /* unbuffered noreply should be success */ | 5598 | /* unbuffered noreply should be success */ |
1880 | 5622 | test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_SUCCESS); | 5599 | test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_SUCCESS); |
1881 | 5623 | /* unbuffered with reply should be not found... */ | 5600 | /* unbuffered with reply should be not found... */ |
1882 | 5624 | test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0) == MEMCACHED_SUCCESS); | 5601 | test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0) == MEMCACHED_SUCCESS); |
1883 | 5625 | test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_NOTFOUND); | 5602 | test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_NOTFOUND); |
1884 | 5626 | } | 5603 | } |
1885 | 5627 | 5604 | ||
1886 | 5628 | memcached_free(memc_clone); | 5605 | memcached_free(memc_clone); |
1887 | @@ -5748,6 +5725,39 @@ | |||
1888 | 5748 | return TEST_SUCCESS; | 5725 | return TEST_SUCCESS; |
1889 | 5749 | } | 5726 | } |
1890 | 5750 | 5727 | ||
1891 | 5728 | |||
1892 | 5729 | static memcached_return_t stat_printer(memcached_server_instance_st server, | ||
1893 | 5730 | const char *key, size_t key_length, | ||
1894 | 5731 | const char *value, size_t value_length, | ||
1895 | 5732 | void *context) | ||
1896 | 5733 | { | ||
1897 | 5734 | (void)server; | ||
1898 | 5735 | (void)context; | ||
1899 | 5736 | (void)key; | ||
1900 | 5737 | (void)key_length; | ||
1901 | 5738 | (void)value; | ||
1902 | 5739 | (void)value_length; | ||
1903 | 5740 | |||
1904 | 5741 | return MEMCACHED_SUCCESS; | ||
1905 | 5742 | } | ||
1906 | 5743 | |||
1907 | 5744 | static test_return_t memcached_stat_execute_test(memcached_st *memc) | ||
1908 | 5745 | { | ||
1909 | 5746 | memcached_return_t rc= memcached_stat_execute(memc, NULL, stat_printer, NULL); | ||
1910 | 5747 | test_true(rc == MEMCACHED_SUCCESS); | ||
1911 | 5748 | |||
1912 | 5749 | rc= memcached_stat_execute(memc, "slabs", stat_printer, NULL); | ||
1913 | 5750 | test_true(rc == MEMCACHED_SUCCESS); | ||
1914 | 5751 | |||
1915 | 5752 | rc= memcached_stat_execute(memc, "items", stat_printer, NULL); | ||
1916 | 5753 | test_true(rc == MEMCACHED_SUCCESS); | ||
1917 | 5754 | |||
1918 | 5755 | rc= memcached_stat_execute(memc, "sizes", stat_printer, NULL); | ||
1919 | 5756 | test_true(rc == MEMCACHED_SUCCESS); | ||
1920 | 5757 | |||
1921 | 5758 | return TEST_SUCCESS; | ||
1922 | 5759 | } | ||
1923 | 5760 | |||
1924 | 5751 | /* | 5761 | /* |
1925 | 5752 | * This test ensures that the failure counter isn't incremented during | 5762 | * This test ensures that the failure counter isn't incremented during |
1926 | 5753 | * normal termination of the memcached instance. | 5763 | * normal termination of the memcached instance. |
1927 | @@ -6080,6 +6090,7 @@ | |||
1928 | 6080 | 6090 | ||
1929 | 6081 | /* Clean the server before beginning testing */ | 6091 | /* Clean the server before beginning testing */ |
1930 | 6082 | test_st tests[] ={ | 6092 | test_st tests[] ={ |
1931 | 6093 | {"util_version", 1, (test_callback_fn)util_version_test }, | ||
1932 | 6083 | {"flush", 0, (test_callback_fn)flush_test }, | 6094 | {"flush", 0, (test_callback_fn)flush_test }, |
1933 | 6084 | {"init", 0, (test_callback_fn)init_test }, | 6095 | {"init", 0, (test_callback_fn)init_test }, |
1934 | 6085 | {"allocation", 0, (test_callback_fn)allocation_test }, | 6096 | {"allocation", 0, (test_callback_fn)allocation_test }, |
1935 | @@ -6135,12 +6146,12 @@ | |||
1936 | 6135 | #ifdef HAVE_LIBMEMCACHEDUTIL | 6146 | #ifdef HAVE_LIBMEMCACHEDUTIL |
1937 | 6136 | {"connectionpool", 1, (test_callback_fn)connection_pool_test }, | 6147 | {"connectionpool", 1, (test_callback_fn)connection_pool_test }, |
1938 | 6137 | {"ping", 1, (test_callback_fn)ping_test }, | 6148 | {"ping", 1, (test_callback_fn)ping_test }, |
1939 | 6138 | {"util_version", 1, (test_callback_fn)util_version_test }, | ||
1940 | 6139 | #endif | 6149 | #endif |
1941 | 6140 | {"test_get_last_disconnect", 1, (test_callback_fn)test_get_last_disconnect}, | 6150 | {"test_get_last_disconnect", 1, (test_callback_fn)test_get_last_disconnect}, |
1942 | 6141 | {"verbosity", 1, (test_callback_fn)test_verbosity}, | 6151 | {"verbosity", 1, (test_callback_fn)test_verbosity}, |
1943 | 6142 | {"test_server_failure", 1, (test_callback_fn)test_server_failure}, | 6152 | {"test_server_failure", 1, (test_callback_fn)test_server_failure}, |
1944 | 6143 | {"cull_servers", 1, (test_callback_fn)test_cull_servers}, | 6153 | {"cull_servers", 1, (test_callback_fn)test_cull_servers}, |
1945 | 6154 | {"memcached_stat_execute", 1, (test_callback_fn)memcached_stat_execute_test}, | ||
1946 | 6144 | {0, 0, 0} | 6155 | {0, 0, 0} |
1947 | 6145 | }; | 6156 | }; |
1948 | 6146 | 6157 | ||
1949 | @@ -6332,9 +6343,9 @@ | |||
1950 | 6332 | }; | 6343 | }; |
1951 | 6333 | 6344 | ||
1952 | 6334 | test_st error_conditions[] ={ | 6345 | test_st error_conditions[] ={ |
1954 | 6335 | {"memcached_get_MEMCACHED_SOME_ERRORS", 0, (test_callback_fn)memcached_get_MEMCACHED_SOME_ERRORS }, | 6346 | {"memcached_get_MEMCACHED_ERRNO", 0, (test_callback_fn)memcached_get_MEMCACHED_ERRNO }, |
1955 | 6336 | {"memcached_get_MEMCACHED_NOTFOUND", 0, (test_callback_fn)memcached_get_MEMCACHED_NOTFOUND }, | 6347 | {"memcached_get_MEMCACHED_NOTFOUND", 0, (test_callback_fn)memcached_get_MEMCACHED_NOTFOUND }, |
1957 | 6337 | {"memcached_get_by_key_MEMCACHED_SOME_ERRORS", 0, (test_callback_fn)memcached_get_by_key_MEMCACHED_SOME_ERRORS }, | 6348 | {"memcached_get_by_key_MEMCACHED_ERRNO", 0, (test_callback_fn)memcached_get_by_key_MEMCACHED_ERRNO }, |
1958 | 6338 | {"memcached_get_by_key_MEMCACHED_NOTFOUND", 0, (test_callback_fn)memcached_get_by_key_MEMCACHED_NOTFOUND }, | 6349 | {"memcached_get_by_key_MEMCACHED_NOTFOUND", 0, (test_callback_fn)memcached_get_by_key_MEMCACHED_NOTFOUND }, |
1959 | 6339 | {0, 0, (test_callback_fn)0} | 6350 | {0, 0, (test_callback_fn)0} |
1960 | 6340 | }; | 6351 | }; |
1961 | 6341 | 6352 | ||
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 | 10 | Sample test application. | 10 | Sample test application. |
1967 | 11 | */ | 11 | */ |
1968 | 12 | 12 | ||
1969 | 13 | #include "config.h" | ||
1970 | 14 | |||
1971 | 13 | #include "libmemcached/common.h" | 15 | #include "libmemcached/common.h" |
1972 | 14 | 16 | ||
1973 | 15 | #include <assert.h> | 17 | #include <assert.h> |
1974 | 16 | #include <stdio.h> | 18 | #include <stdio.h> |
1975 | 19 | #include <stdint.h> | ||
1976 | 17 | #include <stdlib.h> | 20 | #include <stdlib.h> |
1977 | 18 | #include <string.h> | 21 | #include <string.h> |
1978 | 19 | #include <sys/time.h> | 22 | #include <sys/time.h> |
1979 | @@ -25,14 +28,6 @@ | |||
1980 | 25 | 28 | ||
1981 | 26 | #include "server.h" | 29 | #include "server.h" |
1982 | 27 | 30 | ||
1983 | 28 | #ifndef INT64_MAX | ||
1984 | 29 | #define INT64_MAX LONG_MAX | ||
1985 | 30 | #endif | ||
1986 | 31 | #ifndef INT32_MAX | ||
1987 | 32 | #define INT32_MAX INT_MAX | ||
1988 | 33 | #endif | ||
1989 | 34 | |||
1990 | 35 | |||
1991 | 36 | #include "test.h" | 31 | #include "test.h" |
1992 | 37 | 32 | ||
1993 | 38 | #define SERVERS_TO_CREATE 5 | 33 | #define SERVERS_TO_CREATE 5 |
1994 | 39 | 34 | ||
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 | 26 | #include <libmemcached/memcached.h> | 26 | #include <libmemcached/memcached.h> |
2000 | 27 | #include <libmemcached/util.h> | 27 | #include <libmemcached/util.h> |
2001 | 28 | #include <unistd.h> | 28 | #include <unistd.h> |
2002 | 29 | #include <time.h> | ||
2003 | 30 | |||
2004 | 29 | #include "server.h" | 31 | #include "server.h" |
2005 | 30 | 32 | ||
2006 | 31 | void server_startup(server_startup_st *construct) | 33 | void server_startup(server_startup_st *construct) |
2007 | 32 | { | 34 | { |
2008 | 33 | unsigned int x; | ||
2009 | 34 | |||
2010 | 35 | if ((construct->server_list= getenv("MEMCACHED_SERVERS"))) | 35 | if ((construct->server_list= getenv("MEMCACHED_SERVERS"))) |
2011 | 36 | { | 36 | { |
2012 | 37 | printf("servers %s\n", construct->server_list); | 37 | printf("servers %s\n", construct->server_list); |
2013 | @@ -46,7 +46,7 @@ | |||
2014 | 46 | char *end_ptr; | 46 | char *end_ptr; |
2015 | 47 | end_ptr= server_string_buffer; | 47 | end_ptr= server_string_buffer; |
2016 | 48 | 48 | ||
2018 | 49 | for (x= 0; x < construct->count; x++) | 49 | for (uint32_t x= 0; x < construct->count; x++) |
2019 | 50 | { | 50 | { |
2020 | 51 | char buffer[1024]; /* Nothing special for number */ | 51 | char buffer[1024]; /* Nothing special for number */ |
2021 | 52 | int count; | 52 | int count; |
2022 | @@ -95,6 +95,39 @@ | |||
2023 | 95 | } | 95 | } |
2024 | 96 | *end_ptr= 0; | 96 | *end_ptr= 0; |
2025 | 97 | 97 | ||
2026 | 98 | for (uint32_t x= 0; x < construct->count; x++) | ||
2027 | 99 | { | ||
2028 | 100 | uint32_t counter= 3; | ||
2029 | 101 | char buffer[1024]; /* Nothing special for number */ | ||
2030 | 102 | |||
2031 | 103 | snprintf(buffer, sizeof(buffer), "/tmp/%umemc.pid", x); | ||
2032 | 104 | |||
2033 | 105 | while (--counter) | ||
2034 | 106 | { | ||
2035 | 107 | int memcached_pid; | ||
2036 | 108 | |||
2037 | 109 | FILE *file; | ||
2038 | 110 | file= fopen(buffer, "r"); | ||
2039 | 111 | if (file == NULL) | ||
2040 | 112 | { | ||
2041 | 113 | struct timespec req= { .tv_sec= 0, .tv_nsec= 5000 }; | ||
2042 | 114 | nanosleep(&req, NULL); | ||
2043 | 115 | |||
2044 | 116 | continue; | ||
2045 | 117 | } | ||
2046 | 118 | char *found= fgets(buffer, sizeof(buffer), file); | ||
2047 | 119 | if (!found) | ||
2048 | 120 | { | ||
2049 | 121 | abort(); | ||
2050 | 122 | } | ||
2051 | 123 | // Yes, we currently pitch this and don't make use of it. | ||
2052 | 124 | memcached_pid= atoi(buffer); | ||
2053 | 125 | fclose(file); | ||
2054 | 126 | } | ||
2055 | 127 | |||
2056 | 128 | |||
2057 | 129 | } | ||
2058 | 130 | |||
2059 | 98 | construct->server_list= strdup(server_string_buffer); | 131 | construct->server_list= strdup(server_string_buffer); |
2060 | 99 | } | 132 | } |
2061 | 100 | printf("servers %s\n", construct->server_list); | 133 | printf("servers %s\n", construct->server_list); |
2062 | @@ -105,7 +138,7 @@ | |||
2063 | 105 | 138 | ||
2064 | 106 | srandom((unsigned int)time(NULL)); | 139 | srandom((unsigned int)time(NULL)); |
2065 | 107 | 140 | ||
2067 | 108 | for (x= 0; x < memcached_server_list_count(construct->servers); x++) | 141 | for (uint32_t x= 0; x < memcached_server_list_count(construct->servers); x++) |
2068 | 109 | { | 142 | { |
2069 | 110 | printf("\t%s : %d\n", memcached_server_name(&construct->servers[x]), memcached_server_port(&construct->servers[x])); | 143 | printf("\t%s : %d\n", memcached_server_name(&construct->servers[x]), memcached_server_port(&construct->servers[x])); |
2070 | 111 | assert(construct->servers[x].fd == -1); | 144 | assert(construct->servers[x].fd == -1); |
2071 | @@ -117,11 +150,9 @@ | |||
2072 | 117 | 150 | ||
2073 | 118 | void server_shutdown(server_startup_st *construct) | 151 | void server_shutdown(server_startup_st *construct) |
2074 | 119 | { | 152 | { |
2075 | 120 | unsigned int x; | ||
2076 | 121 | |||
2077 | 122 | if (construct->server_list) | 153 | if (construct->server_list) |
2078 | 123 | { | 154 | { |
2080 | 124 | for (x= 0; x < construct->count; x++) | 155 | for (uint32_t x= 0; x < construct->count; x++) |
2081 | 125 | { | 156 | { |
2082 | 126 | char buffer[1024]; /* Nothing special for number */ | 157 | char buffer[1024]; /* Nothing special for number */ |
2083 | 127 | sprintf(buffer, "cat /tmp/%umemc.pid | xargs kill", x); | 158 | sprintf(buffer, "cat /tmp/%umemc.pid | xargs kill", x); |
2084 | 128 | 159 | ||
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 | 9 | * | 9 | * |
2090 | 10 | */ | 10 | */ |
2091 | 11 | 11 | ||
2092 | 12 | #include "config.h" | ||
2093 | 13 | |||
2094 | 12 | #include <stdio.h> | 14 | #include <stdio.h> |
2095 | 13 | #include <string.h> | 15 | #include <string.h> |
2096 | 14 | #include "server.h" | 16 | #include "server.h" |
2097 | 15 | 17 | ||
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 | 9 | /* | 9 | /* |
2103 | 10 | Sample test application. | 10 | Sample test application. |
2104 | 11 | */ | 11 | */ |
2105 | 12 | |||
2106 | 13 | #include "config.h" | ||
2107 | 14 | |||
2108 | 12 | #include <assert.h> | 15 | #include <assert.h> |
2109 | 13 | #include <stdlib.h> | 16 | #include <stdlib.h> |
2110 | 14 | #include <string.h> | 17 | #include <string.h> |
2111 | @@ -22,6 +25,7 @@ | |||
2112 | 22 | #include <stdint.h> | 25 | #include <stdint.h> |
2113 | 23 | 26 | ||
2114 | 24 | #include "libmemcached/memcached.h" | 27 | #include "libmemcached/memcached.h" |
2115 | 28 | |||
2116 | 25 | #include "test.h" | 29 | #include "test.h" |
2117 | 26 | 30 | ||
2118 | 27 | static void world_stats_print(world_stats_st *stats) | 31 | static void world_stats_print(world_stats_st *stats) |
2119 | 28 | 32 | ||
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 | 1 | # vim:ft=automake | ||
2126 | 2 | # included from Top Level Makefile.am | ||
2127 | 3 | # All paths should be given relative to the root | ||
2128 | 4 | |||
2129 | 5 | if HAVE_LIBGTEST | ||
2130 | 6 | check_PROGRAMS += unittests/unittests | ||
2131 | 7 | endif | ||
2132 | 8 | |||
2133 | 9 | unittests_unittests_SOURCES= \ | ||
2134 | 10 | unittests/main.cc \ | ||
2135 | 11 | unittests/strings.cc | ||
2136 | 12 | |||
2137 | 13 | unittests_unittest_CXXFLAGS= ${AM_CXXFLAGS} ${NO_WERROR} | ||
2138 | 14 | unittests_unittests_LDADD= \ | ||
2139 | 15 | tests/libserver.la \ | ||
2140 | 16 | libmemcached/libmemcachedinternal.la \ | ||
2141 | 17 | ${TESTS_LDADDS} ${LTLIBGTEST} | ||
2142 | 18 | # Shorthand | ||
2143 | 19 | unit: check-TESTS | ||
2144 | 20 | |||
2145 | 0 | 21 | ||
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 | 1 | /* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*- | ||
2151 | 2 | * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: | ||
2152 | 3 | * | ||
2153 | 4 | * Copyright (C) 2010 Monty Taylor | ||
2154 | 5 | * | ||
2155 | 6 | * All rights reserved. | ||
2156 | 7 | * | ||
2157 | 8 | * Use and distribution licensed under the BSD license. See | ||
2158 | 9 | * the COPYING file in the parent directory for full text. | ||
2159 | 10 | */ | ||
2160 | 11 | |||
2161 | 12 | #include "config.h" | ||
2162 | 13 | |||
2163 | 14 | #include <gtest/gtest.h> | ||
2164 | 15 | |||
2165 | 16 | |||
2166 | 17 | int main(int argc, char **argv) | ||
2167 | 18 | { | ||
2168 | 19 | ::testing::InitGoogleTest(&argc, argv); | ||
2169 | 20 | return RUN_ALL_TESTS(); | ||
2170 | 21 | } | ||
2171 | 0 | 22 | ||
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 | 1 | /* libMemcached | ||
2177 | 2 | * Copyright (C) 2010 Brian Aker | ||
2178 | 3 | * All rights reserved. | ||
2179 | 4 | * | ||
2180 | 5 | * Use and distribution licensed under the BSD license. See | ||
2181 | 6 | * the COPYING file in the parent directory for full text. | ||
2182 | 7 | */ | ||
2183 | 8 | |||
2184 | 9 | #include "config.h" | ||
2185 | 10 | |||
2186 | 11 | #define __STDC_LIMIT_MACROS | ||
2187 | 12 | #include <stdint.h> | ||
2188 | 13 | |||
2189 | 14 | #include <gtest/gtest.h> | ||
2190 | 15 | |||
2191 | 16 | #include <libmemcached/common.h> | ||
2192 | 17 | |||
2193 | 18 | TEST(memcached_string_st, memcached_create_static) | ||
2194 | 19 | { | ||
2195 | 20 | memcached_string_st string; | ||
2196 | 21 | memcached_string_st *string_ptr; | ||
2197 | 22 | |||
2198 | 23 | memcached_st *memc= memcached_create(NULL); | ||
2199 | 24 | string_ptr= memcached_string_create(memc, &string, 0); | ||
2200 | 25 | ASSERT_TRUE(string.options.is_initialized); | ||
2201 | 26 | ASSERT_TRUE(string_ptr); | ||
2202 | 27 | |||
2203 | 28 | /* The following two better be the same! */ | ||
2204 | 29 | ASSERT_FALSE(memcached_is_allocated(string_ptr)); | ||
2205 | 30 | ASSERT_FALSE(memcached_is_allocated(&string)); | ||
2206 | 31 | EXPECT_EQ(&string, string_ptr); | ||
2207 | 32 | |||
2208 | 33 | ASSERT_TRUE(string.options.is_initialized); | ||
2209 | 34 | ASSERT_TRUE(memcached_is_initialized(&string)); | ||
2210 | 35 | memcached_string_free(&string); | ||
2211 | 36 | ASSERT_FALSE(memcached_is_initialized(&string)); | ||
2212 | 37 | |||
2213 | 38 | memcached_free(memc); | ||
2214 | 39 | } | ||
2215 | 40 | |||
2216 | 41 | TEST(memcached_string_st, memcached_create_null) | ||
2217 | 42 | { | ||
2218 | 43 | memcached_string_st *string; | ||
2219 | 44 | memcached_st *memc= memcached_create(NULL); | ||
2220 | 45 | |||
2221 | 46 | string= memcached_string_create(memc, NULL, 0); | ||
2222 | 47 | ASSERT_TRUE(string); | ||
2223 | 48 | ASSERT_TRUE(memcached_is_allocated(string)); | ||
2224 | 49 | ASSERT_TRUE(memcached_is_initialized(string)); | ||
2225 | 50 | memcached_string_free(string); | ||
2226 | 51 | |||
2227 | 52 | memcached_free(memc); | ||
2228 | 53 | } | ||
2229 | 54 | |||
2230 | 55 | TEST(memcached_string_st, string_alloc_with_size) | ||
2231 | 56 | { | ||
2232 | 57 | memcached_string_st *string; | ||
2233 | 58 | memcached_st *memc= memcached_create(NULL); | ||
2234 | 59 | |||
2235 | 60 | string= memcached_string_create(memc, NULL, 1024); | ||
2236 | 61 | ASSERT_TRUE(string); | ||
2237 | 62 | ASSERT_TRUE(memcached_is_allocated(string)); | ||
2238 | 63 | ASSERT_TRUE(memcached_is_initialized(string)); | ||
2239 | 64 | memcached_string_free(string); | ||
2240 | 65 | |||
2241 | 66 | memcached_free(memc); | ||
2242 | 67 | } | ||
2243 | 68 | |||
2244 | 69 | TEST(memcached_string_st, string_alloc_with_size_toobig) | ||
2245 | 70 | { | ||
2246 | 71 | memcached_st *memc= memcached_create(NULL); | ||
2247 | 72 | memcached_string_st *string; | ||
2248 | 73 | |||
2249 | 74 | string= memcached_string_create(memc, NULL, SIZE_MAX); | ||
2250 | 75 | ASSERT_FALSE(string); | ||
2251 | 76 | |||
2252 | 77 | memcached_free(memc); | ||
2253 | 78 | } | ||
2254 | 79 | |||
2255 | 80 | TEST(memcached_string_st, string_alloc_append) | ||
2256 | 81 | { | ||
2257 | 82 | char buffer[SMALL_STRING_LEN]; | ||
2258 | 83 | memcached_string_st *string; | ||
2259 | 84 | |||
2260 | 85 | memcached_st *memc= memcached_create(NULL); | ||
2261 | 86 | |||
2262 | 87 | /* Ring the bell! */ | ||
2263 | 88 | memset(buffer, 6, SMALL_STRING_LEN); | ||
2264 | 89 | |||
2265 | 90 | string= memcached_string_create(memc, NULL, 100); | ||
2266 | 91 | ASSERT_TRUE(string); | ||
2267 | 92 | ASSERT_TRUE(memcached_is_allocated(string)); | ||
2268 | 93 | ASSERT_TRUE(memcached_is_initialized(string)); | ||
2269 | 94 | |||
2270 | 95 | for (uint32_t x= 0; x < 1024; x++) | ||
2271 | 96 | { | ||
2272 | 97 | memcached_return_t rc; | ||
2273 | 98 | rc= memcached_string_append(string, buffer, SMALL_STRING_LEN); | ||
2274 | 99 | EXPECT_EQ(rc, MEMCACHED_SUCCESS); | ||
2275 | 100 | } | ||
2276 | 101 | ASSERT_TRUE(memcached_is_allocated(string)); | ||
2277 | 102 | memcached_string_free(string); | ||
2278 | 103 | |||
2279 | 104 | memcached_free(memc); | ||
2280 | 105 | } | ||
2281 | 106 | |||
2282 | 107 | TEST(memcached_string_st, string_alloc_append_toobig) | ||
2283 | 108 | { | ||
2284 | 109 | memcached_return_t rc; | ||
2285 | 110 | char buffer[SMALL_STRING_LEN]; | ||
2286 | 111 | memcached_string_st *string; | ||
2287 | 112 | |||
2288 | 113 | memcached_st *memc= memcached_create(NULL); | ||
2289 | 114 | |||
2290 | 115 | /* Ring the bell! */ | ||
2291 | 116 | memset(buffer, 6, SMALL_STRING_LEN); | ||
2292 | 117 | |||
2293 | 118 | string= memcached_string_create(memc, NULL, 100); | ||
2294 | 119 | ASSERT_TRUE(string); | ||
2295 | 120 | ASSERT_TRUE(memcached_is_allocated(string)); | ||
2296 | 121 | ASSERT_TRUE(memcached_is_initialized(string)); | ||
2297 | 122 | |||
2298 | 123 | for (uint32_t x= 0; x < 1024; x++) | ||
2299 | 124 | { | ||
2300 | 125 | rc= memcached_string_append(string, buffer, SMALL_STRING_LEN); | ||
2301 | 126 | EXPECT_EQ(rc, MEMCACHED_SUCCESS); | ||
2302 | 127 | } | ||
2303 | 128 | rc= memcached_string_append(string, buffer, SIZE_MAX); | ||
2304 | 129 | EXPECT_EQ(rc, MEMCACHED_MEMORY_ALLOCATION_FAILURE); | ||
2305 | 130 | ASSERT_TRUE(memcached_is_allocated(string)); | ||
2306 | 131 | memcached_string_free(string); | ||
2307 | 132 | |||
2308 | 133 | memcached_free(memc); | ||
2309 | 134 | } |
This was applied to the tree a while ago.