Merge lp:~jc.redoutey/libmemcached/mget_execute into lp:~tangent-org/libmemcached/trunk

Proposed by JC Redoutey
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jc.redoutey/libmemcached/mget_execute
Merge into: lp:~tangent-org/libmemcached/trunk
Diff against target: 162 lines (+92/-3)
4 files modified
libmemcached/memcached.h (+1/-0)
libmemcached/memcached_io.c (+5/-0)
libmemcached/memcached_response.c (+1/-1)
tests/function.c (+85/-2)
To merge this branch: bzr merge lp:~jc.redoutey/libmemcached/mget_execute
Reviewer Review Type Date Requested Status
Libmemcached-developers Pending
Review via email: mp+15450@code.launchpad.net
To post a comment you must log in.
Revision history for this message
JC Redoutey (jc.redoutey) wrote :

New version with the changes asked
cheers

Revision history for this message
Brian Aker (brianaker) wrote :

I am looking at porting this forward right now.

A couple of things:

1) When you modify memcached_st to add a new member, you need to make sure it is initialized correctly.
2) Mixing int with size_t will just cause porting issues (this was in function.c).

I need to give a better example of how to use just one server during a test.

Thanks for this work, I am sorry I didn't get it in faster.

Cheers,
   -Brian

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libmemcached/memcached.h'
--- libmemcached/memcached.h 2009-11-09 19:19:38 +0000
+++ libmemcached/memcached.h 2009-11-30 21:30:22 +0000
@@ -75,6 +75,7 @@
7575
76struct memcached_st {76struct memcached_st {
77 uint8_t purging;77 uint8_t purging;
78 uint8_t processing_input;
78 bool is_allocated;79 bool is_allocated;
79 uint8_t distribution;80 uint8_t distribution;
80 uint8_t hash;81 uint8_t hash;
8182
=== modified file 'libmemcached/memcached_io.c'
--- libmemcached/memcached_io.c 2009-10-14 11:40:42 +0000
+++ libmemcached/memcached_io.c 2009-11-30 21:30:22 +0000
@@ -120,10 +120,15 @@
120 */120 */
121 memcached_callback_st cb= *ptr->root->callbacks;121 memcached_callback_st cb= *ptr->root->callbacks;
122122
123 ptr->root->processing_input = 1;
124
123 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];125 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
124 memcached_return error;126 memcached_return error;
125 error= memcached_response(ptr, buffer, sizeof(buffer),127 error= memcached_response(ptr, buffer, sizeof(buffer),
126 &ptr->root->result);128 &ptr->root->result);
129
130 ptr->root->processing_input = 0;
131
127 if (error == MEMCACHED_SUCCESS)132 if (error == MEMCACHED_SUCCESS)
128 {133 {
129 for (unsigned int x= 0; x < cb.number_of_callback; x++)134 for (unsigned int x= 0; x < cb.number_of_callback; x++)
130135
=== modified file 'libmemcached/memcached_response.c'
--- libmemcached/memcached_response.c 2009-10-06 10:48:57 +0000
+++ libmemcached/memcached_response.c 2009-11-30 21:30:22 +0000
@@ -44,7 +44,7 @@
44 memcached_result_st *result)44 memcached_result_st *result)
45{45{
46 /* We may have old commands in the buffer not set, first purge */46 /* We may have old commands in the buffer not set, first purge */
47 if (ptr->root->flags & MEM_NO_BLOCK)47 if ((ptr->root->flags & MEM_NO_BLOCK) && (!ptr->root->processing_input))
48 (void)memcached_io_write(ptr, NULL, 0, 1);48 (void)memcached_io_write(ptr, NULL, 0, 1);
4949
50 /*50 /*
5151
=== modified file 'tests/function.c'
--- tests/function.c 2009-11-27 17:05:51 +0000
+++ tests/function.c 2009-11-30 21:30:22 +0000
@@ -3922,7 +3922,7 @@
3922}3922}
39233923
3924#ifdef HAVE_LIBMEMCACHEDUTIL3924#ifdef HAVE_LIBMEMCACHEDUTIL
3925static void* connection_release(void *arg) 3925static void* connection_release(void *arg)
3926{3926{
3927 struct {3927 struct {
3928 memcached_pool_st* pool;3928 memcached_pool_st* pool;
@@ -4169,7 +4169,7 @@
4169 rc= memcached_set(memc, keys[x], len[x], "1", 1, 0, 0);4169 rc= memcached_set(memc, keys[x], len[x], "1", 1, 0, 0);
4170 test_truth(rc == MEMCACHED_SUCCESS);4170 test_truth(rc == MEMCACHED_SUCCESS);
4171 }4171 }
4172 4172
4173 memcached_quit(memc);4173 memcached_quit(memc);
41744174
4175 for (int x=0; x< 7; ++x) {4175 for (int x=0; x< 7; ++x) {
@@ -5391,6 +5391,88 @@
5391 return TEST_SUCCESS;5391 return TEST_SUCCESS;
5392}5392}
53935393
5394
5395
5396
5397/*
5398 * Test that ensures mget_execute does not end into recursive calls that finally fails
5399 */
5400static test_return_t regression_bug_490486(memcached_st *memc)
5401{
5402
5403 memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,1);
5404 memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK,1);
5405 memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT,1000);
5406 memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT,1);
5407 memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT,3600);
5408
5409 /*
5410 * I only want to hit _one_ server so I know the number of requests I'm
5411 * sending in the pipeline.
5412 */
5413 uint32_t number_of_hosts= memc->number_of_hosts;
5414 memc->number_of_hosts= 1;
5415 int max_keys= 20480;
5416
5417
5418 char **keys= calloc((size_t)max_keys, sizeof(char*));
5419 size_t *key_length=calloc((size_t)max_keys, sizeof(size_t));
5420
5421 /* First add all of the items.. */
5422 char blob[1024] = {0};
5423 memcached_return rc;
5424 for (int x= 0; x < max_keys; ++x)
5425 {
5426 char k[251];
5427 key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%u", x);
5428 keys[x]= strdup(k);
5429 assert(keys[x] != NULL);
5430 rc= memcached_set(memc, keys[x], key_length[x], blob, sizeof(blob), 0, 0);
5431 assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
5432 }
5433
5434 /* Try to get all of them with a large multiget */
5435 unsigned int counter= 0;
5436 memcached_execute_function callbacks[1]= { [0]= &callback_counter };
5437 rc= memcached_mget_execute(memc, (const char**)keys, key_length,
5438 (size_t)max_keys, callbacks, &counter, 1);
5439
5440 assert(rc == MEMCACHED_SUCCESS);
5441 char* the_value = NULL;
5442 char the_key[MEMCACHED_MAX_KEY];
5443 size_t the_key_length;
5444 size_t the_value_length;
5445 uint32_t the_flags;
5446
5447 do {
5448 the_value = memcached_fetch(memc, the_key, &the_key_length, &the_value_length, &the_flags, &rc);
5449 if((the_value!= NULL) && (rc == MEMCACHED_SUCCESS))
5450 {
5451 ++counter;
5452 free(the_value);
5453 }
5454
5455 }while( (the_value!= NULL) && (rc == MEMCACHED_SUCCESS));
5456
5457
5458 assert(rc == MEMCACHED_END);
5459
5460 /* Verify that we got all of the items */
5461 assert(counter == (unsigned int)max_keys);
5462
5463 /* Release all allocated resources */
5464 for (int x= 0; x < max_keys; ++x)
5465 free(keys[x]);
5466 free(keys);
5467 free(key_length);
5468
5469 memc->number_of_hosts= number_of_hosts;
5470 return TEST_SUCCESS;
5471}
5472
5473
5474
5475
5394test_st udp_setup_server_tests[] ={5476test_st udp_setup_server_tests[] ={
5395 {"set_udp_behavior_test", 0, set_udp_behavior_test},5477 {"set_udp_behavior_test", 0, set_udp_behavior_test},
5396 {"add_tcp_server_udp_client_test", 0, add_tcp_server_udp_client_test},5478 {"add_tcp_server_udp_client_test", 0, add_tcp_server_udp_client_test},
@@ -5567,6 +5649,7 @@
5567 {"lp:442914", 1, regression_bug_442914 },5649 {"lp:442914", 1, regression_bug_442914 },
5568 {"lp:447342", 1, regression_bug_447342 },5650 {"lp:447342", 1, regression_bug_447342 },
5569 {"lp:463297", 1, regression_bug_463297 },5651 {"lp:463297", 1, regression_bug_463297 },
5652 {"lp:490486", 1, regression_bug_490486 },
5570 {0, 0, 0}5653 {0, 0, 0}
5571};5654};
55725655

Subscribers

People subscribed via source and target branches

to all changes: