Sign fix for variable (this should solve the solaris warning).
[m6w6/libmemcached] / clients / memslap.c
index 37e211a0dd4f2d8bb53ccf735a9319311c569cda..88a0f21ca25be9b4dde03b8d9b43613d8d368ff5 100644 (file)
  *      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,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);
     }