From: Brian Aker Date: Thu, 14 Jan 2010 05:18:46 +0000 (-0800) Subject: Merge Monty X-Git-Tag: 0.40~115 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;ds=sidebyside;h=c2aabfa4fef8c0069f693a5522c6c23a00ae9d83;hp=-c;p=m6w6%2Flibmemcached Merge Monty --- c2aabfa4fef8c0069f693a5522c6c23a00ae9d83 diff --combined clients/memslap.c index 804d8b7b,11b4df87..efda8aff --- a/clients/memslap.c +++ b/clients/memslap.c @@@ -13,9 -13,22 +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,7 -311,6 +311,7 @@@ void ms_help_command(const char *comman { 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); @@@ -418,7 -430,7 +431,7 @@@ static void ms_options_parse(int argc, break; case OPT_CONCURRENCY: /* --concurrency or -c */ - ms_setting.nconns= atoi(optarg); + ms_setting.nconns= (int)strtol(optarg, (char **) NULL, 10); if (ms_setting.nconns <= 0) { fprintf(stderr, "Concurrency must be greater than 0.:-)\n"); @@@ -427,7 -439,7 +440,7 @@@ break; case OPT_EXECUTE_NUMBER: /* --execute_number or -x */ - ms_setting.exec_num= atoll(optarg); + ms_setting.exec_num= (int)strtol(optarg, (char **) NULL, 10); if (ms_setting.exec_num <= 0) { fprintf(stderr, "Execute number must be greater than 0.:-)\n"); @@@ -436,7 -448,7 +449,7 @@@ break; case OPT_THREAD_NUMBER: /* --threads or -T */ - ms_setting.nthreads= atoi(optarg); + ms_setting.nthreads= (int)strtol(optarg, (char **) NULL, 10); if (ms_setting.nthreads <= 0) { fprintf(stderr, "Threads number must be greater than 0.:-)\n"); @@@ -445,7 -457,7 +458,7 @@@ break; case OPT_FIXED_LTH: /* --fixed_size or -X */ - ms_setting.fixed_value_size= (size_t)atoi(optarg); + ms_setting.fixed_value_size= (size_t)strtoull(optarg, (char **) NULL, 10); if ((ms_setting.fixed_value_size <= 0) || (ms_setting.fixed_value_size > MAX_VALUE_SIZE)) { @@@ -466,7 -478,7 +479,7 @@@ break; case OPT_GETS_DIVISION: /* --division or -d */ - ms_setting.mult_key_num= atoi(optarg); + ms_setting.mult_key_num= (int)strtol(optarg, (char **) NULL, 10); if (ms_setting.mult_key_num <= 0) { fprintf(stderr, "Multi-get key number must be greater than 0.:-)\n"); @@@ -552,7 -564,7 +565,7 @@@ break; case OPT_SOCK_PER_CONN: /* --conn_sock or -n */ - ms_setting.sock_per_conn= atoi(optarg); + ms_setting.sock_per_conn= (int)strtol(optarg, (char **) NULL, 10); if (ms_setting.sock_per_conn <= 0) { fprintf(stderr, "Number of socks of each concurrency " @@@ -589,7 -601,7 +602,7 @@@ break; case OPT_REP_WRITE_SRV: /* --rep_write or -p */ - ms_setting.rep_write_srv= atoi(optarg); + ms_setting.rep_write_srv= (int)strtol(optarg, (char **) NULL, 10); if (ms_setting.rep_write_srv <= 0) { fprintf(stderr, @@@ -614,17 -626,8 +627,17 @@@ 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) @@@ -791,8 -794,8 +804,8 @@@ static void ms_monitor_slap_mode( second++; if ((ms_setting.stat_freq > 0) && (second % ms_setting.stat_freq == 0) - && ((int32_t)ms_stats.active_conns >= ms_setting.nconns) - && (ms_stats.active_conns <= (uint32_t)INT_MAX)) + && (ms_stats.active_conns >= ms_setting.nconns) + && (ms_stats.active_conns <= INT_MAX)) { ms_print_statistics(second); } diff --combined clients/ms_memslap.h index 0b9cc29e,87caca5d..8777c5bb --- a/clients/ms_memslap.h +++ b/clients/ms_memslap.h @@@ -19,7 -19,9 +19,9 @@@ #include #include #include - #include + #if !defined(__cplusplus) + # include + #endif #include #include "ms_stats.h" @@@ -69,7 -71,7 +71,7 @@@ typedef struct statisti /* global status statistic structure */ typedef struct stats { - volatile uint32_t active_conns; /* active connections */ + volatile int32_t active_conns; /* active connections */ size_t bytes_read; /* read bytes */ size_t bytes_written; /* written bytes */ size_t obj_bytes; /* object bytes */