Merge lp:~trond-norbye/libmemcached/bug_434484 into lp:~tangent-org/libmemcached/trunk

Proposed by Trond Norbye
Status: Merged
Merged at revision: not available
Proposed branch: lp:~trond-norbye/libmemcached/bug_434484
Merge into: lp:~tangent-org/libmemcached/trunk
Diff against target: None lines
To merge this branch: bzr merge lp:~trond-norbye/libmemcached/bug_434484
Reviewer Review Type Date Requested Status
Libmemcached-developers Pending
Review via email: mp+12208@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Trond Norbye (trond-norbye) wrote :

Fixed two bugs:
1) memcached_dump didn't work on a memcached 1.4.2 server, because it reduced the number of slabs to 200
2) Fix mapping of the error codes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libmemcached/memcached_constants.h'
2--- libmemcached/memcached_constants.h 2009-09-17 19:14:07 +0000
3+++ libmemcached/memcached_constants.h 2009-09-22 08:26:38 +0000
4@@ -62,6 +62,7 @@
5 MEMCACHED_INVALID_HOST_PROTOCOL,
6 MEMCACHED_SERVER_MARKED_DEAD,
7 MEMCACHED_UNKNOWN_STAT_KEY,
8+ MEMCACHED_E2BIG,
9 MEMCACHED_MAXIMUM_RETURN /* Always add new error code before */
10 } memcached_return;
11
12
13=== modified file 'libmemcached/memcached_dump.c'
14--- libmemcached/memcached_dump.c 2009-07-18 17:10:35 +0000
15+++ libmemcached/memcached_dump.c 2009-09-22 07:58:59 +0000
16@@ -55,6 +55,18 @@
17 }
18 else if (rc == MEMCACHED_END)
19 break;
20+ else if (rc == MEMCACHED_SERVER_ERROR || rc == MEMCACHED_CLIENT_ERROR)
21+ {
22+ /* If we try to request stats cachedump for a slab class that is too big
23+ * the server will return an incorrect error message:
24+ * "MEMCACHED_SERVER_ERROR failed to allocate memory"
25+ * This isn't really a fatal error, so let's just skip it. I want to
26+ * fix the return value from the memcached server to a CLIENT_ERROR,
27+ * so let's add support for that as well right now.
28+ */
29+ rc= MEMCACHED_END;
30+ break;
31+ }
32 else
33 goto error;
34 }
35
36=== modified file 'libmemcached/memcached_response.c'
37--- libmemcached/memcached_response.c 2009-07-18 17:37:40 +0000
38+++ libmemcached/memcached_response.c 2009-09-22 08:26:38 +0000
39@@ -493,11 +493,17 @@
40 case PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS:
41 rc= MEMCACHED_DATA_EXISTS;
42 break;
43+ case PROTOCOL_BINARY_RESPONSE_NOT_STORED:
44+ rc= MEMCACHED_NOTSTORED;
45+ break;
46 case PROTOCOL_BINARY_RESPONSE_E2BIG:
47+ rc= MEMCACHED_E2BIG;
48+ break;
49+ case PROTOCOL_BINARY_RESPONSE_ENOMEM:
50+ rc= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
51+ break;
52 case PROTOCOL_BINARY_RESPONSE_EINVAL:
53- case PROTOCOL_BINARY_RESPONSE_NOT_STORED:
54 case PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND:
55- case PROTOCOL_BINARY_RESPONSE_ENOMEM:
56 default:
57 /* @todo fix the error mappings */
58 rc= MEMCACHED_PROTOCOL_ERROR;
59
60=== modified file 'libmemcached/memcached_strerror.c'
61--- libmemcached/memcached_strerror.c 2009-07-08 13:38:34 +0000
62+++ libmemcached/memcached_strerror.c 2009-09-22 08:26:38 +0000
63@@ -78,6 +78,8 @@
64 return "SERVER IS MARKED DEAD";
65 case MEMCACHED_UNKNOWN_STAT_KEY:
66 return "ENCOUNTERED AN UNKNOWN STAT KEY";
67+ case MEMCACHED_E2BIG:
68+ return "ITEM TOO BIG";
69 case MEMCACHED_MAXIMUM_RETURN:
70 return "Gibberish returned!";
71 default:
72
73=== modified file 'tests/function.c'
74--- tests/function.c 2009-09-10 10:57:11 +0000
75+++ tests/function.c 2009-09-22 08:26:38 +0000
76@@ -287,17 +287,25 @@
77 static test_return error_test(memcached_st *memc)
78 {
79 memcached_return rc;
80- uint32_t values[] = { 851992627U, 2337886783U, 3196981036U, 4001849190U, 982370485U, 1263635348U, 4242906218U, 3829656100U, 1891735253U,
81- 334139633U, 2257084983U, 3088286104U, 13199785U, 2542027183U, 1097051614U, 199566778U, 2748246961U, 2465192557U,
82- 1664094137U, 2405439045U, 1842224848U, 692413798U, 3479807801U, 919913813U, 4269430871U, 610793021U, 527273862U,
83- 1437122909U, 2300930706U, 2943759320U, 674306647U, 2400528935U, 54481931U, 4186304426U, 1741088401U, 2979625118U,
84- 4159057246U };
85+ uint32_t values[] = { 851992627U, 2337886783U, 3196981036U, 4001849190U,
86+ 982370485U, 1263635348U, 4242906218U, 3829656100U,
87+ 1891735253U, 334139633U, 2257084983U, 3088286104U,
88+ 13199785U, 2542027183U, 1097051614U, 199566778U,
89+ 2748246961U, 2465192557U, 1664094137U, 2405439045U,
90+ 1842224848U, 692413798U, 3479807801U, 919913813U,
91+ 4269430871U, 610793021U, 527273862U, 1437122909U,
92+ 2300930706U, 2943759320U, 674306647U, 2400528935U,
93+ 54481931U, 4186304426U, 1741088401U, 2979625118U,
94+ 4159057246U, 3425930182U};
95
96- assert(MEMCACHED_MAXIMUM_RETURN == 37); // You have updated the memcache_error messages but not updated docs/tests.
97+ // You have updated the memcache_error messages but not updated docs/tests.
98+ assert(MEMCACHED_MAXIMUM_RETURN == 38);
99 for (rc= MEMCACHED_SUCCESS; rc < MEMCACHED_MAXIMUM_RETURN; rc++)
100 {
101 uint32_t hash_val;
102- hash_val= memcached_generate_hash_value(memcached_strerror(memc, rc), strlen(memcached_strerror(memc, rc)), MEMCACHED_HASH_JENKINS);
103+ const char *msg= memcached_strerror(memc, rc);
104+ hash_val= memcached_generate_hash_value(msg, strlen(msg),
105+ MEMCACHED_HASH_JENKINS);
106 assert(values[rc] == hash_val);
107 }
108
109@@ -4385,6 +4393,28 @@
110 return TEST_SUCCESS;
111 }
112
113+static test_return regression_bug_434484(memcached_st *memc)
114+{
115+ if (pre_binary(memc) != TEST_SUCCESS)
116+ return TEST_SUCCESS;
117+
118+ memcached_return ret;
119+ const char *key= "regression_bug_434484";
120+ size_t keylen= strlen(key);
121+
122+ ret= memcached_append(memc, key, keylen, key, keylen, 0, 0);
123+ assert(ret == MEMCACHED_NOTSTORED);
124+
125+ size_t size= 2048 * 1024;
126+ void *data= malloc(size);
127+ assert(data != NULL);
128+ ret= memcached_set(memc, key, keylen, data, size, 0, 0);
129+ assert(ret == MEMCACHED_E2BIG);
130+ free(data);
131+
132+ return TEST_SUCCESS;
133+}
134+
135 test_st udp_setup_server_tests[] ={
136 {"set_udp_behavior_test", 0, set_udp_behavior_test},
137 {"add_tcp_server_udp_client_test", 0, add_tcp_server_udp_client_test},
138@@ -4537,6 +4567,17 @@
139 {0, 0, 0}
140 };
141
142+/*
143+ * The following test suite is used to verify that we don't introduce
144+ * regression bugs. If you want more information about the bug / test,
145+ * you should look in the bug report at
146+ * http://bugs.launchpad.net/libmemcached
147+ */
148+test_st regression_tests[]= {
149+ {"lp:434484", 1, regression_bug_434484 },
150+ {0, 0, 0}
151+};
152+
153 test_st generate_tests[] ={
154 {"generate_pairs", 1, generate_pairs },
155 {"generate_data", 1, generate_data },
156@@ -4645,6 +4686,7 @@
157 {"test_hashes", 0, 0, hash_tests},
158 {"replication", pre_replication, 0, replication_tests},
159 {"replication_noblock", pre_replication_noblock, 0, replication_tests},
160+ {"regression", 0, 0, regression_tests},
161 {0, 0, 0, 0}
162 };
163

Subscribers

People subscribed via source and target branches

to all changes: