X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fmemslap.c;h=0baff1df62a0db4990cde01dde9902eb3defccdc;hb=7afbf5c09228f6614b8831ec5f374971a38bbf9f;hp=7aa69eadf543f7b039269e89c038857a2b2a578f;hpb=b9795632aa1e69a27215a1c20e51ca8f999feed5;p=awesomized%2Flibmemcached diff --git a/clients/memslap.c b/clients/memslap.c index 7aa69ead..0baff1df 100644 --- a/clients/memslap.c +++ b/clients/memslap.c @@ -1,3 +1,4 @@ +#include "libmemcached/common.h" #include #include #include @@ -9,6 +10,7 @@ #include #include #include +#include #include @@ -77,6 +79,7 @@ static unsigned int opt_createial_load= 0; static unsigned int opt_concurrency= 0; static int opt_displayflag= 0; static char *opt_servers= NULL; +static int opt_udp_io= 0; test_type opt_test= SET_TEST; int main(int argc, char *argv[]) @@ -139,6 +142,15 @@ void scheduler(memcached_server_st *servers, conclusions_st *conclusion) PTHREAD_CREATE_DETACHED); memc= memcached_create(NULL); + + /* We need to set udp behavior before adding servers to the client */ + if (opt_udp_io) + { + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, opt_udp_io); + unsigned int x= 0; + for(x= 0; x < servers[0].count; x++ ) + servers[x].type= MEMCACHED_CONNECTION_UDP; + } memcached_server_push(memc, servers); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary); @@ -167,8 +179,7 @@ void scheduler(memcached_server_st *servers, conclusions_st *conclusion) for (x= 0; x < opt_concurrency; x++) { thread_context_st *context; - context= (thread_context_st *)malloc(sizeof(thread_context_st)); - memset(context, 0, sizeof(thread_context_st)); + context= (thread_context_st *)calloc(1, sizeof(thread_context_st)); context->memc= memcached_clone(NULL, memc); context->test= opt_test; @@ -240,6 +251,7 @@ void options_parse(int argc, char *argv[]) {"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, {"version", no_argument, NULL, OPT_VERSION}, {"binary", no_argument, NULL, OPT_BINARY}, + {"udp", no_argument, NULL, OPT_UDP}, {0, 0, 0, 0}, }; @@ -254,6 +266,15 @@ void options_parse(int argc, char *argv[]) { case 0: break; + case OPT_UDP: + if (opt_test == GET_TEST) + { + fprintf(stderr, "You can not run a get test in UDP mode. UDP mode " + "does not currently support get ops.\n"); + exit(1); + } + opt_udp_io= 1; + break; case OPT_BINARY: opt_binary = 1; break; @@ -274,7 +295,15 @@ void options_parse(int argc, char *argv[]) break; case OPT_SLAP_TEST: if (!strcmp(optarg, "get")) + { + if (opt_udp_io == 1) + { + fprintf(stderr, "You can not run a get test in UDP mode. UDP mode " + "does not currently support get ops.\n"); + exit(1); + } opt_test= GET_TEST ; + } else if (!strcmp(optarg, "set")) opt_test= SET_TEST; else @@ -343,6 +372,7 @@ void *run_task(void *p) switch (context->test) { case SET_TEST: + assert(context->execute_pairs); execute_set(memc, context->execute_pairs, context->execute_number); break; case GET_TEST: