Merge lp:~trond-norbye/libmemcached/no-docs into lp:~brianaker/libmemcached/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
Reviewer Review Type Date Requested Status
Libmemcached-developers Pending
Review via email: mp+30556@code.launchpad.net

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 :

This was applied to the tree a while ago.

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
=== modified file '.bzrignore'
--- .bzrignore 2010-02-21 10:59:22 +0000
+++ .bzrignore 2010-07-21 16:27:47 +0000
@@ -181,3 +181,4 @@
181tests/testhashkit181tests/testhashkit
182tests/testplus182tests/testplus
183tests/testudp183tests/testudp
184unittests/unittests
184185
=== modified file 'ChangeLog'
--- ChangeLog 2010-06-11 01:43:08 +0000
+++ ChangeLog 2010-07-21 16:27:47 +0000
@@ -1,6 +1,15 @@
10.4110.43
2 * memcached_stat_execute() merged.
3
40.42 Tue Jul 6 12:29:50 PDT 2010
5 * Mistake in libtool caused issue with library version
6
70.41 Wed Jun 30 13:15:19 PDT 2010
2 * Added --file for memcat.8 * Added --file for memcat.
3 * Added limemcached_ping() to libmemcached_util9 * Added limemcached_ping() to libmemcached_util
10 * Bugfix for some cases where connect would have issues with timeout.
11 * Wrong value for errno given as error on an IO failure inside of poll.
12 * Bug fix for issue where multiple interfaces with bad DNS were not being caught.
413
50.40 Thu Apr 22 19:01:25 PDT 2010140.40 Thu Apr 22 19:01:25 PDT 2010
6 * Placed retry logic in for busted resolvers15 * Placed retry logic in for busted resolvers
716
=== modified file 'Makefile.am'
--- Makefile.am 2010-06-13 16:21:08 +0000
+++ Makefile.am 2010-07-21 16:27:47 +0000
@@ -12,6 +12,7 @@
12noinst_PROGRAMS =12noinst_PROGRAMS =
13include_HEADERS =13include_HEADERS =
14nobase_include_HEADERS =14nobase_include_HEADERS =
15check_PROGRAMS =
15EXTRA_HEADERS =16EXTRA_HEADERS =
16BUILT_SOURCES=17BUILT_SOURCES=
17EXTRA_DIST= \18EXTRA_DIST= \
@@ -29,19 +30,23 @@
29 m4/po.m4 \30 m4/po.m4 \
30 m4/progtest.m431 m4/progtest.m4
3132
3233TEST_DOCS=
34if BUILD_DOCS
33SUBDIRS = docs35SUBDIRS = docs
36TEST_DOCS+=test-docs
37endif
3438
35test-docs:39test-docs:
36 (cd docs && $(MAKE) test-docs)40 (cd docs && $(MAKE) test-docs)
37include libmemcached/include.am41include libmemcached/include.am
38include clients/include.am42include clients/include.am
39include libhashkit/include.am43include libhashkit/include.am
44include unittests/include.am
40include tests/include.am45include tests/include.am
41include example/include.am46include example/include.am
42include support/include.am47include support/include.am
4348
44check-local: test-no-outputdiff49TESTS += ${check_PROGRAMS}
4550
4651
47fedora:52fedora:
@@ -82,7 +87,7 @@
82 genhtml -o lcov --function-coverage -t libmemcached libmemcached/lcov.out87 genhtml -o lcov --function-coverage -t libmemcached libmemcached/lcov.out
8388
84lcov-clean: clean89lcov-clean: clean
85 rm -rf lcov */lcov.out 90 rm -rf lcov */lcov.out
86 find . -name '*.gcno' | xargs rm -f91 find . -name '*.gcno' | xargs rm -f
87 find . -name '*.gcda' | xargs rm -f92 find . -name '*.gcda' | xargs rm -f
8893
8994
=== modified file 'clients/execute.c'
--- clients/execute.c 2010-01-16 01:50:37 +0000
+++ clients/execute.c 2010-07-21 16:27:47 +0000
@@ -14,8 +14,7 @@
14 Return the number of rows set.14 Return the number of rows set.
15*/15*/
1616
17#include "libmemcached/common.h"17#include "config.h"
18
19#include "execute.h"18#include "execute.h"
2019
21unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of)20unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of)
@@ -108,12 +107,11 @@
108 rc= memcached_mget_execute(memc, keys, key_length,107 rc= memcached_mget_execute(memc, keys, key_length,
109 (size_t)number_of, callbacks, &retrieved, 1);108 (size_t)number_of, callbacks, &retrieved, 1);
110109
111 likely (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOTFOUND ||110 if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOTFOUND ||
112 rc == MEMCACHED_BUFFERED || rc == MEMCACHED_END)111 rc == MEMCACHED_BUFFERED || rc == MEMCACHED_END)
113 {112 {
114 rc= memcached_fetch_execute(memc, callbacks, (void *)&retrieved, 1);113 rc= memcached_fetch_execute(memc, callbacks, (void *)&retrieved, 1);
115 unlikely (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_NOTFOUND &&114 if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_NOTFOUND && rc != MEMCACHED_END)
116 rc != MEMCACHED_END)
117 {115 {
118 fprintf(stderr, "Failed to execute mget: %s\n",116 fprintf(stderr, "Failed to execute mget: %s\n",
119 memcached_strerror(memc, rc));117 memcached_strerror(memc, rc));
120118
=== modified file 'clients/execute.h'
--- clients/execute.h 2009-12-16 19:03:49 +0000
+++ clients/execute.h 2010-07-21 16:27:47 +0000
@@ -11,6 +11,9 @@
1111
12#ifndef CLIENTS_EXECUTE_H12#ifndef CLIENTS_EXECUTE_H
13#define CLIENTS_EXECUTE_H13#define CLIENTS_EXECUTE_H
14
15#include <stdio.h>
16
14#include "libmemcached/memcached.h"17#include "libmemcached/memcached.h"
15#include "generator.h"18#include "generator.h"
1619
1720
=== modified file 'clients/generator.c'
--- clients/generator.c 2010-04-22 00:49:09 +0000
+++ clients/generator.c 2010-07-21 16:27:47 +0000
@@ -9,7 +9,7 @@
9 *9 *
10 */10 */
1111
12#include "libmemcached/common.h"12#include "config.h"
1313
14#include <stdio.h>14#include <stdio.h>
15#include <stdlib.h>15#include <stdlib.h>
1616
=== modified file 'clients/memcat.c'
--- clients/memcat.c 2010-06-08 19:05:16 +0000
+++ clients/memcat.c 2010-07-21 16:27:47 +0000
@@ -9,7 +9,8 @@
9 *9 *
10 */10 */
1111
12#include "libmemcached/common.h"12#include "config.h"
13
13#include <stdio.h>14#include <stdio.h>
14#include <inttypes.h>15#include <inttypes.h>
15#include <string.h>16#include <string.h>
1617
=== modified file 'clients/memcp.c'
--- clients/memcp.c 2010-03-03 10:50:13 +0000
+++ clients/memcp.c 2010-07-21 16:27:47 +0000
@@ -9,7 +9,8 @@
9 *9 *
10 */10 */
1111
12#include "libmemcached/common.h"12#include "config.h"
13
13#include <stdio.h>14#include <stdio.h>
14#include <stdlib.h>15#include <stdlib.h>
15#include <inttypes.h>16#include <inttypes.h>
@@ -22,6 +23,10 @@
22#include <errno.h>23#include <errno.h>
23#include <strings.h>24#include <strings.h>
24#include <string.h>25#include <string.h>
26#include <sys/types.h>
27#include <stdlib.h>
28#include <limits.h>
29
2530
26#include <libmemcached/memcached.h>31#include <libmemcached/memcached.h>
2732
2833
=== modified file 'clients/memdump.c'
--- clients/memdump.c 2010-03-03 10:50:13 +0000
+++ clients/memdump.c 2010-07-21 16:27:47 +0000
@@ -9,7 +9,8 @@
9 *9 *
10 */10 */
1111
12#include "libmemcached/common.h"12#include "config.h"
13
13#include <stdio.h>14#include <stdio.h>
14#include <stdlib.h>15#include <stdlib.h>
15#include <inttypes.h>16#include <inttypes.h>
1617
=== modified file 'clients/memerror.c'
--- clients/memerror.c 2010-01-14 21:37:53 +0000
+++ clients/memerror.c 2010-07-21 16:27:47 +0000
@@ -8,8 +8,8 @@
8 * Summary:8 * Summary:
9 *9 *
10 */10 */
11#include "config.h"
1112
12#include "libmemcached/common.h"
13#include <stdio.h>13#include <stdio.h>
14#include <inttypes.h>14#include <inttypes.h>
15#include <string.h>15#include <string.h>
1616
=== modified file 'clients/memflush.c'
--- clients/memflush.c 2010-03-03 10:50:13 +0000
+++ clients/memflush.c 2010-07-21 16:27:47 +0000
@@ -8,8 +8,8 @@
8 * Summary:8 * Summary:
9 *9 *
10 */10 */
11#include "config.h"
1112
12#include "libmemcached/common.h"
13#include <stdio.h>13#include <stdio.h>
14#include <unistd.h>14#include <unistd.h>
15#include <string.h>15#include <string.h>
1616
=== modified file 'clients/memrm.c'
--- clients/memrm.c 2010-03-03 10:50:13 +0000
+++ clients/memrm.c 2010-07-21 16:27:47 +0000
@@ -8,8 +8,8 @@
8 * Summary:8 * Summary:
9 *9 *
10 */10 */
11#include "config.h"
1112
12#include "libmemcached/common.h"
13#include <stdio.h>13#include <stdio.h>
14#include <unistd.h>14#include <unistd.h>
15#include <getopt.h>15#include <getopt.h>
1616
=== modified file 'clients/memstat.c'
--- clients/memstat.c 2010-03-10 00:45:36 +0000
+++ clients/memstat.c 2010-07-21 16:27:47 +0000
@@ -11,8 +11,8 @@
11 * Brian Aker11 * Brian Aker
12 * Toru Maesaka12 * Toru Maesaka
13 */13 */
14#include "config.h"
1415
15#include "libmemcached/common.h"
16#include <stdio.h>16#include <stdio.h>
17#include <sys/types.h>17#include <sys/types.h>
18#include <sys/stat.h>18#include <sys/stat.h>
@@ -56,36 +56,22 @@
56};56};
5757
5858
59static memcached_return_t server_print_callback(const memcached_st *memc,59static memcached_return_t stat_printer(memcached_server_instance_st instance,
60 memcached_server_instance_st instance,60 const char *key, size_t key_length,
61 void *context)61 const char *value, size_t value_length,
62 void *context)
62{63{
63 memcached_stat_st server_stat;64 static memcached_server_instance_st last= NULL;
64 memcached_return_t rc;
65 char **list;
66 char **ptr;
67
68 (void)context;65 (void)context;
6966
70 rc= memcached_stat_servername(&server_stat, NULL,67 if (last != instance)
71 memcached_server_name(instance),
72 memcached_server_port(instance));
73
74 list= memcached_stat_get_keys(memc, &server_stat, &rc);
75
76 printf("Server: %s (%u)\n", memcached_server_name(instance),
77 (uint32_t)memcached_server_port(instance));
78
79 for (ptr= list; *ptr; ptr++)
80 {68 {
81 char *value= memcached_stat_get_value(memc, &server_stat, *ptr, &rc);69 printf("Server: %s (%u)\n", memcached_server_name(instance),
8270 (uint32_t)memcached_server_port(instance));
83 printf("\t %s: %s\n", *ptr, value);71 last= instance;
84 free(value);
85 }72 }
8673
87 free(list);74 printf("\t %.*s: %.*s\n", (int)key_length, key, (int)value_length, value);
88 printf("\n");
8975
90 return MEMCACHED_SUCCESS;76 return MEMCACHED_SUCCESS;
91}77}
@@ -140,12 +126,7 @@
140 }126 }
141 else127 else
142 {128 {
143 memcached_server_fn callbacks[1];129 rc= memcached_stat_execute(memc, NULL, stat_printer, NULL);
144
145 callbacks[0]= server_print_callback;
146 rc= memcached_server_cursor(memc, callbacks,
147 NULL, 1);
148
149 }130 }
150131
151 free(opt_servers);132 free(opt_servers);
152133
=== modified file 'clients/utilities.c'
--- clients/utilities.c 2010-05-24 09:08:06 +0000
+++ clients/utilities.c 2010-07-21 16:27:47 +0000
@@ -8,8 +8,8 @@
8 * Summary:8 * Summary:
9 *9 *
10 */10 */
11#include "config.h"
1112
12#include "libmemcached/common.h"
13#include <stdio.h>13#include <stdio.h>
14#include <ctype.h>14#include <ctype.h>
15#include <string.h>15#include <string.h>
1616
=== modified file 'clients/utilities.h'
--- clients/utilities.h 2010-03-03 10:50:13 +0000
+++ clients/utilities.h 2010-07-21 16:27:47 +0000
@@ -11,6 +11,7 @@
1111
12#include <getopt.h>12#include <getopt.h>
13#include <libmemcached/memcached.h>13#include <libmemcached/memcached.h>
14#include "libmemcached/watchpoint.h"
14#include "client_options.h"15#include "client_options.h"
1516
16#if TIME_WITH_SYS_TIME17#if TIME_WITH_SYS_TIME
1718
=== modified file 'configure.ac'
--- configure.ac 2010-06-13 15:01:04 +0000
+++ configure.ac 2010-07-21 16:27:47 +0000
@@ -7,14 +7,16 @@
7# the COPYING file in this directory for full text.7# the COPYING file in this directory for full text.
88
9AC_PREREQ(2.59)9AC_PREREQ(2.59)
10AC_INIT([libmemcached],[0.41],[http://libmemcached.org/])10AC_INIT([libmemcached],[0.42],[http://libmemcached.org/])
11AC_CONFIG_SRCDIR([libmemcached/memcached.c])11AC_CONFIG_SRCDIR([libmemcached/memcached.c])
12AC_CONFIG_AUX_DIR(config)12AC_CONFIG_AUX_DIR(config)
1313
14PANDORA_CANONICAL_TARGET14PANDORA_CANONICAL_TARGET
1515
16#shared library versioning16#shared library versioning
17MEMCACHED_LIBRARY_VERSION=5:1:117MEMCACHED_UTIL_LIBRARY_VERSION=1:0:0
18MEMCACHED_PROTOCAL_LIBRARY_VERSION=0:0:0
19MEMCACHED_LIBRARY_VERSION=5:1:0
18# | | |20# | | |
19# +------+ | +---+21# +------+ | +---+
20# | | |22# | | |
@@ -25,6 +27,8 @@
25# | +- increment if source code has changed27# | +- increment if source code has changed
26# | set to zero if current is incremented28# | set to zero if current is incremented
27# +- increment if interfaces have been added, removed or changed29# +- increment if interfaces have been added, removed or changed
30AC_SUBST(MEMCACHED_UTIL_LIBRARY_VERSION)
31AC_SUBST(MEMCACHED_PROTOCAL_LIBRARY_VERSION)
28AC_SUBST(MEMCACHED_LIBRARY_VERSION)32AC_SUBST(MEMCACHED_LIBRARY_VERSION)
2933
3034
@@ -36,6 +40,7 @@
3640
37AC_CHECK_FUNCS([getline])41AC_CHECK_FUNCS([getline])
3842
43PANDORA_HAVE_LIBGTEST
39PANDORA_HAVE_LIBEVENT44PANDORA_HAVE_LIBEVENT
40PANDORA_REQUIRE_PTHREAD45PANDORA_REQUIRE_PTHREAD
41PANDORA_CXX_DEMANGLE46PANDORA_CXX_DEMANGLE
@@ -45,8 +50,6 @@
45ENABLE_UTILLIB50ENABLE_UTILLIB
46SETSOCKOPT_SANITY51SETSOCKOPT_SANITY
47ENABLE_HSIEH_HASH52ENABLE_HSIEH_HASH
48REQUIRE_POD2MAN
49REQUIRE_PODCHECKER
50PROTOCOL_BINARY_TEST53PROTOCOL_BINARY_TEST
51WITH_MEMCACHED54WITH_MEMCACHED
52ENABLE_DEPRECATED55ENABLE_DEPRECATED
@@ -68,6 +71,20 @@
68 [1],71 [1],
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])])])
7073
74AC_ARG_WITH([docs],
75 [AS_HELP_STRING([--with-docs],
76 [Generate documentation (yes|no) @<:@default=yes@:>@])],
77 [with_docs=$withval],
78 [with_docs=yes])
79
80AS_IF([test "$with_docs" = "yes"],
81 [
82 REQUIRE_POD2MAN
83 REQUIRE_PODCHECKER
84 ])
85AM_CONDITIONAL(BUILD_DOCS, test "$with_docs" = "yes")
86
87
71AC_CONFIG_FILES([88AC_CONFIG_FILES([
72 Makefile89 Makefile
73 docs/Makefile90 docs/Makefile
@@ -104,3 +121,13 @@
104 ;;121 ;;
105esac122esac
106123
124AS_IF(test "$with_docs" = "no",
125 [
126 echo "*****"
127 echo "*"
128 echo "* WARNING: You are not generating any documentation."
129 echo "* Please don't ship libmemcached to an end user"
130 echo "* without documentation..."
131 echo "*"
132 echo "*****"
133 ])
107134
=== modified file 'libhashkit/hsieh.c'
--- libhashkit/hsieh.c 2010-01-19 23:39:13 +0000
+++ libhashkit/hsieh.c 2010-07-21 16:27:47 +0000
@@ -17,7 +17,7 @@
17 +(uint32_t)(((const uint8_t *)(d))[0]) )17 +(uint32_t)(((const uint8_t *)(d))[0]) )
18#endif18#endif
1919
20uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context__attribute__((unused)))20uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context __attribute__((unused)))
21{21{
22 uint32_t hash = 0, tmp;22 uint32_t hash = 0, tmp;
23 int rem;23 int rem;
@@ -43,16 +43,18 @@
43 {43 {
44 case 3: hash += get16bits (key);44 case 3: hash += get16bits (key);
45 hash ^= hash << 16;45 hash ^= hash << 16;
46 hash ^= key[sizeof (uint16_t)] << 18;46 hash ^= (uint32_t)key[sizeof (uint16_t)] << 18;
47 hash += hash >> 11;47 hash += hash >> 11;
48 break;48 break;
49 case 2: hash += get16bits (key);49 case 2: hash += get16bits (key);
50 hash ^= hash << 11;50 hash ^= hash << 11;
51 hash += hash >> 17;51 hash += hash >> 17;
52 break;52 break;
53 case 1: hash += *key;53 case 1: hash += (unsigned char)(*key);
54 hash ^= hash << 10;54 hash ^= hash << 10;
55 hash += hash >> 1;55 hash += hash >> 1;
56 default:
57 break;
56 }58 }
5759
58 /* Force "avalanching" of final 127 bits */60 /* Force "avalanching" of final 127 bits */
5961
=== modified file 'libmemcached/behavior.c'
--- libmemcached/behavior.c 2010-04-05 19:01:19 +0000
+++ libmemcached/behavior.c 2010-07-21 16:27:47 +0000
@@ -55,6 +55,7 @@
55 ptr->server_failure_limit= (uint32_t)data;55 ptr->server_failure_limit= (uint32_t)data;
56 break;56 break;
57 case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL:57 case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL:
58 memcached_quit(ptr); // We need t shutdown all of the connections to make sure we do the correct protocol
58 if (data)59 if (data)
59 {60 {
60 ptr->flags.verify_key= false;61 ptr->flags.verify_key= false;
6162
=== modified file 'libmemcached/common.h'
--- libmemcached/common.h 2010-04-21 03:14:19 +0000
+++ libmemcached/common.h 2010-07-21 16:27:47 +0000
@@ -56,9 +56,17 @@
5656
57typedef struct memcached_server_st * memcached_server_write_instance_st;57typedef struct memcached_server_st * memcached_server_write_instance_st;
5858
59typedef memcached_return_t (*memcached_server_execute_fn)(memcached_st *ptr, memcached_server_write_instance_st server, void *context);
60
59LIBMEMCACHED_LOCAL61LIBMEMCACHED_LOCAL
60memcached_server_write_instance_st memcached_server_instance_fetch(memcached_st *ptr, uint32_t server_key);62memcached_server_write_instance_st memcached_server_instance_fetch(memcached_st *ptr, uint32_t server_key);
6163
64LIBMEMCACHED_LOCAL
65memcached_return_t memcached_server_execute(memcached_st *ptr,
66 memcached_server_execute_fn callback,
67 void *context);
68
69
62/* These are private not to be installed headers */70/* These are private not to be installed headers */
63#include "libmemcached/io.h"71#include "libmemcached/io.h"
64#include "libmemcached/do.h"72#include "libmemcached/do.h"
@@ -79,7 +87,7 @@
79typedef enum {87typedef enum {
80 MEM_NOT= -1,88 MEM_NOT= -1,
81 MEM_FALSE= false,89 MEM_FALSE= false,
82 MEM_TRUE= true,90 MEM_TRUE= true
83} memcached_ternary_t;91} memcached_ternary_t;
8492
8593
8694
=== modified file 'libmemcached/connect.c'
--- libmemcached/connect.c 2010-06-13 21:04:20 +0000
+++ libmemcached/connect.c 2010-07-21 16:27:47 +0000
@@ -1,9 +1,96 @@
1/* LibMemcached
2 * Copyright (C) 2006-2010 Brian Aker
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 *
8 * Summary: Server IO, Not public!
9 *
10 */
11
1#include "common.h"12#include "common.h"
2#include <netdb.h>13#include <netdb.h>
3#include <poll.h>14#include <poll.h>
4#include <sys/time.h>15#include <sys/time.h>
5#include <time.h>16#include <time.h>
617
18static memcached_return_t connect_poll(memcached_server_st *ptr)
19{
20 struct pollfd fds[1];
21 fds[0].fd = ptr->fd;
22 fds[0].events = POLLOUT;
23
24 int timeout= ptr->root->connect_timeout;
25 if (ptr->root->flags.no_block == true)
26 timeout= -1;
27
28 int error;
29 size_t loop_max= 5;
30
31 while (--loop_max) // Should only loop on cases of ERESTART or EINTR
32 {
33 error= poll(fds, 1, timeout);
34
35 switch (error)
36 {
37 case 1:
38 {
39 int err;
40 socklen_t len= sizeof (err);
41 (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len);
42
43 // We check the value to see what happened wth the socket.
44 if (err == 0)
45 {
46 return MEMCACHED_SUCCESS;
47 }
48 else
49 {
50 ptr->cached_errno= errno;
51
52 return MEMCACHED_ERRNO;
53 }
54 }
55 case 0:
56 return MEMCACHED_TIMEOUT;
57 default: // A real error occurred and we need to completely bail
58 WATCHPOINT_ERRNO(errno);
59 switch (errno)
60 {
61#ifdef TARGET_OS_LINUX
62 case ERESTART:
63#endif
64 case EINTR:
65 continue;
66 default:
67 if (fds[0].revents & POLLERR)
68 {
69 int err;
70 socklen_t len= sizeof (err);
71 (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len);
72 ptr->cached_errno= (err == 0) ? errno : err;
73 }
74 else
75 {
76 ptr->cached_errno= errno;
77 }
78
79 (void)close(ptr->fd);
80 ptr->fd= -1;
81
82 return MEMCACHED_ERRNO;
83 }
84 }
85 WATCHPOINT_ASSERT(0); // Programming error
86 }
87
88 // This should only be possible from ERESTART or EINTR;
89 ptr->cached_errno= errno;
90
91 return MEMCACHED_ERRNO;
92}
93
7static memcached_return_t set_hostinfo(memcached_server_st *server)94static memcached_return_t set_hostinfo(memcached_server_st *server)
8{95{
9 struct addrinfo *ai;96 struct addrinfo *ai;
@@ -225,36 +312,35 @@
225{312{
226 struct sockaddr_un servAddr;313 struct sockaddr_un servAddr;
227314
228 if (ptr->fd == -1)315 WATCHPOINT_ASSERT(ptr->fd == -1);
316
317 if ((ptr->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
229 {318 {
230 if ((ptr->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0)319 ptr->cached_errno= errno;
231 {320 return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE;
232 ptr->cached_errno= errno;321 }
233 return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE;
234 }
235322
236 memset(&servAddr, 0, sizeof (struct sockaddr_un));323 memset(&servAddr, 0, sizeof (struct sockaddr_un));
237 servAddr.sun_family= AF_UNIX;324 servAddr.sun_family= AF_UNIX;
238 strcpy(servAddr.sun_path, ptr->hostname); /* Copy filename */325 strcpy(servAddr.sun_path, ptr->hostname); /* Copy filename */
239326
240test_connect:327test_connect:
241 if (connect(ptr->fd,328 if (connect(ptr->fd,
242 (struct sockaddr *)&servAddr,329 (struct sockaddr *)&servAddr,
243 sizeof(servAddr)) < 0)330 sizeof(servAddr)) < 0)
331 {
332 switch (errno)
244 {333 {
245 switch (errno)334 case EINPROGRESS:
246 {335 case EALREADY:
247 case EINPROGRESS:336 case EINTR:
248 case EALREADY:337 goto test_connect;
249 case EINTR:338 case EISCONN: /* We were spinning waiting on connect */
250 goto test_connect;339 break;
251 case EISCONN: /* We were spinning waiting on connect */340 default:
252 break;341 WATCHPOINT_ERRNO(errno);
253 default:342 ptr->cached_errno= errno;
254 WATCHPOINT_ERRNO(errno);343 return MEMCACHED_ERRNO;
255 ptr->cached_errno= errno;
256 return MEMCACHED_ERRNO;
257 }
258 }344 }
259 }345 }
260346
@@ -265,134 +351,78 @@
265351
266static memcached_return_t network_connect(memcached_server_st *ptr)352static memcached_return_t network_connect(memcached_server_st *ptr)
267{353{
268 if (ptr->fd == -1)354 bool timeout_error_occured= false;
269 {355
270 struct addrinfo *use;356
271357 WATCHPOINT_ASSERT(ptr->fd == -1);
272 WATCHPOINT_ASSERT(ptr->cursor_active == 0);358 WATCHPOINT_ASSERT(ptr->cursor_active == 0);
273359
274 if (! ptr->options.sockaddr_inited ||360 if (! ptr->options.sockaddr_inited || (!(ptr->root->flags.use_cache_lookups)))
275 (!(ptr->root->flags.use_cache_lookups)))361 {
362 memcached_return_t rc;
363
364 rc= set_hostinfo(ptr);
365 if (rc != MEMCACHED_SUCCESS)
366 return rc;
367 ptr->options.sockaddr_inited= true;
368 }
369
370 struct addrinfo *use= ptr->address_info;
371 /* Create the socket */
372 while (use != NULL)
373 {
374 /* Memcache server does not support IPV6 in udp mode, so skip if not ipv4 */
375 if (ptr->type == MEMCACHED_CONNECTION_UDP && use->ai_family != AF_INET)
376 {
377 use= use->ai_next;
378 continue;
379 }
380
381 if ((ptr->fd= socket(use->ai_family,
382 use->ai_socktype,
383 use->ai_protocol)) < 0)
384 {
385 ptr->cached_errno= errno;
386 WATCHPOINT_ERRNO(errno);
387 return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE;
388 }
389
390 (void)set_socket_options(ptr);
391
392 /* connect to server */
393 if ((connect(ptr->fd, use->ai_addr, use->ai_addrlen) > -1))
394 {
395 break; // Success
396 }
397
398 /* An error occurred */
399 ptr->cached_errno= errno;
400 if (errno == EINPROGRESS || /* nonblocking mode - first return, */
401 errno == EALREADY) /* nonblocking mode - subsequent returns */
276 {402 {
277 memcached_return_t rc;403 memcached_return_t rc;
278404 rc= connect_poll(ptr);
279 rc= set_hostinfo(ptr);405
280 if (rc != MEMCACHED_SUCCESS)406 if (rc == MEMCACHED_TIMEOUT)
281 return rc;407 timeout_error_occured= true;
282 ptr->options.sockaddr_inited= true;408
283 }409 if (rc == MEMCACHED_SUCCESS)
284410 break;
285 use= ptr->address_info;411 }
286 /* Create the socket */412 else if (errno == EISCONN) /* we are connected :-) */
287 while (use != NULL)413 {
288 {414 break;
289 /* Memcache server does not support IPV6 in udp mode, so skip if not ipv4 */415 }
290 if (ptr->type == MEMCACHED_CONNECTION_UDP && use->ai_family != AF_INET)416 else if (errno == EINTR) // Special case, we retry ai_addr
291 {417 {
292 use= use->ai_next;418 (void)close(ptr->fd);
293 continue;419 ptr->fd= -1;
294 }420 continue;
295421 }
296 if ((ptr->fd= socket(use->ai_family,422
297 use->ai_socktype,423 (void)close(ptr->fd);
298 use->ai_protocol)) < 0)424 ptr->fd= -1;
299 {425 use= use->ai_next;
300 ptr->cached_errno= errno;
301 WATCHPOINT_ERRNO(errno);
302 return MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE;
303 }
304
305 (void)set_socket_options(ptr);
306
307 /* connect to server */
308 if ((connect(ptr->fd, use->ai_addr, use->ai_addrlen) == -1))
309 {
310 ptr->cached_errno= errno;
311 if (errno == EINPROGRESS || /* nonblocking mode - first return, */
312 errno == EALREADY) /* nonblocking mode - subsequent returns */
313 {
314 struct pollfd fds[1];
315 fds[0].fd = ptr->fd;
316 fds[0].events = POLLOUT;
317
318 int timeout= ptr->root->connect_timeout;
319 if (ptr->root->flags.no_block == true)
320 timeout= -1;
321
322 size_t loop_max= 5;
323 while (--loop_max)
324 {
325 int error= poll(fds, 1, timeout);
326
327 switch (error)
328 {
329 case 1:
330 loop_max= 1;
331 break;
332 case 0:
333 if (loop_max==1)
334 return MEMCACHED_TIMEOUT;
335 continue;
336 // A real error occurred and we need to completely bail
337 default:
338 WATCHPOINT_ERRNO(errno);
339 switch (errno)
340 {
341#ifdef TARGET_OS_LINUX
342 case ERESTART:
343#endif
344 case EINTR:
345 continue;
346 default:
347 if (fds[0].revents & POLLERR)
348 {
349 int err;
350 socklen_t len= sizeof (err);
351 (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len);
352 ptr->cached_errno= (err == 0) ? errno : err;
353 }
354
355 (void)close(ptr->fd);
356 ptr->fd= -1;
357
358 break;
359 }
360 }
361 }
362 }
363 else if (errno == EISCONN) /* we are connected :-) */
364 {
365 break;
366 }
367 else if (errno != EINTR)
368 {
369 (void)close(ptr->fd);
370 ptr->fd= -1;
371 break;
372 }
373 }
374
375#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
376 if (ptr->fd != -1 && ptr->root->sasl && ptr->root->sasl->callbacks)
377 {
378 memcached_return rc= memcached_sasl_authenticate_connection(ptr);
379 if (rc != MEMCACHED_SUCCESS)
380 {
381 (void)close(ptr->fd);
382 ptr->fd= -1;
383
384 return rc;
385 }
386 }
387#endif
388
389
390 if (ptr->fd != -1)
391 {
392 return MEMCACHED_SUCCESS;
393 }
394 use = use->ai_next;
395 }
396 }426 }
397427
398 if (ptr->fd == -1)428 if (ptr->fd == -1)
@@ -408,7 +438,7 @@
408 ptr->next_retry= next_time.tv_sec + ptr->root->retry_timeout;438 ptr->next_retry= next_time.tv_sec + ptr->root->retry_timeout;
409 }439 }
410440
411 if (ptr->cached_errno == 0)441 if (timeout_error_occured)
412 return MEMCACHED_TIMEOUT;442 return MEMCACHED_TIMEOUT;
413443
414 return MEMCACHED_ERRNO; /* The last error should be from connect() */444 return MEMCACHED_ERRNO; /* The last error should be from connect() */
@@ -435,6 +465,10 @@
435memcached_return_t memcached_connect(memcached_server_write_instance_st ptr)465memcached_return_t memcached_connect(memcached_server_write_instance_st ptr)
436{466{
437 memcached_return_t rc= MEMCACHED_NO_SERVERS;467 memcached_return_t rc= MEMCACHED_NO_SERVERS;
468
469 if (ptr->fd > -1)
470 return MEMCACHED_SUCCESS;
471
438 LIBMEMCACHED_MEMCACHED_CONNECT_START();472 LIBMEMCACHED_MEMCACHED_CONNECT_START();
439473
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. */
@@ -481,6 +515,17 @@
481 case MEMCACHED_CONNECTION_UDP:515 case MEMCACHED_CONNECTION_UDP:
482 case MEMCACHED_CONNECTION_TCP:516 case MEMCACHED_CONNECTION_TCP:
483 rc= network_connect(ptr);517 rc= network_connect(ptr);
518#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
519 if (ptr->fd != -1 && ptr->root->sasl && ptr->root->sasl->callbacks)
520 {
521 rc= memcached_sasl_authenticate_connection(ptr);
522 if (rc != MEMCACHED_SUCCESS)
523 {
524 (void)close(ptr->fd);
525 ptr->fd= -1;
526 }
527 }
528#endif
484 break;529 break;
485 case MEMCACHED_CONNECTION_UNIX_SOCKET:530 case MEMCACHED_CONNECTION_UNIX_SOCKET:
486 rc= unix_socket_connect(ptr);531 rc= unix_socket_connect(ptr);
487532
=== modified file 'libmemcached/delete.c'
--- libmemcached/delete.c 2010-04-02 19:55:21 +0000
+++ libmemcached/delete.c 2010-07-21 16:27:47 +0000
@@ -45,7 +45,7 @@
4545
46 if (ptr->flags.binary_protocol)46 if (ptr->flags.binary_protocol)
47 {47 {
48 likely (!expiration)48 likely (! expiration)
49 {49 {
50 rc= binary_delete(ptr, server_key, key, key_length, to_write);50 rc= binary_delete(ptr, server_key, key, key_length, to_write);
51 }51 }
5252
=== modified file 'libmemcached/include.am'
--- libmemcached/include.am 2010-06-15 06:31:25 +0000
+++ libmemcached/include.am 2010-07-21 16:27:47 +0000
@@ -65,7 +65,7 @@
65 libmemcached/protocol/pedantic.c \65 libmemcached/protocol/pedantic.c \
66 libmemcached/protocol/protocol_handler.c66 libmemcached/protocol/protocol_handler.c
6767
68libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS} -version-info 0:0:068libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_PROTOCAL_LIBRARY_VERSION}
6969
70noinst_LTLIBRARIES+= \70noinst_LTLIBRARIES+= \
71 libmemcached/libmemcachedcallbacks.la71 libmemcached/libmemcachedcallbacks.la
@@ -133,7 +133,7 @@
133 libmemcached/util/pool.c \133 libmemcached/util/pool.c \
134 libmemcached/util/version.c134 libmemcached/util/version.c
135libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la135libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la
136libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info 0:0:0136libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION}
137libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la137libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la
138138
139if BUILD_BYTEORDER139if BUILD_BYTEORDER
@@ -158,6 +158,7 @@
158if DTRACE_NEEDS_OBJECTS158if DTRACE_NEEDS_OBJECTS
159libmemcached_libmemcached_la_SOURCES += libmemcached/libmemcached_probes.d159libmemcached_libmemcached_la_SOURCES += libmemcached/libmemcached_probes.d
160libmemcached_libmemcached_la_DEPENDENCIES += libmemcached/libmemcached_probes.o160libmemcached_libmemcached_la_DEPENDENCIES += libmemcached/libmemcached_probes.o
161CLEANFILES+= libmemcached/libmemcached_probes.o
161endif162endif
162163
163SUFFIXES+= .d164SUFFIXES+= .d
@@ -165,7 +166,7 @@
165libmemcached/dtrace_probes.h: libmemcached/libmemcached_probes.d166libmemcached/dtrace_probes.h: libmemcached/libmemcached_probes.d
166 $(DTRACE) $(DTRACEFLAGS) -h -o libmemcached/dtrace_probes.h -s ${top_srcdir}/libmemcached/libmemcached_probes.d167 $(DTRACE) $(DTRACEFLAGS) -h -o libmemcached/dtrace_probes.h -s ${top_srcdir}/libmemcached/libmemcached_probes.d
167168
168libmemcached/libmemcached_probes.o: libmemcached/libmemcached_probes.d ${libmemcached_libmemcached_OBJECTS} config.h169libmemcached/libmemcached_probes.o: libmemcached/libmemcached_probes.d ${libmemcached_libmemcached_la_OBJECTS} config.h
169170
170.d.o:171.d.o:
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}\//"`
172173
=== modified file 'libmemcached/io.c'
--- libmemcached/io.c 2010-04-22 22:51:37 +0000
+++ libmemcached/io.c 2010-07-21 16:27:47 +0000
@@ -62,45 +62,50 @@
62 timeout= -1;62 timeout= -1;
6363
64 size_t loop_max= 5;64 size_t loop_max= 5;
65 while (--loop_max)65 while (--loop_max) // While loop is for ERESTART or EINTR
66 {66 {
67 error= poll(&fds, 1, timeout);67 error= poll(&fds, 1, timeout);
6868
69 switch (error)69 switch (error)
70 {70 {
71 case 1:71 case 1: // Success!
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);
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);
7474
75 return MEMCACHED_SUCCESS;75 return MEMCACHED_SUCCESS;
76 case 0:76 case 0: // Timeout occured, we let the while() loop do its thing.
77 return MEMCACHED_TIMEOUT;77 return MEMCACHED_TIMEOUT;
78 default:78 default:
79 WATCHPOINT_ERRNO(errno);79 WATCHPOINT_ERRNO(errno);
80 switch (errno)
80 {81 {
81 switch (errno)
82 {
83#ifdef TARGET_OS_LINUX82#ifdef TARGET_OS_LINUX
84 case ERESTART:83 case ERESTART:
85#endif84#endif
86 case EINTR:85 case EINTR:
87 continue;86 break;
88 default:87 default:
89 ptr->cached_errno= error;88 if (fds.revents & POLLERR)
90 memcached_quit_server(ptr, true);89 {
90 int err;
91 socklen_t len= sizeof (err);
92 (void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len);
93 ptr->cached_errno= (err == 0) ? errno : err;
94 }
95 else
96 {
97 ptr->cached_errno= errno;
98 }
99 memcached_quit_server(ptr, true);
91100
92 return MEMCACHED_FAILURE;101 return MEMCACHED_FAILURE;
93 }
94 }102 }
95 }103 }
96 }104 }
97105
98 if (loop_max == 0 && error == 0)
99 return MEMCACHED_TIMEOUT;
100
101 /* Imposssible for anything other then -1 */106 /* Imposssible for anything other then -1 */
102 WATCHPOINT_ASSERT(error == -1);107 WATCHPOINT_ASSERT(error == -1);
103 ptr->cached_errno= error;108 ptr->cached_errno= errno;
104 memcached_quit_server(ptr, true);109 memcached_quit_server(ptr, true);
105110
106 return MEMCACHED_FAILURE;111 return MEMCACHED_FAILURE;
107112
=== modified file 'libmemcached/response.c'
--- libmemcached/response.c 2010-04-22 22:51:37 +0000
+++ libmemcached/response.c 2010-07-21 16:27:47 +0000
@@ -61,6 +61,7 @@
61 * compatibility.61 * compatibility.
62 */62 */
63 if (ptr->root->flags.binary_protocol == false)63 if (ptr->root->flags.binary_protocol == false)
64 {
64 while (memcached_server_response_count(ptr) > 1)65 while (memcached_server_response_count(ptr) > 1)
65 {66 {
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);
@@ -75,6 +76,7 @@
75 rc != MEMCACHED_DATA_EXISTS)76 rc != MEMCACHED_DATA_EXISTS)
76 return rc;77 return rc;
77 }78 }
79 }
7880
79 return memcached_read_one_response(ptr, buffer, buffer_length, result);81 return memcached_read_one_response(ptr, buffer, buffer_length, result);
80}82}
8183
=== modified file 'libmemcached/server.c'
--- libmemcached/server.c 2010-04-22 00:49:09 +0000
+++ libmemcached/server.c 2010-07-21 16:27:47 +0000
@@ -172,6 +172,26 @@
172 return MEMCACHED_SUCCESS;172 return MEMCACHED_SUCCESS;
173}173}
174174
175memcached_return_t memcached_server_execute(memcached_st *ptr,
176 memcached_server_execute_fn callback,
177 void *context)
178{
179 for (uint32_t x= 0; x < memcached_server_count(ptr); x++)
180 {
181 memcached_server_write_instance_st instance=
182 memcached_server_instance_fetch(ptr, x);
183
184 unsigned int iferror;
185
186 iferror= (*callback)(ptr, instance, context);
187
188 if (iferror)
189 continue;
190 }
191
192 return MEMCACHED_SUCCESS;
193}
194
175memcached_server_instance_st memcached_server_by_key(const memcached_st *ptr,195memcached_server_instance_st memcached_server_by_key(const memcached_st *ptr,
176 const char *key,196 const char *key,
177 size_t key_length,197 size_t key_length,
178198
=== modified file 'libmemcached/stats.c'
--- libmemcached/stats.c 2010-04-02 19:55:21 +0000
+++ libmemcached/stats.c 2010-07-21 16:27:47 +0000
@@ -29,6 +29,13 @@
29 NULL29 NULL
30};30};
3131
32struct local_context
33{
34 memcached_stat_fn func;
35 void *context;
36 const char *args;
37};
38
3239
33static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char *value)40static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char *value)
34{41{
@@ -228,8 +235,9 @@
228}235}
229236
230static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat,237static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat,
231 char *args,238 const char *args,
232 memcached_server_write_instance_st instance)239 memcached_server_write_instance_st instance,
240 struct local_context *check)
233{241{
234 memcached_return_t rc;242 memcached_return_t rc;
235243
@@ -286,10 +294,23 @@
286 return rc;294 return rc;
287 }295 }
288296
289 unlikely((set_data(memc_stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY)297 if (memc_stat)
290 {298 {
291 WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY);299 unlikely((set_data(memc_stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY)
292 WATCHPOINT_ASSERT(0);300 {
301 WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY);
302 WATCHPOINT_ASSERT(0);
303 }
304 }
305
306 if (check && check->func)
307 {
308 size_t key_length= strlen(buffer);
309
310 check->func(instance,
311 buffer, key_length,
312 buffer+key_length+1, strlen(buffer+key_length+1),
313 check->context);
293 }314 }
294 } while (1);315 } while (1);
295316
@@ -302,8 +323,9 @@
302}323}
303324
304static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat,325static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat,
305 char *args,326 const char *args,
306 memcached_server_write_instance_st instance)327 memcached_server_write_instance_st instance,
328 struct local_context *check)
307{329{
308 memcached_return_t rc;330 memcached_return_t rc;
309 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];331 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
@@ -343,10 +365,21 @@
343 value= string_ptr;365 value= string_ptr;
344 value[(size_t)(end_ptr-string_ptr)]= 0;366 value[(size_t)(end_ptr-string_ptr)]= 0;
345 string_ptr= end_ptr + 2;367 string_ptr= end_ptr + 2;
346 unlikely((set_data(memc_stat, key, value)) == MEMCACHED_UNKNOWN_STAT_KEY)368 if (memc_stat)
347 {369 {
348 WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY);370 unlikely((set_data(memc_stat, key, value)) == MEMCACHED_UNKNOWN_STAT_KEY)
349 WATCHPOINT_ASSERT(0);371 {
372 WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY);
373 WATCHPOINT_ASSERT(0);
374 }
375 }
376
377 if (check && check->func)
378 {
379 check->func(instance,
380 key, strlen(key),
381 value, strlen(value),
382 check->context);
350 }383 }
351 }384 }
352 else385 else
@@ -394,11 +427,11 @@
394427
395 if (ptr->flags.binary_protocol)428 if (ptr->flags.binary_protocol)
396 {429 {
397 temp_return= binary_stats_fetch(stat_instance, args, instance);430 temp_return= binary_stats_fetch(stat_instance, args, instance, NULL);
398 }431 }
399 else432 else
400 {433 {
401 temp_return= ascii_stats_fetch(stat_instance, args, instance);434 temp_return= ascii_stats_fetch(stat_instance, args, instance, NULL);
402 }435 }
403436
404 if (temp_return != MEMCACHED_SUCCESS)437 if (temp_return != MEMCACHED_SUCCESS)
@@ -428,11 +461,11 @@
428461
429 if (memc.flags.binary_protocol)462 if (memc.flags.binary_protocol)
430 {463 {
431 rc= binary_stats_fetch(memc_stat, args, instance);464 rc= binary_stats_fetch(memc_stat, args, instance, NULL);
432 }465 }
433 else466 else
434 {467 {
435 rc= ascii_stats_fetch(memc_stat, args, instance);468 rc= ascii_stats_fetch(memc_stat, args, instance, NULL);
436 }469 }
437470
438 memcached_free(&memc);471 memcached_free(&memc);
@@ -489,3 +522,31 @@
489 free(memc_stat);522 free(memc_stat);
490 }523 }
491}524}
525
526static memcached_return_t call_stat_fn(memcached_st *ptr,
527 memcached_server_write_instance_st instance,
528 void *context)
529{
530 memcached_return_t rc;
531 struct local_context *check= (struct local_context *)context;
532
533 if (ptr->flags.binary_protocol)
534 {
535 rc= binary_stats_fetch(NULL, check->args, instance, check);
536 }
537 else
538 {
539 rc= ascii_stats_fetch(NULL, check->args, instance, check);
540 }
541
542 return rc;
543}
544
545memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context)
546{
547 memcached_version(memc);
548
549 struct local_context check= { .func= func, .context= context, .args= args };
550
551 return memcached_server_execute(memc, call_stat_fn, (void *)&check);
552}
492553
=== modified file 'libmemcached/stats.h'
--- libmemcached/stats.h 2010-02-17 01:58:35 +0000
+++ libmemcached/stats.h 2010-07-21 16:27:47 +0000
@@ -62,6 +62,9 @@
62char ** memcached_stat_get_keys(const memcached_st *ptr, memcached_stat_st *memc_stat,62char ** memcached_stat_get_keys(const memcached_st *ptr, memcached_stat_st *memc_stat,
63 memcached_return_t *error);63 memcached_return_t *error);
6464
65LIBMEMCACHED_API
66memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context);
67
65#ifdef __cplusplus68#ifdef __cplusplus
66} // extern "C"69} // extern "C"
67#endif70#endif
6871
=== modified file 'libmemcached/types.h'
--- libmemcached/types.h 2010-02-17 01:58:35 +0000
+++ libmemcached/types.h 2010-07-21 16:27:47 +0000
@@ -47,6 +47,10 @@
4747
48typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context);48typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context);
49typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context);49typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context);
50typedef memcached_return_t (*memcached_stat_fn)(memcached_server_instance_st server,
51 const char *key, size_t key_length,
52 const char *value, size_t value_length,
53 void *context);
5054
51/**55/**
52 Trigger functions.56 Trigger functions.
5357
=== modified file 'libmemcached/util/version.c'
--- libmemcached/util/version.c 2010-06-15 06:31:25 +0000
+++ libmemcached/util/version.c 2010-07-21 16:27:47 +0000
@@ -16,8 +16,8 @@
16struct local_context16struct local_context
17{17{
18 uint8_t major_version;18 uint8_t major_version;
19 uint8_t minor_version;
19 uint8_t micro_version;20 uint8_t micro_version;
20 uint8_t minor_version;
2121
22 bool truth;22 bool truth;
23};23};
@@ -30,8 +30,8 @@
30 struct local_context *check= (struct local_context *)context;30 struct local_context *check= (struct local_context *)context;
3131
32 if (instance->major_version >= check->major_version &&32 if (instance->major_version >= check->major_version &&
33 instance->micro_version >= check->micro_version &&33 instance->minor_version >= check->minor_version &&
34 instance->minor_version >= check->minor_version)34 instance->micro_version >= check->micro_version )
35 {35 {
36 return MEMCACHED_SUCCESS;36 return MEMCACHED_SUCCESS;
37 }37 }
@@ -43,13 +43,14 @@
4343
44bool libmemcached_util_version_check(memcached_st *memc, 44bool libmemcached_util_version_check(memcached_st *memc,
45 uint8_t major_version,45 uint8_t major_version,
46 uint8_t micro_version,46 uint8_t minor_version,
47 uint8_t minor_version)47 uint8_t micro_version)
48{48{
49 memcached_server_fn callbacks[1];49 memcached_server_fn callbacks[1];
50 memcached_version(memc);50 memcached_version(memc);
5151
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 };
53 memcached_version(memc);
5354
54 callbacks[0]= check_server_version;55 callbacks[0]= check_server_version;
55 memcached_server_cursor(memc, callbacks, (void *)&check, 1);56 memcached_server_cursor(memc, callbacks, (void *)&check, 1);
5657
=== modified file 'libmemcached/util/version.h'
--- libmemcached/util/version.h 2010-06-15 06:31:25 +0000
+++ libmemcached/util/version.h 2010-07-21 16:27:47 +0000
@@ -19,8 +19,8 @@
19LIBMEMCACHED_API19LIBMEMCACHED_API
20 bool libmemcached_util_version_check(memcached_st *memc, 20 bool libmemcached_util_version_check(memcached_st *memc,
21 uint8_t major_version,21 uint8_t major_version,
22 uint8_t micro_version,22 uint8_t minor_version,
23 uint8_t minor_version);23 uint8_t micro_version);
2424
25#ifdef __cplusplus25#ifdef __cplusplus
26}26}
2727
=== modified file 'libmemcached/version.c'
--- libmemcached/version.c 2010-04-02 19:55:21 +0000
+++ libmemcached/version.c 2010-07-21 16:27:47 +0000
@@ -13,10 +13,19 @@
13 if (ptr->flags.use_udp)13 if (ptr->flags.use_udp)
14 return MEMCACHED_NOT_SUPPORTED;14 return MEMCACHED_NOT_SUPPORTED;
1515
16 bool was_blocking= ptr->flags.no_block;
17 memcached_return_t rc;
18
19 ptr->flags.no_block= false;
20
16 if (ptr->flags.binary_protocol)21 if (ptr->flags.binary_protocol)
17 return memcached_version_binary(ptr);22 rc= memcached_version_binary(ptr);
18 else23 else
19 return memcached_version_textual(ptr); 24 rc= memcached_version_textual(ptr);
25
26 ptr->flags.no_block= was_blocking;
27
28 return rc;
20}29}
2130
22static inline memcached_return_t memcached_version_textual(memcached_st *ptr)31static inline memcached_return_t memcached_version_textual(memcached_st *ptr)
2332
=== modified file 'm4/pandora_warnings.m4'
--- m4/pandora_warnings.m4 2010-06-13 16:24:20 +0000
+++ m4/pandora_warnings.m4 2010-07-21 16:27:47 +0000
@@ -145,7 +145,7 @@
145 m4_if(PW_LESS_WARNINGS,[no],[145 m4_if(PW_LESS_WARNINGS,[no],[
146 BASE_WARNINGS_FULL="-Wformat=2 ${W_CONVERSION} -Wstrict-aliasing"146 BASE_WARNINGS_FULL="-Wformat=2 ${W_CONVERSION} -Wstrict-aliasing"
147 CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings"147 CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings"
148 CXX_WARNINGS_FULL="-Weffc++ -Wold-style-cast"148 CXX_WARNINGS_FULL="-Wold-style-cast"
149 NO_OLD_STYLE_CAST="-Wno-old-style-cast"149 NO_OLD_STYLE_CAST="-Wno-old-style-cast"
150 NO_EFF_CXX="-Wno-effc++"150 NO_EFF_CXX="-Wno-effc++"
151 ],[151 ],[
152152
=== modified file 'support/libmemcached.spec.in'
--- support/libmemcached.spec.in 2010-04-05 16:41:24 +0000
+++ support/libmemcached.spec.in 2010-07-21 16:27:47 +0000
@@ -82,10 +82,14 @@
82%exclude %{_libdir}/libhashkit.la82%exclude %{_libdir}/libhashkit.la
83%exclude %{_libdir}/libmemcachedutil.la83%exclude %{_libdir}/libmemcachedutil.la
84%exclude %{_libdir}/libmemcachedprotocol.la84%exclude %{_libdir}/libmemcachedprotocol.la
85%{_libdir}/libhashkit.so.*85%{_libdir}/libhashkit.so.0.0.0
86%{_libdir}/libmemcached.so.*86%{_libdir}/libmemcached.so.5.0.1
87%{_libdir}/libmemcachedutil.so.*87%{_libdir}/libmemcachedutil.so.1.0.0
88%{_libdir}/libmemcachedprotocol.so.*88%{_libdir}/libmemcachedprotocol.so.0.0.0
89%{_libdir}/libhashkit.so.0
90%{_libdir}/libmemcached.so.5
91%{_libdir}/libmemcachedprotocol.so.0
92%{_libdir}/libmemcachedutil.so.1
89%{_mandir}/man1/memcapable.1.gz93%{_mandir}/man1/memcapable.1.gz
90%{_mandir}/man1/memcat.1.gz94%{_mandir}/man1/memcat.1.gz
91%{_mandir}/man1/memcp.1.gz95%{_mandir}/man1/memcp.1.gz
@@ -104,14 +108,6 @@
104%{_includedir}/libmemcached/delete.h108%{_includedir}/libmemcached/delete.h
105%{_includedir}/libmemcached/fetch.h109%{_includedir}/libmemcached/fetch.h
106%{_includedir}/libmemcached/flush.h110%{_includedir}/libmemcached/flush.h
107%{_includedir}/libmemcached/flush_buffers.h
108%{_includedir}/libmemcached/hash.h
109%{_includedir}/libmemcached/parse.h
110%{_includedir}/libmemcached/quit.h
111%{_includedir}/libmemcached/sasl.h
112%{_includedir}/libmemcached/strerror.h
113%{_includedir}/libmemcached/verbosity.h
114%{_includedir}/libmemcached/version.h
115%{_includedir}/libhashkit/algorithm.h111%{_includedir}/libhashkit/algorithm.h
116%{_includedir}/libhashkit/behavior.h112%{_includedir}/libhashkit/behavior.h
117%{_includedir}/libhashkit/configure.h113%{_includedir}/libhashkit/configure.h
@@ -129,21 +125,32 @@
129%{_includedir}/libmemcached/constants.h125%{_includedir}/libmemcached/constants.h
130%{_includedir}/libmemcached/dump.h126%{_includedir}/libmemcached/dump.h
131%{_includedir}/libmemcached/exception.hpp127%{_includedir}/libmemcached/exception.hpp
128%{_includedir}/libmemcached/flush_buffers.h
132%{_includedir}/libmemcached/get.h129%{_includedir}/libmemcached/get.h
130%{_includedir}/libmemcached/hash.h
133%{_includedir}/libmemcached/memcached.h131%{_includedir}/libmemcached/memcached.h
134%{_includedir}/libmemcached/memcached.hpp132%{_includedir}/libmemcached/memcached.hpp
135%{_includedir}/libmemcached/memcached_util.h133%{_includedir}/libmemcached/memcached_util.h
134%{_includedir}/libmemcached/parse.h
136%{_includedir}/libmemcached/protocol/cache.h135%{_includedir}/libmemcached/protocol/cache.h
137%{_includedir}/libmemcached/protocol/callback.h136%{_includedir}/libmemcached/protocol/callback.h
138%{_includedir}/libmemcached/protocol_handler.h137%{_includedir}/libmemcached/protocol_handler.h
138%{_includedir}/libmemcached/quit.h
139%{_includedir}/libmemcached/result.h139%{_includedir}/libmemcached/result.h
140%{_includedir}/libmemcached/sasl.h
140%{_includedir}/libmemcached/server.h141%{_includedir}/libmemcached/server.h
141%{_includedir}/libmemcached/server_list.h142%{_includedir}/libmemcached/server_list.h
142%{_includedir}/libmemcached/stats.h143%{_includedir}/libmemcached/stats.h
143%{_includedir}/libmemcached/storage.h144%{_includedir}/libmemcached/storage.h
145%{_includedir}/libmemcached/strerror.h
144%{_includedir}/libmemcached/string.h146%{_includedir}/libmemcached/string.h
145%{_includedir}/libmemcached/types.h147%{_includedir}/libmemcached/types.h
148%{_includedir}/libmemcached/util.h
149%{_includedir}/libmemcached/util/ping.h
146%{_includedir}/libmemcached/util/pool.h150%{_includedir}/libmemcached/util/pool.h
151%{_includedir}/libmemcached/util/version.h
152%{_includedir}/libmemcached/verbosity.h
153%{_includedir}/libmemcached/version.h
147%{_includedir}/libmemcached/visibility.h154%{_includedir}/libmemcached/visibility.h
148%{_includedir}/libmemcached/watchpoint.h155%{_includedir}/libmemcached/watchpoint.h
149%{_includedir}/libmemcached/memcached/protocol_binary.h156%{_includedir}/libmemcached/memcached/protocol_binary.h
@@ -187,6 +194,7 @@
187%{_mandir}/man3/memcached_decrement_with_initial.3.gz194%{_mandir}/man3/memcached_decrement_with_initial.3.gz
188%{_mandir}/man3/memcached_delete.3.gz195%{_mandir}/man3/memcached_delete.3.gz
189%{_mandir}/man3/memcached_delete_by_key.3.gz196%{_mandir}/man3/memcached_delete_by_key.3.gz
197%{_mandir}/man3/memcached_destroy_sasl_auth_data.3.gz
190%{_mandir}/man3/memcached_dump.3.gz198%{_mandir}/man3/memcached_dump.3.gz
191%{_mandir}/man3/memcached_fetch.3.gz199%{_mandir}/man3/memcached_fetch.3.gz
192%{_mandir}/man3/memcached_fetch_execute.3.gz200%{_mandir}/man3/memcached_fetch_execute.3.gz
@@ -197,6 +205,7 @@
197%{_mandir}/man3/memcached_get.3.gz205%{_mandir}/man3/memcached_get.3.gz
198%{_mandir}/man3/memcached_get_by_key.3.gz206%{_mandir}/man3/memcached_get_by_key.3.gz
199%{_mandir}/man3/memcached_get_memory_allocators.3.gz207%{_mandir}/man3/memcached_get_memory_allocators.3.gz
208%{_mandir}/man3/memcached_get_sasl_callbacks.3.gz
200%{_mandir}/man3/memcached_get_user_data.3.gz209%{_mandir}/man3/memcached_get_user_data.3.gz
201%{_mandir}/man3/memcached_increment.3.gz210%{_mandir}/man3/memcached_increment.3.gz
202%{_mandir}/man3/memcached_increment_with_initial.3.gz211%{_mandir}/man3/memcached_increment_with_initial.3.gz
@@ -216,6 +225,7 @@
216%{_mandir}/man3/memcached_quit.3.gz225%{_mandir}/man3/memcached_quit.3.gz
217%{_mandir}/man3/memcached_replace.3.gz226%{_mandir}/man3/memcached_replace.3.gz
218%{_mandir}/man3/memcached_replace_by_key.3.gz227%{_mandir}/man3/memcached_replace_by_key.3.gz
228%{_mandir}/man3/memcached_sasl_set_auth_data.3.gz
219%{_mandir}/man3/memcached_server_add.3.gz229%{_mandir}/man3/memcached_server_add.3.gz
220%{_mandir}/man3/memcached_server_count.3.gz230%{_mandir}/man3/memcached_server_count.3.gz
221%{_mandir}/man3/memcached_server_cursor.3.gz231%{_mandir}/man3/memcached_server_cursor.3.gz
@@ -228,6 +238,7 @@
228%{_mandir}/man3/memcached_set.3.gz238%{_mandir}/man3/memcached_set.3.gz
229%{_mandir}/man3/memcached_set_by_key.3.gz239%{_mandir}/man3/memcached_set_by_key.3.gz
230%{_mandir}/man3/memcached_set_memory_allocators.3.gz240%{_mandir}/man3/memcached_set_memory_allocators.3.gz
241%{_mandir}/man3/memcached_set_sasl_callbacks.3.gz
231%{_mandir}/man3/memcached_set_user_data.3.gz242%{_mandir}/man3/memcached_set_user_data.3.gz
232%{_mandir}/man3/memcached_stat.3.gz243%{_mandir}/man3/memcached_stat.3.gz
233%{_mandir}/man3/memcached_stat_get_keys.3.gz244%{_mandir}/man3/memcached_stat_get_keys.3.gz
234245
=== modified file 'tests/atomsmasher.c'
--- tests/atomsmasher.c 2010-01-15 21:49:15 +0000
+++ tests/atomsmasher.c 2010-07-21 16:27:47 +0000
@@ -12,10 +12,14 @@
12/*12/*
13 Sample test application.13 Sample test application.
14*/14*/
15#include "libmemcached/common.h"15#include "config.h"
16
17#include "libmemcached/memcached.h"
18#include "libmemcached/watchpoint.h"
1619
17#include <stdio.h>20#include <stdio.h>
18#include <stdlib.h>21#include <stdlib.h>
22#include <stdint.h>
19#include <string.h>23#include <string.h>
20#include <sys/time.h>24#include <sys/time.h>
21#include <sys/types.h>25#include <sys/types.h>
@@ -26,14 +30,6 @@
26#include "../clients/generator.h"30#include "../clients/generator.h"
27#include "../clients/execute.h"31#include "../clients/execute.h"
2832
29#ifndef INT64_MAX
30#define INT64_MAX LONG_MAX
31#endif
32#ifndef INT32_MAX
33#define INT32_MAX INT_MAX
34#endif
35
36
37#include "test.h"33#include "test.h"
3834
39/* Number of items generated for tests */35/* Number of items generated for tests */
4036
=== modified file 'tests/hashkit_functions.c'
--- tests/hashkit_functions.c 2010-04-11 17:56:46 +0000
+++ tests/hashkit_functions.c 2010-07-21 16:27:47 +0000
@@ -6,6 +6,8 @@
6 * the COPYING file in the parent directory for full text.6 * the COPYING file in the parent directory for full text.
7 */7 */
88
9#include "config.h"
10
9#include <assert.h>11#include <assert.h>
10#include <stdio.h>12#include <stdio.h>
11#include <stdlib.h>13#include <stdlib.h>
1214
=== modified file 'tests/include.am'
--- tests/include.am 2010-06-13 16:43:30 +0000
+++ tests/include.am 2010-07-21 16:27:47 +0000
@@ -4,7 +4,7 @@
44
5TESTS_LDADDS = libmemcached/libmemcached.la5TESTS_LDADDS = libmemcached/libmemcached.la
66
7VALGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --leak-check=yes --show-reachable=yes7VALGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --leak-check=yes --show-reachable=yes --track-fds=yes
88
9DEBUG_COMMAND= $(LIBTOOL) --mode=execute gdb9DEBUG_COMMAND= $(LIBTOOL) --mode=execute gdb
1010
@@ -41,6 +41,7 @@
41tests_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)41tests_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)
42tests_testapp_SOURCES= tests/mem_functions.c42tests_testapp_SOURCES= tests/mem_functions.c
43tests_testapp_DEPENDENCIES= \43tests_testapp_DEPENDENCIES= \
44 $(BUILT_SOURCES) \
44 clients/libgenexec.la \45 clients/libgenexec.la \
45 tests/libserver.la \46 tests/libserver.la \
46 tests/libtest.la \47 tests/libtest.la \
@@ -86,12 +87,14 @@
86tests_memplus_SOURCES = tests/mem_plus.cc87tests_memplus_SOURCES = tests/mem_plus.cc
87tests_memplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX)88tests_memplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX)
88tests_memplus_DEPENDENCIES = tests/libtest.la tests/libserver.la libmemcached/libmemcached.la89tests_memplus_DEPENDENCIES = tests/libtest.la tests/libserver.la libmemcached/libmemcached.la
89tests_memplus_LDADD = $(tests_memplus_DEPENDENCIES)90tests_memplus_LDADD = $(tests_memplus_DEPENDENCIES) $(LIBSASL)
9091
91test: test-docs test-mem test-hash memcapable92test: check
93
94check-local: $(TEST_DOCS) test-mem test-hash memcapable
92 echo "Tests completed"95 echo "Tests completed"
9396
94test-x: test-docs test-plus test-mem test-hash memcapable test-memcat test-memcp test-memrm test-memerror test-memdump test-memflush test-memstat97test-x: check-local test-plus test-memcat test-memcp test-memrm test-memerror test-memdump test-memflush test-memstat
95 echo "Tests completed"98 echo "Tests completed"
9699
97memcapable: clients/memcapable100memcapable: clients/memcapable
98101
=== modified file 'tests/mem_functions.c'
--- tests/mem_functions.c 2010-06-15 06:31:25 +0000
+++ tests/mem_functions.c 2010-07-21 16:27:47 +0000
@@ -10,10 +10,11 @@
10 Sample test application.10 Sample test application.
11*/11*/
1212
13#include "libmemcached/common.h"13#include "config.h"
1414
15#include <assert.h>15#include <assert.h>
16#include <stdio.h>16#include <stdio.h>
17#include <stdint.h>
17#include <stdlib.h>18#include <stdlib.h>
18#include <string.h>19#include <string.h>
19#include <sys/time.h>20#include <sys/time.h>
@@ -22,20 +23,18 @@
22#include <signal.h>23#include <signal.h>
23#include <unistd.h>24#include <unistd.h>
24#include <time.h>25#include <time.h>
26
27#include "libmemcached/common.h"
28
25#include "server.h"29#include "server.h"
26#include "clients/generator.h"30#include "clients/generator.h"
27#include "clients/execute.h"31#include "clients/execute.h"
2832
29#ifndef INT64_MAX33#define SMALL_STRING_LEN 1024
30#define INT64_MAX LONG_MAX
31#endif
32#ifndef INT32_MAX
33#define INT32_MAX INT_MAX
34#endif
35
3634
37#include "test.h"35#include "test.h"
3836
37
39#ifdef HAVE_LIBMEMCACHEDUTIL38#ifdef HAVE_LIBMEMCACHEDUTIL
40#include <pthread.h>39#include <pthread.h>
41#include "libmemcached/memcached_util.h"40#include "libmemcached/memcached_util.h"
@@ -682,7 +681,6 @@
682*/681*/
683static test_return_t add_wrapper(memcached_st *memc)682static test_return_t add_wrapper(memcached_st *memc)
684{683{
685 unsigned int x;
686 unsigned int max= 10000;684 unsigned int max= 10000;
687#ifdef __sun685#ifdef __sun
688 max= 10;686 max= 10;
@@ -691,7 +689,7 @@
691 max= 10;689 max= 10;
692#endif690#endif
693691
694 for (x= 0; x < max; x++)692 for (uint32_t x= 0; x < max; x++)
695 add_test(memc);693 add_test(memc);
696694
697 return TEST_SUCCESS;695 return TEST_SUCCESS;
@@ -3599,7 +3597,7 @@
3599 // will not toggle protocol on an connection.3597 // will not toggle protocol on an connection.
3600 memcached_version(memc_clone);3598 memcached_version(memc_clone);
36013599
3602 if (libmemcached_util_version_check(memc_clone, 1, 2, 0))3600 if (libmemcached_util_version_check(memc_clone, 1, 3, 0))
3603 {3601 {
3604 memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);3602 memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
3605 rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);3603 rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
@@ -3724,23 +3722,14 @@
3724static test_return_t pre_binary(memcached_st *memc)3722static test_return_t pre_binary(memcached_st *memc)
3725{3723{
3726 memcached_return_t rc= MEMCACHED_FAILURE;3724 memcached_return_t rc= MEMCACHED_FAILURE;
3727 memcached_st *memc_clone;3725
37283726 if (libmemcached_util_version_check(memc, 1, 3, 0))
3729 memc_clone= memcached_clone(NULL, memc);
3730 test_true(memc_clone);
3731 // The memcached_version needs to be done on a clone, because the server
3732 // will not toggle protocol on an connection.
3733 memcached_version(memc_clone);
3734
3735 if (libmemcached_util_version_check(memc_clone, 1, 2, 0))
3736 {3727 {
3737 rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);3728 rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
3738 test_true(rc == MEMCACHED_SUCCESS);3729 test_true(rc == MEMCACHED_SUCCESS);
3739 test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1);3730 test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1);
3740 }3731 }
37413732
3742 memcached_free(memc_clone);
3743
3744 return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED;3733 return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED;
3745}3734}
37463735
@@ -4432,24 +4421,24 @@
4432 memcached_version(memc);4421 memcached_version(memc);
44334422
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.
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);
4436 test_true(if_successful == true);4425 test_true(if_successful == true);
44374426
4438 if (instance->minor_version > 0)4427 if (instance->micro_version > 0)
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));
4440 else if (instance->micro_version > 0)4429 else if (instance->minor_version > 0)
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);
4442 else if (instance->major_version > 0)4431 else if (instance->major_version > 0)
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);
44444433
4445 test_true(if_successful == true);4434 test_true(if_successful == true);
44464435
4447 if (instance->minor_version > 0)4436 if (instance->micro_version > 0)
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));
4449 else if (instance->micro_version > 0)4438 else if (instance->minor_version > 0)
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);
4451 else if (instance->major_version > 0)4440 else if (instance->major_version > 0)
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);
44534442
4454 test_true(if_successful == false);4443 test_true(if_successful == false);
44554444
@@ -5018,7 +5007,7 @@
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()
5019 but find that the server is not available.5008 but find that the server is not available.
5020*/5009*/
5021static test_return_t memcached_get_MEMCACHED_SOME_ERRORS(memcached_st *memc)5010static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *memc)
5022{5011{
5023 (void)memc;5012 (void)memc;
5024 memcached_st *tl_memc_h;5013 memcached_st *tl_memc_h;
@@ -5032,21 +5021,18 @@
50325021
5033 // Create a handle.5022 // Create a handle.
5034 tl_memc_h= memcached_create(NULL);5023 tl_memc_h= memcached_create(NULL);
5035 servers= memcached_servers_parse("localhost:9898"); // This server should not exist5024 servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist
5036 memcached_server_push(tl_memc_h, servers);5025 memcached_server_push(tl_memc_h, servers);
5037 memcached_server_list_free(servers);5026 memcached_server_list_free(servers);
50385027
5039 // See if memcached is reachable.5028 // See if memcached is reachable.
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);
50415030
5042 if (value)5031 test_false(value);
5043 {
5044 free(value);
5045 test_true(value); // Pointer won't be zero so this is fine.
5046 }
5047
5048 test_true(len == 0);5032 test_true(len == 0);
5049 test_true(rc == MEMCACHED_SOME_ERRORS);5033 test_true(rc == MEMCACHED_ERRNO);
5034
5035 memcached_free(tl_memc_h);
50505036
5051 return TEST_SUCCESS;5037 return TEST_SUCCESS;
5052}5038}
@@ -5065,12 +5051,7 @@
5065 // See if memcached is reachable.5051 // See if memcached is reachable.
5066 value= memcached_get(memc, key, strlen(key), &len, &flags, &rc);5052 value= memcached_get(memc, key, strlen(key), &len, &flags, &rc);
50675053
5068 if (value)5054 test_false(value);
5069 {
5070 free(value);
5071 test_true(value); // Pointer won't be zero so this is fine.
5072 }
5073
5074 test_true(len == 0);5055 test_true(len == 0);
5075 test_true(rc == MEMCACHED_NOTFOUND);5056 test_true(rc == MEMCACHED_NOTFOUND);
50765057
@@ -5083,7 +5064,7 @@
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()
5084 but find that the server is not available.5065 but find that the server is not available.
5085*/5066*/
5086static test_return_t memcached_get_by_key_MEMCACHED_SOME_ERRORS(memcached_st *memc)5067static test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *memc)
5087{5068{
5088 (void)memc;5069 (void)memc;
5089 memcached_st *tl_memc_h;5070 memcached_st *tl_memc_h;
@@ -5097,21 +5078,18 @@
50975078
5098 // Create a handle.5079 // Create a handle.
5099 tl_memc_h= memcached_create(NULL);5080 tl_memc_h= memcached_create(NULL);
5100 servers= memcached_servers_parse("localhost:9898"); // This server should not exist5081 servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist
5101 memcached_server_push(tl_memc_h, servers);5082 memcached_server_push(tl_memc_h, servers);
5102 memcached_server_list_free(servers);5083 memcached_server_list_free(servers);
51035084
5104 // See if memcached is reachable.5085 // See if memcached is reachable.
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);
51065087
5107 if (value)5088 test_false(value);
5108 {
5109 free(value);
5110 test_true(value); // Pointer won't be zero so this is fine.
5111 }
5112
5113 test_true(len == 0);5089 test_true(len == 0);
5114 test_true(rc == MEMCACHED_SOME_ERRORS);5090 test_true(rc == MEMCACHED_ERRNO);
5091
5092 memcached_free(tl_memc_h);
51155093
5116 return TEST_SUCCESS;5094 return TEST_SUCCESS;
5117}5095}
@@ -5130,12 +5108,7 @@
5130 // See if memcached is reachable.5108 // See if memcached is reachable.
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);
51325110
5133 if (value)5111 test_false(value);
5134 {
5135 free(value);
5136 test_true(value); // Pointer won't be zero so this is fine.
5137 }
5138
5139 test_true(len == 0);5112 test_true(len == 0);
5140 test_true(rc == MEMCACHED_NOTFOUND);5113 test_true(rc == MEMCACHED_NOTFOUND);
51415114
@@ -5575,54 +5548,58 @@
55755548
5576static test_return_t regression_bug_463297(memcached_st *memc)5549static test_return_t regression_bug_463297(memcached_st *memc)
5577{5550{
5578 memcached_st *memc_clone= memcached_clone(NULL, memc);5551 memcached_st *memc_clone= memcached_clone(NULL, memc);
5579 test_true(memc_clone != NULL);5552 test_true(memc_clone != NULL);
5580 test_true(memcached_version(memc_clone) == MEMCACHED_SUCCESS);5553 test_true(memcached_version(memc_clone) == MEMCACHED_SUCCESS);
55815554
55825555 memcached_server_instance_st instance=
5583 if (libmemcached_util_version_check(memc_clone, 1, 1, 2))5556 memcached_server_instance_by_position(memc_clone, 0);
5557
5558 if (instance->major_version > 1 ||
5559 (instance->major_version == 1 &&
5560 instance->minor_version > 2))
5584 {5561 {
5585 /* Binary protocol doesn't support deferred delete */5562 /* Binary protocol doesn't support deferred delete */
5586 memcached_st *bin_clone= memcached_clone(NULL, memc);5563 memcached_st *bin_clone= memcached_clone(NULL, memc);
5587 test_true(bin_clone != NULL);5564 test_true(bin_clone != NULL);
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);
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);
5590 memcached_free(bin_clone);5567 memcached_free(bin_clone);
55915568
5592 memcached_quit(memc_clone);5569 memcached_quit(memc_clone);
55935570
5594 /* If we know the server version, deferred delete should fail5571 /* If we know the server version, deferred delete should fail
5595 * with invalid arguments */5572 * with invalid arguments */
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);
55975574
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 */
5599 memcached_return_t rc= memcached_delete(memc, "foo", 3, 1);5576 memcached_return_t rc= memcached_delete(memc, "foo", 3, 1);
56005577
5601 /* but there is a bug in some of the memcached servers (1.4) that treats5578 /* but there is a bug in some of the memcached servers (1.4) that treats
5602 * the counter as noreply so it doesn't send the proper error message5579 * the counter as noreply so it doesn't send the proper error message
5603 */5580 */
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);
56055582
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 */
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);
5608 rc= memcached_delete(memc, "foo", 3, 1);5585 rc= memcached_delete(memc, "foo", 3, 1);
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);
56105587
5611 /* Same goes for noreply... */5588 /* Same goes for noreply... */
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);
5613 rc= memcached_delete(memc, "foo", 3, 1);5590 rc= memcached_delete(memc, "foo", 3, 1);
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);
56155592
5616 /* but a normal request should go through (and be buffered) */5593 /* but a normal request should go through (and be buffered) */
5617 test_true((rc= memcached_delete(memc, "foo", 3, 0)) == MEMCACHED_BUFFERED);5594 test_true((rc= memcached_delete(memc, "foo", 3, 0)) == MEMCACHED_BUFFERED);
5618 test_true(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS);5595 test_true(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS);
56195596
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);
5621 /* unbuffered noreply should be success */5598 /* unbuffered noreply should be success */
5622 test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_SUCCESS);5599 test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_SUCCESS);
5623 /* unbuffered with reply should be not found... */5600 /* unbuffered with reply should be not found... */
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);
5625 test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_NOTFOUND);5602 test_true(memcached_delete(memc, "foo", 3, 0) == MEMCACHED_NOTFOUND);
5626 }5603 }
56275604
5628 memcached_free(memc_clone);5605 memcached_free(memc_clone);
@@ -5748,6 +5725,39 @@
5748 return TEST_SUCCESS;5725 return TEST_SUCCESS;
5749}5726}
57505727
5728
5729static memcached_return_t stat_printer(memcached_server_instance_st server,
5730 const char *key, size_t key_length,
5731 const char *value, size_t value_length,
5732 void *context)
5733{
5734 (void)server;
5735 (void)context;
5736 (void)key;
5737 (void)key_length;
5738 (void)value;
5739 (void)value_length;
5740
5741 return MEMCACHED_SUCCESS;
5742}
5743
5744static test_return_t memcached_stat_execute_test(memcached_st *memc)
5745{
5746 memcached_return_t rc= memcached_stat_execute(memc, NULL, stat_printer, NULL);
5747 test_true(rc == MEMCACHED_SUCCESS);
5748
5749 rc= memcached_stat_execute(memc, "slabs", stat_printer, NULL);
5750 test_true(rc == MEMCACHED_SUCCESS);
5751
5752 rc= memcached_stat_execute(memc, "items", stat_printer, NULL);
5753 test_true(rc == MEMCACHED_SUCCESS);
5754
5755 rc= memcached_stat_execute(memc, "sizes", stat_printer, NULL);
5756 test_true(rc == MEMCACHED_SUCCESS);
5757
5758 return TEST_SUCCESS;
5759}
5760
5751/*5761/*
5752 * This test ensures that the failure counter isn't incremented during5762 * This test ensures that the failure counter isn't incremented during
5753 * normal termination of the memcached instance.5763 * normal termination of the memcached instance.
@@ -6080,6 +6090,7 @@
60806090
6081/* Clean the server before beginning testing */6091/* Clean the server before beginning testing */
6082test_st tests[] ={6092test_st tests[] ={
6093 {"util_version", 1, (test_callback_fn)util_version_test },
6083 {"flush", 0, (test_callback_fn)flush_test },6094 {"flush", 0, (test_callback_fn)flush_test },
6084 {"init", 0, (test_callback_fn)init_test },6095 {"init", 0, (test_callback_fn)init_test },
6085 {"allocation", 0, (test_callback_fn)allocation_test },6096 {"allocation", 0, (test_callback_fn)allocation_test },
@@ -6135,12 +6146,12 @@
6135#ifdef HAVE_LIBMEMCACHEDUTIL6146#ifdef HAVE_LIBMEMCACHEDUTIL
6136 {"connectionpool", 1, (test_callback_fn)connection_pool_test },6147 {"connectionpool", 1, (test_callback_fn)connection_pool_test },
6137 {"ping", 1, (test_callback_fn)ping_test },6148 {"ping", 1, (test_callback_fn)ping_test },
6138 {"util_version", 1, (test_callback_fn)util_version_test },
6139#endif6149#endif
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},
6141 {"verbosity", 1, (test_callback_fn)test_verbosity},6151 {"verbosity", 1, (test_callback_fn)test_verbosity},
6142 {"test_server_failure", 1, (test_callback_fn)test_server_failure},6152 {"test_server_failure", 1, (test_callback_fn)test_server_failure},
6143 {"cull_servers", 1, (test_callback_fn)test_cull_servers},6153 {"cull_servers", 1, (test_callback_fn)test_cull_servers},
6154 {"memcached_stat_execute", 1, (test_callback_fn)memcached_stat_execute_test},
6144 {0, 0, 0}6155 {0, 0, 0}
6145};6156};
61466157
@@ -6332,9 +6343,9 @@
6332};6343};
63336344
6334test_st error_conditions[] ={6345test_st error_conditions[] ={
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 },
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 },
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 },
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 },
6339 {0, 0, (test_callback_fn)0}6350 {0, 0, (test_callback_fn)0}
6340};6351};
63416352
=== modified file 'tests/mem_udp.c'
--- tests/mem_udp.c 2010-02-18 06:22:15 +0000
+++ tests/mem_udp.c 2010-07-21 16:27:47 +0000
@@ -10,10 +10,13 @@
10 Sample test application.10 Sample test application.
11*/11*/
1212
13#include "config.h"
14
13#include "libmemcached/common.h"15#include "libmemcached/common.h"
1416
15#include <assert.h>17#include <assert.h>
16#include <stdio.h>18#include <stdio.h>
19#include <stdint.h>
17#include <stdlib.h>20#include <stdlib.h>
18#include <string.h>21#include <string.h>
19#include <sys/time.h>22#include <sys/time.h>
@@ -25,14 +28,6 @@
2528
26#include "server.h"29#include "server.h"
2730
28#ifndef INT64_MAX
29#define INT64_MAX LONG_MAX
30#endif
31#ifndef INT32_MAX
32#define INT32_MAX INT_MAX
33#endif
34
35
36#include "test.h"31#include "test.h"
3732
38#define SERVERS_TO_CREATE 533#define SERVERS_TO_CREATE 5
3934
=== modified file 'tests/server.c'
--- tests/server.c 2010-06-15 06:31:25 +0000
+++ tests/server.c 2010-07-21 16:27:47 +0000
@@ -26,12 +26,12 @@
26#include <libmemcached/memcached.h>26#include <libmemcached/memcached.h>
27#include <libmemcached/util.h>27#include <libmemcached/util.h>
28#include <unistd.h>28#include <unistd.h>
29#include <time.h>
30
29#include "server.h"31#include "server.h"
3032
31void server_startup(server_startup_st *construct)33void server_startup(server_startup_st *construct)
32{34{
33 unsigned int x;
34
35 if ((construct->server_list= getenv("MEMCACHED_SERVERS")))35 if ((construct->server_list= getenv("MEMCACHED_SERVERS")))
36 {36 {
37 printf("servers %s\n", construct->server_list);37 printf("servers %s\n", construct->server_list);
@@ -46,7 +46,7 @@
46 char *end_ptr;46 char *end_ptr;
47 end_ptr= server_string_buffer;47 end_ptr= server_string_buffer;
4848
49 for (x= 0; x < construct->count; x++)49 for (uint32_t x= 0; x < construct->count; x++)
50 {50 {
51 char buffer[1024]; /* Nothing special for number */51 char buffer[1024]; /* Nothing special for number */
52 int count;52 int count;
@@ -95,6 +95,39 @@
95 }95 }
96 *end_ptr= 0;96 *end_ptr= 0;
9797
98 for (uint32_t x= 0; x < construct->count; x++)
99 {
100 uint32_t counter= 3;
101 char buffer[1024]; /* Nothing special for number */
102
103 snprintf(buffer, sizeof(buffer), "/tmp/%umemc.pid", x);
104
105 while (--counter)
106 {
107 int memcached_pid;
108
109 FILE *file;
110 file= fopen(buffer, "r");
111 if (file == NULL)
112 {
113 struct timespec req= { .tv_sec= 0, .tv_nsec= 5000 };
114 nanosleep(&req, NULL);
115
116 continue;
117 }
118 char *found= fgets(buffer, sizeof(buffer), file);
119 if (!found)
120 {
121 abort();
122 }
123 // Yes, we currently pitch this and don't make use of it.
124 memcached_pid= atoi(buffer);
125 fclose(file);
126 }
127
128
129 }
130
98 construct->server_list= strdup(server_string_buffer);131 construct->server_list= strdup(server_string_buffer);
99 }132 }
100 printf("servers %s\n", construct->server_list);133 printf("servers %s\n", construct->server_list);
@@ -105,7 +138,7 @@
105138
106 srandom((unsigned int)time(NULL));139 srandom((unsigned int)time(NULL));
107140
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++)
109 {142 {
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]));
111 assert(construct->servers[x].fd == -1);144 assert(construct->servers[x].fd == -1);
@@ -117,11 +150,9 @@
117150
118void server_shutdown(server_startup_st *construct)151void server_shutdown(server_startup_st *construct)
119{152{
120 unsigned int x;
121
122 if (construct->server_list)153 if (construct->server_list)
123 {154 {
124 for (x= 0; x < construct->count; x++)155 for (uint32_t x= 0; x < construct->count; x++)
125 {156 {
126 char buffer[1024]; /* Nothing special for number */157 char buffer[1024]; /* Nothing special for number */
127 sprintf(buffer, "cat /tmp/%umemc.pid | xargs kill", x);158 sprintf(buffer, "cat /tmp/%umemc.pid | xargs kill", x);
128159
=== modified file 'tests/start.c'
--- tests/start.c 2009-12-16 19:03:49 +0000
+++ tests/start.c 2010-07-21 16:27:47 +0000
@@ -9,6 +9,8 @@
9 *9 *
10 */10 */
1111
12#include "config.h"
13
12#include <stdio.h>14#include <stdio.h>
13#include <string.h>15#include <string.h>
14#include "server.h"16#include "server.h"
1517
=== modified file 'tests/test.c'
--- tests/test.c 2010-04-22 00:49:09 +0000
+++ tests/test.c 2010-07-21 16:27:47 +0000
@@ -9,6 +9,9 @@
9/*9/*
10 Sample test application.10 Sample test application.
11*/11*/
12
13#include "config.h"
14
12#include <assert.h>15#include <assert.h>
13#include <stdlib.h>16#include <stdlib.h>
14#include <string.h>17#include <string.h>
@@ -22,6 +25,7 @@
22#include <stdint.h>25#include <stdint.h>
2326
24#include "libmemcached/memcached.h"27#include "libmemcached/memcached.h"
28
25#include "test.h"29#include "test.h"
2630
27static void world_stats_print(world_stats_st *stats)31static void world_stats_print(world_stats_st *stats)
2832
=== added directory 'unittests'
=== added file 'unittests/include.am'
--- unittests/include.am 1970-01-01 00:00:00 +0000
+++ unittests/include.am 2010-07-21 16:27:47 +0000
@@ -0,0 +1,20 @@
1# vim:ft=automake
2# included from Top Level Makefile.am
3# All paths should be given relative to the root
4
5if HAVE_LIBGTEST
6check_PROGRAMS += unittests/unittests
7endif
8
9unittests_unittests_SOURCES= \
10 unittests/main.cc \
11 unittests/strings.cc
12
13unittests_unittest_CXXFLAGS= ${AM_CXXFLAGS} ${NO_WERROR}
14unittests_unittests_LDADD= \
15 tests/libserver.la \
16 libmemcached/libmemcachedinternal.la \
17 ${TESTS_LDADDS} ${LTLIBGTEST}
18# Shorthand
19unit: check-TESTS
20
021
=== added file 'unittests/main.cc'
--- unittests/main.cc 1970-01-01 00:00:00 +0000
+++ unittests/main.cc 2010-07-21 16:27:47 +0000
@@ -0,0 +1,21 @@
1/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2010 Monty Taylor
5 *
6 * All rights reserved.
7 *
8 * Use and distribution licensed under the BSD license. See
9 * the COPYING file in the parent directory for full text.
10 */
11
12#include "config.h"
13
14#include <gtest/gtest.h>
15
16
17int main(int argc, char **argv)
18{
19 ::testing::InitGoogleTest(&argc, argv);
20 return RUN_ALL_TESTS();
21}
022
=== added file 'unittests/strings.cc'
--- unittests/strings.cc 1970-01-01 00:00:00 +0000
+++ unittests/strings.cc 2010-07-21 16:27:47 +0000
@@ -0,0 +1,134 @@
1/* libMemcached
2 * Copyright (C) 2010 Brian Aker
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 */
8
9#include "config.h"
10
11#define __STDC_LIMIT_MACROS
12#include <stdint.h>
13
14#include <gtest/gtest.h>
15
16#include <libmemcached/common.h>
17
18TEST(memcached_string_st, memcached_create_static)
19{
20 memcached_string_st string;
21 memcached_string_st *string_ptr;
22
23 memcached_st *memc= memcached_create(NULL);
24 string_ptr= memcached_string_create(memc, &string, 0);
25 ASSERT_TRUE(string.options.is_initialized);
26 ASSERT_TRUE(string_ptr);
27
28 /* The following two better be the same! */
29 ASSERT_FALSE(memcached_is_allocated(string_ptr));
30 ASSERT_FALSE(memcached_is_allocated(&string));
31 EXPECT_EQ(&string, string_ptr);
32
33 ASSERT_TRUE(string.options.is_initialized);
34 ASSERT_TRUE(memcached_is_initialized(&string));
35 memcached_string_free(&string);
36 ASSERT_FALSE(memcached_is_initialized(&string));
37
38 memcached_free(memc);
39}
40
41TEST(memcached_string_st, memcached_create_null)
42{
43 memcached_string_st *string;
44 memcached_st *memc= memcached_create(NULL);
45
46 string= memcached_string_create(memc, NULL, 0);
47 ASSERT_TRUE(string);
48 ASSERT_TRUE(memcached_is_allocated(string));
49 ASSERT_TRUE(memcached_is_initialized(string));
50 memcached_string_free(string);
51
52 memcached_free(memc);
53}
54
55TEST(memcached_string_st, string_alloc_with_size)
56{
57 memcached_string_st *string;
58 memcached_st *memc= memcached_create(NULL);
59
60 string= memcached_string_create(memc, NULL, 1024);
61 ASSERT_TRUE(string);
62 ASSERT_TRUE(memcached_is_allocated(string));
63 ASSERT_TRUE(memcached_is_initialized(string));
64 memcached_string_free(string);
65
66 memcached_free(memc);
67}
68
69TEST(memcached_string_st, string_alloc_with_size_toobig)
70{
71 memcached_st *memc= memcached_create(NULL);
72 memcached_string_st *string;
73
74 string= memcached_string_create(memc, NULL, SIZE_MAX);
75 ASSERT_FALSE(string);
76
77 memcached_free(memc);
78}
79
80TEST(memcached_string_st, string_alloc_append)
81{
82 char buffer[SMALL_STRING_LEN];
83 memcached_string_st *string;
84
85 memcached_st *memc= memcached_create(NULL);
86
87 /* Ring the bell! */
88 memset(buffer, 6, SMALL_STRING_LEN);
89
90 string= memcached_string_create(memc, NULL, 100);
91 ASSERT_TRUE(string);
92 ASSERT_TRUE(memcached_is_allocated(string));
93 ASSERT_TRUE(memcached_is_initialized(string));
94
95 for (uint32_t x= 0; x < 1024; x++)
96 {
97 memcached_return_t rc;
98 rc= memcached_string_append(string, buffer, SMALL_STRING_LEN);
99 EXPECT_EQ(rc, MEMCACHED_SUCCESS);
100 }
101 ASSERT_TRUE(memcached_is_allocated(string));
102 memcached_string_free(string);
103
104 memcached_free(memc);
105}
106
107TEST(memcached_string_st, string_alloc_append_toobig)
108{
109 memcached_return_t rc;
110 char buffer[SMALL_STRING_LEN];
111 memcached_string_st *string;
112
113 memcached_st *memc= memcached_create(NULL);
114
115 /* Ring the bell! */
116 memset(buffer, 6, SMALL_STRING_LEN);
117
118 string= memcached_string_create(memc, NULL, 100);
119 ASSERT_TRUE(string);
120 ASSERT_TRUE(memcached_is_allocated(string));
121 ASSERT_TRUE(memcached_is_initialized(string));
122
123 for (uint32_t x= 0; x < 1024; x++)
124 {
125 rc= memcached_string_append(string, buffer, SMALL_STRING_LEN);
126 EXPECT_EQ(rc, MEMCACHED_SUCCESS);
127 }
128 rc= memcached_string_append(string, buffer, SIZE_MAX);
129 EXPECT_EQ(rc, MEMCACHED_MEMORY_ALLOCATION_FAILURE);
130 ASSERT_TRUE(memcached_is_allocated(string));
131 memcached_string_free(string);
132
133 memcached_free(memc);
134}

Subscribers

People subscribed via source and target branches

to all changes: