X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fmemslap.c;h=88a0f21ca25be9b4dde03b8d9b43613d8d368ff5;hb=e110b4a534fd2d052461777411dac53b40c165bf;hp=37e211a0dd4f2d8bb53ccf735a9319311c569cda;hpb=7fafbd3dbd318577553476edf6436926aff9014c;p=m6w6%2Flibmemcached diff --git a/clients/memslap.c b/clients/memslap.c index 37e211a0..88a0f21c 100644 --- a/clients/memslap.c +++ b/clients/memslap.c @@ -13,9 +13,22 @@ * Mingqiang Zhuang * */ +#include "config.h" + #include #include #include +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + #include "ms_sigsegv.h" #include "ms_setting.h" @@ -298,6 +311,7 @@ void ms_help_command(const char *command_name, const char *description) { printf(" -%c, --%s%c\n", long_options[x].val, long_options[x].name, long_options[x].has_arg ? '=' : ' '); + if ((help_message= (char *)ms_lookup_help(long_options[x].val)) != NULL) { printf(" %s\n", help_message); @@ -417,7 +431,7 @@ static void ms_options_parse(int argc, char *argv[]) break; case OPT_CONCURRENCY: /* --concurrency or -c */ - ms_setting.nconns= (int)strtol(optarg, (char **) NULL, 10); + ms_setting.nconns= (uint32_t)strtoul(optarg, (char **) NULL, 10); if (ms_setting.nconns <= 0) { fprintf(stderr, "Concurrency must be greater than 0.:-)\n"); @@ -613,11 +627,20 @@ static int ms_check_para() { if (ms_setting.srv_str == NULL) { - fprintf(stderr, "No Servers provided.\n\n"); - return -1; + char *temp; + + if ((temp= getenv("MEMCACHED_SERVERS"))) + { + ms_setting.srv_str= strdup(temp); + } + else + { + fprintf(stderr, "No Servers provided\n\n"); + return -1; + } } - if (ms_setting.nconns % ms_setting.nthreads != 0) + if (ms_setting.nconns % (uint32_t)ms_setting.nthreads != 0) { fprintf(stderr, "Concurrency must be the multiples of threads count.\n"); return -1; @@ -761,7 +784,7 @@ static void ms_monitor_slap_mode() { /* Wait all the connects complete warm up. */ pthread_mutex_lock(&ms_global.init_lock.lock); - while (ms_global.init_lock.count < ms_setting.nconns) + while (ms_global.init_lock.count < (int)ms_setting.nconns) { pthread_cond_wait(&ms_global.init_lock.cond, &ms_global.init_lock.lock); @@ -811,7 +834,7 @@ static void ms_monitor_slap_mode() * We loop until we know that all connects have cleaned up. */ pthread_mutex_lock(&ms_global.run_lock.lock); - while (ms_global.run_lock.count < ms_setting.nconns) + while (ms_global.run_lock.count < (int)ms_setting.nconns) { pthread_cond_wait(&ms_global.run_lock.cond, &ms_global.run_lock.lock); }