Merge Monty
authorBrian Aker <brian@gaz>
Thu, 14 Jan 2010 05:18:46 +0000 (21:18 -0800)
committerBrian Aker <brian@gaz>
Thu, 14 Jan 2010 05:18:46 +0000 (21:18 -0800)
1  2 
clients/memslap.c
clients/ms_memslap.h

diff --combined clients/memslap.c
index 804d8b7b8981031954be4aaaaba2be2158e64252,11b4df8735ffe0f50a49522552fbaf1f9c04efd1..efda8affae122722bb2f5aae61db84ad7d31488d
   *      Mingqiang Zhuang <mingqiangzhuang@hengtiansoft.com>
   *
   */
+ #include "config.h"
  #include <stdlib.h>
  #include <getopt.h>
  #include <limits.h>
+ #if TIME_WITH_SYS_TIME
+ # include <sys/time.h>
+ # include <time.h>
+ #else
+ # if HAVE_SYS_TIME_H
+ #  include <sys/time.h>
+ # else
+ #  include <time.h>
+ # 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");
        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");
        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");
        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))
        {
        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");
        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 "
        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 0b9cc29e2cea1d65a8ebd32e4ab845429c62a305,87caca5dc1408ba422c5fec17c7e09ee1520dddd..8777c5bb2466a14419a37b5e6be47699c926adb4
@@@ -19,7 -19,9 +19,9 @@@
  #include <unistd.h>
  #include <stdint.h>
  #include <pthread.h>
- #include <stdbool.h>
+ #if !defined(__cplusplus)
+ # include <stdbool.h>
+ #endif
  #include <math.h>
  
  #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 */