#include "test.h"
#define GLOBAL_COUNT 100000
+#define GLOBAL2_COUNT 1000
+static uint32_t global_count;
+
static pairs_st *global_pairs;
static char *global_keys[GLOBAL_COUNT];
static size_t global_keys_length[GLOBAL_COUNT];
if (rc == MEMCACHED_NOTFOUND)
errors++;
else
+ {
+ WATCHPOINT_ERROR(rc);
assert(0);
+ }
continue;
}
return 0;
}
+/*
+ Bug found where command total one more than MEMCACHED_MAX_BUFFER
+ set key34567890 0 0 8169 \r\n is sent followed by buffer of size 8169, followed by 8169
+ */
+uint8_t user_supplied_bug13(memcached_st *memc)
+{
+ char key[] = "key34567890";
+ char *overflow;
+ memcached_return rc;
+ size_t overflowSize;
+
+ char commandFirst[]= "set key34567890 0 0 ";
+ char commandLast[] = " \r\n"; /* first line of command sent to server */
+ size_t commandLength;
+ size_t testSize;
+
+ commandLength = strlen(commandFirst) + strlen(commandLast) + 4; /* 4 is number of characters in size, probably 8196 */
+
+ overflowSize = MEMCACHED_MAX_BUFFER - commandLength;
+
+ for (testSize= overflowSize - 1; testSize < overflowSize + 1; testSize++)
+ {
+ overflow= malloc(testSize);
+ assert(overflow != NULL);
+
+ memset(overflow, 'x', testSize);
+ rc= memcached_set(memc, key, strlen(key),
+ overflow, testSize, 0, 0);
+ assert(rc == MEMCACHED_SUCCESS);
+ free(overflow);
+ }
+
+ return 0;
+}
+
uint8_t result_static(memcached_st *memc)
{
memcached_result_st result;
return 0;
}
-uint8_t generate_data(memcached_st *memc)
+uint8_t generate_pairs(memcached_st *memc)
{
unsigned long long x;
- global_pairs= pairs_generate(GLOBAL_COUNT);
- execute_set(memc, global_pairs, GLOBAL_COUNT);
+ global_pairs= pairs_generate(GLOBAL_COUNT, 400);
+ global_count= GLOBAL_COUNT;
- for (x= 0; x < GLOBAL_COUNT; x++)
+ for (x= 0; x < global_count; x++)
{
global_keys[x]= global_pairs[x].key;
global_keys_length[x]= global_pairs[x].key_length;
return 0;
}
-uint8_t generate_buffer_data(memcached_st *memc)
+uint8_t generate_large_pairs(memcached_st *memc)
{
- int latch= 0;
+ unsigned long long x;
+ global_pairs= pairs_generate(GLOBAL2_COUNT, MEMCACHED_MAX_BUFFER+10);
+ global_count= GLOBAL2_COUNT;
- latch= 1;
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, &latch);
- generate_data(memc);
+ for (x= 0; x < global_count; x++)
+ {
+ global_keys[x]= global_pairs[x].key;
+ global_keys_length[x]= global_pairs[x].key_length;
+ }
return 0;
}
-#ifdef NOT_DONE
-uint8_t mset_data(memcached_st *memc)
+uint8_t generate_data(memcached_st *memc)
{
- unsigned long long x;
- global_pairs= pairs_generate(GLOBAL_COUNT);
+ execute_set(memc, global_pairs, global_count);
- (void)memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0);
+ return 0;
+}
- for (x= 0; x < GLOBAL_COUNT; x++)
- {
- global_keys[x]= global_pairs[x].key;
- global_keys_length[x]= global_pairs[x].key_length;
- }
+uint8_t generate_buffer_data(memcached_st *memc)
+{
+ int latch= 0;
+
+ latch= 1;
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, &latch);
+ generate_data(memc);
return 0;
}
-#endif
uint8_t get_read(memcached_st *memc)
{
size_t return_value_length;
uint32_t flags;
- for (x= 0; x < GLOBAL_COUNT; x++)
+ for (x= 0; x < global_count; x++)
{
return_value= memcached_get(memc, global_keys[x], global_keys_length[x],
&return_value_length, &flags, &rc);
{
memcached_return rc;
- rc= memcached_mget(memc, global_keys, global_keys_length, GLOBAL_COUNT);
+ rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
assert(rc == MEMCACHED_SUCCESS);
/* Turn this into a help function */
{
{
memcached_return rc;
- rc= memcached_mget(memc, global_keys, global_keys_length, GLOBAL_COUNT);
+ rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
assert(rc == MEMCACHED_SUCCESS);
/* Turn this into a help function */
{
unsigned int counter;
unsigned int (*callbacks[1])(memcached_st *, memcached_result_st *, void *);
- rc= memcached_mget(memc, global_keys, global_keys_length, GLOBAL_COUNT);
+ rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
assert(rc == MEMCACHED_SUCCESS);
callbacks[0]= &callback_counter;
{
unsigned int x;
- for (x= 0; x < GLOBAL_COUNT; x++)
+ for (x= 0; x < global_count; x++)
{
(void)memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0);
}
latch= 1;
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, &latch);
- for (x= 0; x < GLOBAL_COUNT; x++)
+ for (x= 0; x < global_count; x++)
{
(void)memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0);
}
{"user_supplied_bug10", 1, user_supplied_bug10 },
{"user_supplied_bug11", 1, user_supplied_bug11 },
{"user_supplied_bug12", 1, user_supplied_bug12 },
+ {"user_supplied_bug13", 1, user_supplied_bug13 },
{0, 0, 0}
};
test_st generate_tests[] ={
+ {"generate_pairs", 1, generate_pairs },
{"generate_data", 1, generate_data },
{"get_read", 0, get_read },
{"delete_generate", 0, delete_generate },
{"mget_read_result", 0, mget_read_result },
{"mget_read_function", 0, mget_read_function },
{"cleanup", 1, cleanup_pairs },
+ {"generate_large_pairs", 1, generate_large_pairs },
+ {"generate_data", 1, generate_data },
+ {"generate_buffer_data", 1, generate_buffer_data },
+ {"cleanup", 1, cleanup_pairs },
{0, 0, 0}
};