Adding new memcached_clone() function
[m6w6/libmemcached] / lib / memcached_get.c
index 8b85fb9a22f40f1bca340a982c57015f51e9fb3c..80b9de378327935e648d4dbd9580beb98a490e53 100644 (file)
@@ -125,6 +125,9 @@ read_error:
   return NULL;
 }
 
+/* 
+  What happens if no servers exist?
+*/
 char *memcached_get(memcached_st *ptr, char *key, size_t key_length, 
                     size_t *value_length, 
                     uint16_t *flags,
@@ -133,7 +136,7 @@ char *memcached_get(memcached_st *ptr, char *key, size_t key_length,
   char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
   char *buf_ptr= buffer;
   unsigned int server_key;
-  char *value;
+  char *value= NULL;
   LIBMEMCACHED_MEMCACHED_GET_START();
 
   server_key= memcached_generate_hash(ptr, key, key_length);
@@ -165,7 +168,9 @@ char *memcached_get(memcached_st *ptr, char *key, size_t key_length,
     goto error;
   }
   else if (*error == MEMCACHED_END)
-    assert(0); /* If this happens we have somehow messed up the fetch */
+  {
+    WATCHPOINT_ASSERT(0); /* If this happens we have somehow messed up the fetch */
+  }
   else if (*error == MEMCACHED_SUCCESS)
   {
     memcached_return rc;
@@ -198,19 +203,18 @@ memcached_return memcached_mget(memcached_st *ptr,
                                 char **keys, size_t *key_length, 
                                 unsigned int number_of_keys)
 {
-  char buffer[HUGE_STRING_LEN];
   unsigned int x;
-  memcached_return rc;
+  memcached_return rc= MEMCACHED_NOTFOUND;
   char *cursor_key_exec;
   LIBMEMCACHED_MEMCACHED_MGET_START();
-
   ptr->cursor_server= 0;
-  memset(buffer, 0, HUGE_STRING_LEN);
+
+  if (number_of_keys == 0)
+    return MEMCACHED_NOTFOUND;
 
   cursor_key_exec= (char *)malloc(sizeof(char) * ptr->number_of_hosts);
   memset(cursor_key_exec, 0, sizeof(char) * ptr->number_of_hosts);
 
-
   for (x= 0; x < number_of_keys; x++)
   {
     unsigned int server_key;
@@ -296,7 +300,9 @@ char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length,
     else if (*error == MEMCACHED_END && *value_length == 0)
       return NULL;
     else if (*error == MEMCACHED_END)
-      assert(0); /* If this happens we have somehow messed up the fetch */
+    {
+      WATCHPOINT_ASSERT(0); /* If this happens we have somehow messed up the fetch */
+    }
     else if (*error != MEMCACHED_SUCCESS)
       return NULL;
     else