Cleanup from memaslap
[awesomized/libmemcached] / clients / memslap.c
index aff2de1ba6b95bec7e0a8cafdada969e935e28a3..0d77fd6e172be763f923752a1dc5b243e348c360 100644 (file)
@@ -1,4 +1,42 @@
-#include "libmemcached/common.h"
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ * 
+ *  Libmemcached library
+ *
+ *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2006-2009 Brian Aker All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -131,7 +169,6 @@ int main(int argc, char *argv[])
 
 void scheduler(memcached_server_st *servers, conclusions_st *conclusion)
 {
-  unsigned int x;
   unsigned int actual_loaded= 0; /* Fix warning */
   memcached_st *memc;
 
@@ -151,8 +188,10 @@ void scheduler(memcached_server_st *servers, conclusions_st *conclusion)
   {
     memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP,
                            (uint64_t)opt_udp_io);
-    for(x= 0; x < servers[0].count; x++ )
+    for (uint32_t x= 0; x < memcached_server_list_count(servers); x++ )
+    {
       servers[x].type= MEMCACHED_CONNECTION_UDP;
+    }
   }
   memcached_server_push(memc, servers);
 
@@ -173,8 +212,10 @@ void scheduler(memcached_server_st *servers, conclusions_st *conclusion)
     free(key_lengths);
     keys= NULL;
     key_lengths= NULL;
-  } else {
-    for (x= 0; x < actual_loaded; ++x)
+  }
+  else
+  {
+    for (uint32_t x= 0; x < actual_loaded; ++x)
     {
       keys[x]= pairs[x].key;
       key_lengths[x]= pairs[x].key_length;
@@ -196,7 +237,7 @@ void scheduler(memcached_server_st *servers, conclusions_st *conclusion)
   master_wakeup= 1;
   pthread_mutex_unlock(&sleeper_mutex);
 
-  for (x= 0; x < opt_concurrency; x++)
+  for (uint32_t x= 0; x < opt_concurrency; x++)
   {
     thread_context_st *context;
     context= (thread_context_st *)calloc(1, sizeof(thread_context_st));