Merge lp:~brianaker/libmemcached/key-cleanup into lp:libmemcached/1.0

Proposed by Brian Aker
Status: Merged
Merged at revision: 1170
Proposed branch: lp:~brianaker/libmemcached/key-cleanup
Merge into: lp:libmemcached/1.0
Diff against target: 880 lines (+269/-217)
17 files modified
libmemcached/auto.cc (+0/-1)
libmemcached/connect.cc (+1/-1)
libmemcached/error.cc (+138/-119)
libmemcached/get.cc (+15/-5)
libmemcached/io.cc (+5/-0)
libmemcached/io.hpp (+2/-1)
libmemcached/key.cc (+47/-23)
libmemcached/key.hpp (+0/-24)
libmemcached/response.cc (+10/-1)
libmemcached/stats.cc (+7/-6)
libmemcached/touch.cc (+2/-2)
m4/ax_pthread.m4 (+16/-12)
tests/cli.am (+9/-0)
tests/libmemcached-1.0/mem_functions.cc (+9/-11)
tests/libmemcached_world.h (+2/-0)
tests/libmemcached_world_socket.h (+3/-0)
tests/memdump.cc (+3/-11)
To merge this branch: bzr merge lp:~brianaker/libmemcached/key-cleanup
Reviewer Review Type Date Requested Status
Tangent Trunk Pending
Review via email: mp+190608@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libmemcached/auto.cc'
2--- libmemcached/auto.cc 2013-09-15 07:19:20 +0000
3+++ libmemcached/auto.cc 2013-10-11 11:04:39 +0000
4@@ -54,7 +54,6 @@
5
6 if (memcached_fatal(rc))
7 {
8- fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, rc));
9 assert(memcached_last_error(instance->root) != MEMCACHED_SUCCESS);
10 *value= UINT64_MAX;
11 }
12
13=== modified file 'libmemcached/connect.cc'
14--- libmemcached/connect.cc 2013-04-21 08:19:20 +0000
15+++ libmemcached/connect.cc 2013-10-11 11:04:39 +0000
16@@ -76,7 +76,7 @@
17 if (server->root->poll_timeout == 0)
18 {
19 return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT,
20- memcached_literal_param("The time to wait for a connection to be established was set to zero, which means it will always timeout (MEMCACHED_TIMEOUT)."));
21+ memcached_literal_param("The time to wait for a connection to be established was set to zero which produces a timeout to every call to poll()."));
22 }
23
24 while (--loop_max) // Should only loop on cases of ERESTART or EINTR
25
26=== modified file 'libmemcached/error.cc'
27--- libmemcached/error.cc 2013-03-31 23:24:29 +0000
28+++ libmemcached/error.cc 2013-10-11 11:04:39 +0000
29@@ -36,6 +36,9 @@
30 */
31
32 #include <libmemcached/common.h>
33+
34+#include "libmemcached/assert.hpp"
35+
36 #include <cerrno>
37 #include <cstdarg>
38 #include <cstdio>
39@@ -87,111 +90,133 @@
40 memcached_error_free(memc);
41 }
42
43- // For memory allocation we use our error since it is a bit more specific
44- if (local_errno == ENOMEM and rc == MEMCACHED_ERRNO)
45- {
46- rc= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
47- }
48-
49- if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE)
50- {
51- local_errno= ENOMEM;
52- }
53-
54- if (rc == MEMCACHED_ERRNO and not local_errno)
55- {
56- local_errno= errno;
57- rc= MEMCACHED_ERRNO;
58- }
59-
60- if (rc == MEMCACHED_ERRNO and local_errno == ENOTCONN)
61- {
62- rc= MEMCACHED_CONNECTION_FAILURE;
63- }
64-
65- if (rc == MEMCACHED_ERRNO and local_errno == ECONNRESET)
66- {
67- rc= MEMCACHED_CONNECTION_FAILURE;
68- }
69-
70- if (local_errno == EINVAL)
71- {
72- rc= MEMCACHED_INVALID_ARGUMENTS;
73- }
74-
75- if (local_errno == ECONNREFUSED)
76- {
77- rc= MEMCACHED_CONNECTION_FAILURE;
78- }
79-
80- memcached_error_t *error= libmemcached_xmalloc(&memc, memcached_error_t);
81- if (error == NULL) // Bad business if this happens
82- {
83- return;
84- }
85-
86- error->root= &memc;
87- error->query_id= memc.query_id;
88- error->rc= rc;
89- error->local_errno= local_errno;
90-
91- const char *errmsg_ptr;
92- char errmsg[MAX_ERROR_LENGTH];
93- errmsg[0]= 0;
94- errmsg_ptr= errmsg;
95-
96- if (local_errno)
97- {
98+ if (memcached_fatal(rc) or rc == MEMCACHED_CLIENT_ERROR)
99+ {
100+ // For memory allocation we use our error since it is a bit more specific
101+ if (local_errno == ENOMEM and rc == MEMCACHED_ERRNO)
102+ {
103+ rc= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
104+ }
105+
106+ if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE)
107+ {
108+ local_errno= ENOMEM;
109+ }
110+
111+ if (rc == MEMCACHED_ERRNO and not local_errno)
112+ {
113+ local_errno= errno;
114+ rc= MEMCACHED_ERRNO;
115+ }
116+
117+ if (rc == MEMCACHED_ERRNO and local_errno == ENOTCONN)
118+ {
119+ rc= MEMCACHED_CONNECTION_FAILURE;
120+ }
121+
122+ if (rc == MEMCACHED_ERRNO and local_errno == ECONNRESET)
123+ {
124+ rc= MEMCACHED_CONNECTION_FAILURE;
125+ }
126+
127+ if (local_errno == EINVAL)
128+ {
129+ rc= MEMCACHED_INVALID_ARGUMENTS;
130+ }
131+
132+ if (local_errno == ECONNREFUSED)
133+ {
134+ rc= MEMCACHED_CONNECTION_FAILURE;
135+ }
136+
137+ if (rc == MEMCACHED_TIMEOUT)
138+ {
139+ }
140+
141+ memcached_error_t *error= libmemcached_xmalloc(&memc, memcached_error_t);
142+ if (error == NULL) // Bad business if this happens
143+ {
144+ assert_msg(error, "libmemcached_xmalloc() failed to allocate a memcached_error_t");
145+ return;
146+ }
147+
148+ error->root= &memc;
149+ error->query_id= memc.query_id;
150+ error->rc= rc;
151+ error->local_errno= local_errno;
152+
153+ // MEMCACHED_CLIENT_ERROR is a special case because it is an error coming from the server
154+ if (rc == MEMCACHED_CLIENT_ERROR)
155+ {
156+ assert(str);
157+ assert(str->size);
158+ if (str and str->size)
159+ {
160+ assert(error->local_errno == 0);
161+ error->local_errno= 0;
162+
163+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %.*s",
164+ error->root,
165+ int(str->size), str->c_str);
166+ }
167+ }
168+ else if (local_errno)
169+ {
170+ const char *errmsg_ptr;
171+ char errmsg[MAX_ERROR_LENGTH];
172+ errmsg[0]= 0;
173+ errmsg_ptr= errmsg;
174+
175 #if defined(STRERROR_R_CHAR_P) && STRERROR_R_CHAR_P
176- errmsg_ptr= strerror_r(local_errno, errmsg, sizeof(errmsg));
177+ errmsg_ptr= strerror_r(local_errno, errmsg, sizeof(errmsg));
178 #elif defined(HAVE_STRERROR_R) && HAVE_STRERROR_R
179- strerror_r(local_errno, errmsg, sizeof(errmsg));
180- errmsg_ptr= errmsg;
181+ strerror_r(local_errno, errmsg, sizeof(errmsg));
182+ errmsg_ptr= errmsg;
183 #elif defined(HAVE_STRERROR) && HAVE_STRERROR
184- snprintf(errmsg, sizeof(errmsg), "%s", strerror(local_errno));
185- errmsg_ptr= errmsg;
186+ snprintf(errmsg, sizeof(errmsg), "%s", strerror(local_errno));
187+ errmsg_ptr= errmsg;
188 #endif
189- }
190-
191-
192- if (str and str->size and local_errno)
193- {
194- error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s), %.*s -> %s",
195- error->root,
196- memcached_strerror(&memc, rc),
197- errmsg_ptr,
198- memcached_string_printf(*str), at);
199- }
200- else if (local_errno)
201- {
202- error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s) -> %s",
203- error->root,
204- memcached_strerror(&memc, rc),
205- errmsg_ptr,
206- at);
207- }
208- else if (rc == MEMCACHED_PARSE_ERROR and str and str->size)
209- {
210- error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %.*s -> %s",
211- error->root,
212- int(str->size), str->c_str, at);
213- }
214- else if (str and str->size)
215- {
216- error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s, %.*s -> %s",
217- error->root,
218- memcached_strerror(&memc, rc),
219- int(str->size), str->c_str, at);
220- }
221- else
222- {
223- error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s -> %s",
224- error->root,
225- memcached_strerror(&memc, rc), at);
226- }
227-
228- error->next= memc.error_messages;
229- memc.error_messages= error;
230+
231+ if (str and str->size and local_errno)
232+ {
233+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s), %.*s -> %s",
234+ error->root,
235+ memcached_strerror(&memc, rc),
236+ errmsg_ptr,
237+ memcached_string_printf(*str), at);
238+ }
239+ else
240+ {
241+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s) -> %s",
242+ error->root,
243+ memcached_strerror(&memc, rc),
244+ errmsg_ptr,
245+ at);
246+ }
247+ }
248+ else if (rc == MEMCACHED_PARSE_ERROR and str and str->size)
249+ {
250+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %.*s -> %s",
251+ error->root,
252+ int(str->size), str->c_str, at);
253+ }
254+ else if (str and str->size)
255+ {
256+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s, %.*s -> %s",
257+ error->root,
258+ memcached_strerror(&memc, rc),
259+ int(str->size), str->c_str, at);
260+ }
261+ else
262+ {
263+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s -> %s",
264+ error->root,
265+ memcached_strerror(&memc, rc), at);
266+ }
267+
268+ error->next= memc.error_messages;
269+ memc.error_messages= error;
270+ }
271
272 #if 0
273 if (error_log_fd == -1)
274@@ -231,13 +256,11 @@
275 memcached_return_t memcached_set_error(Memcached& memc, memcached_return_t rc, const char *at, memcached_string_t& str)
276 {
277 assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client");
278- if (memcached_fatal(rc) == false)
279+ if (memcached_fatal(rc))
280 {
281- return rc;
282+ _set(memc, &str, rc, at);
283 }
284
285- _set(memc, &str, rc, at);
286-
287 return rc;
288 }
289
290@@ -299,17 +322,15 @@
291 memcached_string_t error_host= { hostname_port_message, size_t(size) };
292
293 assert_msg(self.root, "Programmer error, root was not set on instance");
294- if (self.root == NULL)
295+ if (self.root)
296 {
297- return rc;
298+ _set(*self.root, &error_host, rc, at);
299+ _set(self, (*self.root));
300+ assert(self.error_messages);
301+ assert(self.root->error_messages);
302+ assert(self.error_messages->rc == self.root->error_messages->rc);
303 }
304
305- _set(*self.root, &error_host, rc, at);
306- _set(self, (*self.root));
307- assert(self.root->error_messages);
308- assert(self.error_messages);
309- assert(self.error_messages->rc == self.root->error_messages->rc);
310-
311 return rc;
312 }
313
314@@ -326,14 +347,12 @@
315
316 memcached_string_t error_host= { hostname_port, size};
317
318- if (self.root == NULL)
319+ if (self.root)
320 {
321- return rc;
322+ _set(*self.root, &error_host, rc, at);
323+ _set(self, *self.root);
324 }
325
326- _set(*self.root, &error_host, rc, at);
327- _set(self, *self.root);
328-
329 return rc;
330 }
331
332@@ -528,7 +547,7 @@
333 {
334 if (memc->error_messages)
335 {
336- if (memc->error_messages->size == 0)
337+ if (memc->error_messages->size and memc->error_messages->message[0])
338 {
339 return memc->error_messages->message;
340 }
341
342=== modified file 'libmemcached/get.cc'
343--- libmemcached/get.cc 2013-03-31 23:24:29 +0000
344+++ libmemcached/get.cc 2013-10-11 11:04:39 +0000
345@@ -114,7 +114,6 @@
346 {
347 *error= MEMCACHED_NOTFOUND;
348 }
349-
350 if (value == NULL)
351 {
352 if (ptr->get_key_failure and *error == MEMCACHED_NOTFOUND)
353@@ -221,12 +220,14 @@
354
355 if (number_of_keys == 0)
356 {
357- return memcached_set_error(*ptr, MEMCACHED_NOTFOUND, MEMCACHED_AT, memcached_literal_param("number_of_keys was zero"));
358+ return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Numbers of keys provided was zero"));
359 }
360
361- if (memcached_failed(memcached_key_test(*ptr, keys, key_length, number_of_keys)))
362+ if (memcached_failed((rc= memcached_key_test(*ptr, keys, key_length, number_of_keys))))
363 {
364- return memcached_last_error(ptr);
365+ assert(memcached_last_error(ptr) == rc);
366+
367+ return rc;
368 }
369
370 bool is_group_key_set= false;
371@@ -463,6 +464,11 @@
372
373 bool flush= (number_of_keys == 1);
374
375+ if (memcached_failed(rc= memcached_key_test(*ptr, keys, key_length, number_of_keys)))
376+ {
377+ return rc;
378+ }
379+
380 /*
381 If a server fails we warn about errors and start all over with sending keys
382 to the server.
383@@ -502,10 +508,13 @@
384 request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK;
385 }
386
387+#if 0
388 {
389 memcached_return_t vk= memcached_validate_key_length(key_length[x], ptr->flags.binary_protocol);
390- if (vk != MEMCACHED_SUCCESS)
391+ if (memcached_failed(rc= memcached_key_test(*memc, (const char **)&key, &key_length, 1)))
392 {
393+ memcached_set_error(ptr, vk, MEMCACHED_AT, memcached_literal_param("Key was too long."));
394+
395 if (x > 0)
396 {
397 memcached_io_reset(instance);
398@@ -514,6 +523,7 @@
399 return vk;
400 }
401 }
402+#endif
403
404 request.message.header.request.keylen= htons((uint16_t)(key_length[x] + memcached_array_size(ptr->_namespace)));
405 request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
406
407=== modified file 'libmemcached/io.cc'
408--- libmemcached/io.cc 2013-07-18 10:28:37 +0000
409+++ libmemcached/io.cc 2013-10-11 11:04:39 +0000
410@@ -412,6 +412,11 @@
411 return io_wait(instance, MEM_WRITE);
412 }
413
414+memcached_return_t memcached_io_wait_for_read(memcached_instance_st* instance)
415+{
416+ return io_wait(instance, MEM_READ);
417+}
418+
419 static memcached_return_t _io_fill(memcached_instance_st* instance)
420 {
421 ssize_t data_read;
422
423=== modified file 'libmemcached/io.hpp'
424--- libmemcached/io.hpp 2013-03-31 23:24:29 +0000
425+++ libmemcached/io.hpp 2013-10-11 11:04:39 +0000
426@@ -49,7 +49,8 @@
427 libmemcached_io_vector_st vector[],
428 const size_t number_of, const bool with_flush);
429
430-memcached_return_t memcached_io_wait_for_write(memcached_instance_st* ptr);
431+memcached_return_t memcached_io_wait_for_write(memcached_instance_st*);
432+memcached_return_t memcached_io_wait_for_read(memcached_instance_st*);
433
434 void memcached_io_reset(memcached_instance_st* ptr);
435
436
437=== modified file 'libmemcached/key.cc'
438--- libmemcached/key.cc 2012-02-13 20:14:15 +0000
439+++ libmemcached/key.cc 2013-10-11 11:04:39 +0000
440@@ -37,47 +37,71 @@
441
442 #include <libmemcached/common.h>
443
444+static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool)
445+{
446+ if (key_length == 0)
447+ {
448+ return MEMCACHED_BAD_KEY_PROVIDED;
449+ }
450+
451+ // No one ever reimplemented MEMCACHED to use keys longer then the original ascii length
452+#if 0
453+ if (binary)
454+ {
455+ if (key_length > 0xffff)
456+ {
457+ return MEMCACHED_BAD_KEY_PROVIDED;
458+ }
459+ }
460+ else
461+#endif
462+ {
463+ if (key_length >= MEMCACHED_MAX_KEY)
464+ {
465+ return MEMCACHED_BAD_KEY_PROVIDED;
466+ }
467+ }
468+
469+ return MEMCACHED_SUCCESS;
470+}
471+
472 memcached_return_t memcached_key_test(memcached_st &memc,
473 const char * const *keys,
474 const size_t *key_length,
475 size_t number_of_keys)
476 {
477+ if (number_of_keys == 0)
478+ {
479+ return memcached_set_error(memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Numbers of keys provided was zero"));
480+ }
481+
482 if (keys == NULL or key_length == NULL)
483 {
484 return memcached_set_error(memc, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("Key was NULL or length of key was zero."));
485 }
486
487+ const bool is_binary= memcached_flag(memc, MEMCACHED_FLAG_BINARY_PROTOCOL);
488+
489 // If we don't need to verify the key, or we are using the binary protoocol,
490 // we just check the size of the key
491- if (memc.flags.verify_key == false or memc.flags.binary_protocol == true)
492- {
493- for (size_t x= 0; x < number_of_keys; x++)
494- {
495- // We should set binary key, but the memcached server is broken for
496- // longer keys at the moment.
497- memcached_return_t rc= memcached_validate_key_length(*(key_length +x), false /* memc.flags.binary_protocol */);
498- if (memcached_failed(rc))
499- {
500- return memcached_set_error(memc, rc, MEMCACHED_AT, memcached_literal_param("Key provided was too long."));
501- }
502- }
503-
504- return MEMCACHED_SUCCESS;
505- }
506-
507- for (size_t x= 0; x < number_of_keys; x++)
508- {
509- memcached_return_t rc= memcached_validate_key_length(*(key_length + x), false);
510+ for (size_t x= 0; x < number_of_keys; ++x)
511+ {
512+ // We should set binary key, but the memcached server is broken for
513+ // longer keys at the moment.
514+ memcached_return_t rc= memcached_validate_key_length(*(key_length +x), false /* memc.flags.binary_protocol */);
515 if (memcached_failed(rc))
516 {
517 return memcached_set_error(memc, rc, MEMCACHED_AT, memcached_literal_param("Key provided was too long."));
518 }
519-
520- for (size_t y= 0; y < *(key_length + x); y++)
521+
522+ if (memc.flags.verify_key and is_binary == false)
523 {
524- if ((isgraph(keys[x][y])) == 0)
525+ for (size_t y= 0; y < *(key_length +x); ++y)
526 {
527- return memcached_set_error(memc, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("Key provided had invalid character."));
528+ if ((isgraph(keys[x][y])) == 0)
529+ {
530+ return memcached_set_error(memc, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("Key provided had invalid character."));
531+ }
532 }
533 }
534 }
535
536=== modified file 'libmemcached/key.hpp'
537--- libmemcached/key.hpp 2011-10-02 23:49:04 +0000
538+++ libmemcached/key.hpp 2013-10-11 11:04:39 +0000
539@@ -41,27 +41,3 @@
540 const size_t *key_length,
541 size_t number_of_keys);
542
543-static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool binary)
544-{
545- if (key_length == 0)
546- {
547- return MEMCACHED_BAD_KEY_PROVIDED;
548- }
549-
550- if (binary)
551- {
552- if (key_length > 0xffff)
553- {
554- return MEMCACHED_BAD_KEY_PROVIDED;
555- }
556- }
557- else
558- {
559- if (key_length >= MEMCACHED_MAX_KEY)
560- {
561- return MEMCACHED_BAD_KEY_PROVIDED;
562- }
563- }
564-
565- return MEMCACHED_SUCCESS;
566-}
567
568=== modified file 'libmemcached/response.cc'
569--- libmemcached/response.cc 2013-03-31 23:24:29 +0000
570+++ libmemcached/response.cc 2013-10-11 11:04:39 +0000
571@@ -500,6 +500,8 @@
572 memcached_return_t rc;
573 protocol_binary_response_header header;
574
575+ assert(memcached_is_binary(instance->root));
576+
577 if ((rc= memcached_safe_read(instance, &header.bytes, sizeof(header.bytes))) != MEMCACHED_SUCCESS)
578 {
579 WATCHPOINT_ERROR(rc);
580@@ -892,12 +894,19 @@
581 return memcached_set_error(*instance, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT);
582 }
583
584- /* We may have old commands in the buffer not set, first purge */
585+ /* We may have old commands in the buffer not sent, first purge */
586 if ((instance->root->flags.no_block) and (memcached_is_processing_input(instance->root) == false))
587 {
588 (void)memcached_io_write(instance);
589 }
590
591+ /* Before going into loop wait to see if we have any IO waiting for us */
592+ if (0)
593+ {
594+ memcached_return_t read_rc= memcached_io_wait_for_read(instance);
595+ fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, memcached_strerror(NULL, read_rc));
596+ }
597+
598 /*
599 * The previous implementation purged all pending requests and just
600 * returned the last one. Purge all pending messages to ensure backwards
601
602=== modified file 'libmemcached/stats.cc'
603--- libmemcached/stats.cc 2013-03-31 23:24:29 +0000
604+++ libmemcached/stats.cc 2013-10-11 11:04:39 +0000
605@@ -346,7 +346,7 @@
606 return MEMCACHED_SUCCESS;
607 }
608
609-char *memcached_stat_get_value(const memcached_st *, memcached_stat_st *memc_stat,
610+char *memcached_stat_get_value(const memcached_st* shell, memcached_stat_st *memc_stat,
611 const char *key, memcached_return_t *error)
612 {
613 memcached_return_t not_used;
614@@ -456,13 +456,15 @@
615 }
616 else
617 {
618- *error= MEMCACHED_NOTFOUND;
619+ Memcached* memc= (Memcached*)memcached2Memcached(shell);
620+ *error= memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid key provided"));
621 return NULL;
622 }
623
624 if (length >= SMALL_STRING_LEN || length < 0)
625 {
626- *error= MEMCACHED_FAILURE;
627+ Memcached* memc= (Memcached*)memcached2Memcached(shell);
628+ *error= memcached_set_error(*memc, MEMCACHED_FAILURE, MEMCACHED_AT, memcached_literal_param("Internal failure occured with buffer, please report this bug."));
629 return NULL;
630 }
631
632@@ -658,8 +660,7 @@
633 if (args)
634 {
635 args_length= strlen(args);
636- rc= memcached_validate_key_length(args_length, self->flags.binary_protocol);
637- if (memcached_failed(rc))
638+ if (memcached_failed(rc= memcached_key_test(*self, (const char **)&args, &args_length, 1)))
639 {
640 *error= memcached_set_error(*self, rc, MEMCACHED_AT);
641 return NULL;
642@@ -746,7 +747,7 @@
643 if (args)
644 {
645 args_length= strlen(args);
646- rc= memcached_validate_key_length(args_length, memc.flags.binary_protocol);
647+ rc= memcached_key_test(*memc_ptr, (const char **)&args, &args_length, 1);
648 }
649
650 if (memcached_success(rc))
651
652=== modified file 'libmemcached/touch.cc'
653--- libmemcached/touch.cc 2013-03-31 23:24:29 +0000
654+++ libmemcached/touch.cc 2013-10-11 11:04:39 +0000
655@@ -124,9 +124,9 @@
656 return rc;
657 }
658
659- if (memcached_failed(rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol)))
660+ if (memcached_failed(rc= memcached_key_test(*ptr, (const char **)&key, &key_length, 1)))
661 {
662- return rc;
663+ return memcached_set_error(*ptr, rc, MEMCACHED_AT);
664 }
665
666 uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length);
667
668=== modified file 'm4/ax_pthread.m4'
669--- m4/ax_pthread.m4 2012-11-04 06:54:36 +0000
670+++ m4/ax_pthread.m4 2013-10-11 11:04:39 +0000
671@@ -82,7 +82,7 @@
672 # modified version of the Autoconf Macro, you may extend this special
673 # exception to the GPL to apply to your modified version as well.
674
675-#serial 19
676+#serial 20
677
678 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
679 AC_DEFUN([AX_PTHREAD], [
680@@ -159,10 +159,6 @@
681 ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
682 ;;
683
684- darwin12*)
685- ax_pthread_flags="$ax_pthread_flags"
686- ;;
687-
688 darwin*)
689 ax_pthread_flags="-pthread $ax_pthread_flags"
690 ;;
691@@ -287,16 +283,24 @@
692 LIBS="$save_LIBS"
693 CFLAGS="$save_CFLAGS"
694
695- # More AIX lossage: must compile with xlc_r or cc_r
696- if test x"$GCC" != xyes; then
697- AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
698- else
699- PTHREAD_CC=$CC
700+ # More AIX lossage: compile with *_r variant
701+ if test "x$GCC" != xyes; then
702+ case $host_os in
703+ aix*)
704+ AS_CASE(["x/$CC"],
705+ [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
706+ [#handle absolute path differently from PATH based program lookup
707+ AS_CASE(["x$CC"],
708+ [x/*],
709+ [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
710+ [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
711+ ;;
712+ esac
713 fi
714-else
715- PTHREAD_CC="$CC"
716 fi
717
718+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
719+
720 AC_SUBST(PTHREAD_LIBS)
721 AC_SUBST(PTHREAD_CFLAGS)
722 AC_SUBST(PTHREAD_CC)
723
724=== modified file 'tests/cli.am'
725--- tests/cli.am 2013-05-03 20:00:36 +0000
726+++ tests/cli.am 2013-10-11 11:04:39 +0000
727@@ -122,3 +122,12 @@
728
729 valgrind-memtouch: tests/memtouch
730 @$(VALGRIND_COMMAND) tests/memtouch
731+
732+test-memdump: tests/memdump
733+ tests/memdump
734+
735+gdb-memdump: tests/memdump
736+ @$(GDB_COMMAND) tests/memdump
737+
738+valgrind-memdump: tests/memdump
739+ @$(VALGRIND_COMMAND) tests/memdump
740
741=== modified file 'tests/libmemcached-1.0/mem_functions.cc'
742--- tests/libmemcached-1.0/mem_functions.cc 2013-09-15 07:19:20 +0000
743+++ tests/libmemcached-1.0/mem_functions.cc 2013-10-11 11:04:39 +0000
744@@ -993,6 +993,7 @@
745 test_compare(MEMCACHED_SUCCESS,
746 memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, true));
747 test_compare(query_id, memcached_query_id(memc_clone)); // We should not increase the query_id for memcached_behavior_set()
748+ ASSERT_TRUE(memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY));
749
750 /* All keys are valid in the binary protocol (except for length) */
751 if (memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == false)
752@@ -3081,7 +3082,7 @@
753 const char *key= "mine";
754 char *value;
755
756- /* Make sure be default none exists */
757+ /* Make sure by default none exists */
758 value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
759 test_null(value);
760 test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
761@@ -3092,7 +3093,7 @@
762
763 value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
764 test_true(value);
765- test_memcmp(value, key, 4);
766+ test_memcmp(value, key, strlen(key));
767 test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
768
769 /* Test that we can turn it off */
770@@ -3110,7 +3111,7 @@
771 value= (char *)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
772 test_true(value);
773 test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
774- test_memcmp(value, key, 4);
775+ test_memcmp(value, key, strlen(key));
776
777 /* Set to Zero, and then Set to something too large */
778 {
779@@ -3120,9 +3121,7 @@
780 test_compare(MEMCACHED_SUCCESS,
781 memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, NULL));
782
783- value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
784- test_null(value);
785- test_compare(MEMCACHED_SUCCESS, rc);
786+ ASSERT_NULL_(memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc), "Setting namespace to NULL did not work");
787
788 /* Test a long key for failure */
789 /* TODO, extend test to determine based on setting, what result should be */
790@@ -3150,11 +3149,10 @@
791 {
792 memcached_return_t rc;
793 const char *key= "mine";
794- char *value;
795
796 // Make sure we default to a null namespace
797- value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
798- test_null(value);
799+ char* value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
800+ ASSERT_NULL_(value, "memc had a value for namespace when none should exist");
801 test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
802
803 /* Test a clean set */
804@@ -3162,8 +3160,8 @@
805 memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, (void *)key));
806
807 value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
808- test_true(value);
809- test_memcmp(value, key, 4);
810+ ASSERT_TRUE(value);
811+ test_memcmp(value, key, strlen(key));
812 test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
813
814 return TEST_SUCCESS;
815
816=== modified file 'tests/libmemcached_world.h'
817--- tests/libmemcached_world.h 2013-04-21 08:19:20 +0000
818+++ tests/libmemcached_world.h 2013-10-11 11:04:39 +0000
819@@ -87,12 +87,14 @@
820 static bool world_destroy(void *object)
821 {
822 libmemcached_test_container_st *container= (libmemcached_test_container_st *)object;
823+#if 0
824 #if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
825 if (LIBMEMCACHED_WITH_SASL_SUPPORT)
826 {
827 sasl_done();
828 }
829 #endif
830+#endif
831
832 delete container;
833
834
835=== modified file 'tests/libmemcached_world_socket.h'
836--- tests/libmemcached_world_socket.h 2013-01-24 11:17:17 +0000
837+++ tests/libmemcached_world_socket.h 2013-10-11 11:04:39 +0000
838@@ -75,12 +75,15 @@
839 static bool world_destroy(void *object)
840 {
841 libmemcached_test_container_st *container= (libmemcached_test_container_st *)object;
842+
843+#if 0
844 #if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
845 if (LIBMEMCACHED_WITH_SASL_SUPPORT)
846 {
847 sasl_done();
848 }
849 #endif
850+#endif
851
852 delete container;
853
854
855=== modified file 'tests/memdump.cc'
856--- tests/memdump.cc 2013-08-06 10:04:31 +0000
857+++ tests/memdump.cc 2013-10-11 11:04:39 +0000
858@@ -111,19 +111,11 @@
859 {0, 0, 0, 0}
860 };
861
862-static void *world_create(server_startup_st& servers, test_return_t& error)
863+static void *world_create(server_startup_st& servers, test_return_t&)
864 {
865- if (libtest::has_memcached() == false)
866- {
867- error= TEST_SKIPPED;
868- return NULL;
869- }
870+ SKIP_UNLESS(libtest::has_memcached());
871
872- if (server_startup(servers, "memcached", libtest::default_port(), NULL) == false)
873- {
874- error= TEST_FAILURE;
875- return NULL;
876- }
877+ ASSERT_TRUE(server_startup(servers, "memcached", libtest::default_port(), NULL));
878
879 return &servers;
880 }

Subscribers

People subscribed via source and target branches

to all changes: