Extend lp:655423 just to see if we can trigger it via any other method.
[m6w6/libmemcached] / tests / mem_functions.cc
index dfa1584f69cab4d8defcb65a52ac9f3dccc6c626..8d9be93e629fd273d50ab523c9e4dd06e342c31f 100644 (file)
@@ -840,25 +840,25 @@ static test_return_t bad_key_test(memcached_st *memc)
   test_compare(query_id, memcached_query_id(memc_clone)); // We should not increase the query_id for memcached_behavior_set()
 
   /* All keys are valid in the binary protocol (except for length) */
-  if (memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 0)
+  if (not memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
   {
     query_id= memcached_query_id(memc_clone);
     string= memcached_get(memc_clone, key, strlen(key),
                           &string_length, &flags, &rc);
-    test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
-    test_true(string_length ==  0);
-    test_true(!string);
+    test_compare(MEMCACHED_BAD_KEY_PROVIDED, rc);
+    test_compare(0, string_length);
+    test_false(string);
 
     set= 0;
     query_id= memcached_query_id(memc_clone);
     rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, set);
     test_compare(query_id, memcached_query_id(memc_clone)); // We should not increase the query_id for memcached_behavior_set()
-    test_true(rc == MEMCACHED_SUCCESS);
+    test_compare(MEMCACHED_SUCCESS, rc);
     string= memcached_get(memc_clone, key, strlen(key),
                           &string_length, &flags, &rc);
-    test_true(rc == MEMCACHED_NOTFOUND);
-    test_true(string_length ==  0);
-    test_true(!string);
+    test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
+    test_compare(0, string_length);
+    test_false(string);
 
     /* Test multi key for bad keys */
     const char *keys[] = { "GoodKey", "Bad Key", "NotMine" };
@@ -1014,7 +1014,7 @@ static test_return_t get_test(memcached_st *memc)
   string= memcached_get(memc, key, strlen(key),
                         &string_length, &flags, &rc);
 
-  test_true(rc == MEMCACHED_NOTFOUND);
+  test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
   test_false(string_length);
   test_false(string);
 
@@ -1023,28 +1023,29 @@ static test_return_t get_test(memcached_st *memc)
 
 static test_return_t get_test2(memcached_st *memc)
 {
-  memcached_return_t rc;
   const char *key= "foo";
   const char *value= "when we sanitize";
-  char *string;
-  size_t string_length;
-  uint32_t flags;
 
   uint64_t query_id= memcached_query_id(memc);
-  rc= memcached_set(memc, key, strlen(key),
-                    value, strlen(value),
-                    (time_t)0, (uint32_t)0);
-  test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+  memcached_return_t rc= memcached_set(memc, key, strlen(key),
+                                       value, strlen(value),
+                                       (time_t)0, (uint32_t)0);
+  test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
   test_compare(query_id +1, memcached_query_id(memc));
 
   query_id= memcached_query_id(memc);
-  string= memcached_get(memc, key, strlen(key),
-                        &string_length, &flags, &rc);
+  test_true(query_id);
+
+  uint32_t flags;
+  size_t string_length;
+  char *string= memcached_get(memc, key, strlen(key),
+                              &string_length, &flags, &rc);
   test_compare(query_id +1, memcached_query_id(memc));
 
+  test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
+  test_compare_got(MEMCACHED_SUCCESS, memcached_last_error(memc), memcached_last_error_message(memc));
   test_true(string);
-  test_true(rc == MEMCACHED_SUCCESS);
-  test_true(string_length == strlen(value));
+  test_compare(strlen(value), string_length);
   test_memcmp(string, value, string_length);
 
   free(string);
@@ -1054,18 +1055,16 @@ static test_return_t get_test2(memcached_st *memc)
 
 static test_return_t set_test2(memcached_st *memc)
 {
-  memcached_return_t rc;
   const char *key= "foo";
   const char *value= "train in the brain";
   size_t value_length= strlen(value);
-  unsigned int x;
 
-  for (x= 0; x < 10; x++)
+  for (uint32_t x= 0; x < 10; x++)
   {
-    rc= memcached_set(memc, key, strlen(key),
-                      value, value_length,
-                      (time_t)0, (uint32_t)0);
-    test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+    memcached_return_t rc= memcached_set(memc, key, strlen(key),
+                                         value, value_length,
+                                         (time_t)0, (uint32_t)0);
+    test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
   }
 
   return TEST_SUCCESS;
@@ -1073,15 +1072,15 @@ static test_return_t set_test2(memcached_st *memc)
 
 static test_return_t set_test3(memcached_st *memc)
 {
-  memcached_return_t rc;
-  char *value;
   size_t value_length= 8191;
 
-  value = (char*)malloc(value_length);
+  char *value= (char*)malloc(value_length);
   test_true(value);
 
   for (uint32_t x= 0; x < value_length; x++)
+  {
     value[x] = (char) (x % 127);
+  }
 
   /* The dump test relies on there being at least 32 items in memcached */
   for (uint32_t x= 0; x < 32; x++)
@@ -1091,9 +1090,9 @@ static test_return_t set_test3(memcached_st *memc)
     snprintf(key, sizeof(key), "foo%u", x);
 
     uint64_t query_id= memcached_query_id(memc);
-    rc= memcached_set(memc, key, strlen(key),
-                      value, value_length,
-                      (time_t)0, (uint32_t)0);
+    memcached_return_t rc= memcached_set(memc, key, strlen(key),
+                                         value, value_length,
+                                         (time_t)0, (uint32_t)0);
     test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
     test_compare(query_id +1, memcached_query_id(memc));
   }
@@ -1105,33 +1104,32 @@ static test_return_t set_test3(memcached_st *memc)
 
 static test_return_t get_test3(memcached_st *memc)
 {
-  memcached_return_t rc;
   const char *key= "foo";
-  char *value;
   size_t value_length= 8191;
-  char *string;
-  size_t string_length;
-  uint32_t flags;
-  uint32_t x;
 
-  value = (char*)malloc(value_length);
+  char *value= (char*)malloc(value_length);
   test_true(value);
 
-  for (x= 0; x < value_length; x++)
+  for (uint32_t x= 0; x < value_length; x++)
+  {
     value[x] = (char) (x % 127);
+  }
 
+  memcached_return_t rc;
   rc= memcached_set(memc, key, strlen(key),
                     value, value_length,
                     (time_t)0, (uint32_t)0);
-  test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+  test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
 
-  string= memcached_get(memc, key, strlen(key),
-                        &string_length, &flags, &rc);
+  size_t string_length;
+  uint32_t flags;
+  char *string= memcached_get(memc, key, strlen(key),
+                              &string_length, &flags, &rc);
 
-  test_true(rc == MEMCACHED_SUCCESS);
+  test_compare(MEMCACHED_SUCCESS, rc);
   test_true(string);
-  test_true(string_length == value_length);
-  test_true(!memcmp(string, value, string_length));
+  test_compare(string_length, value_length);
+  test_memcmp(string, value, string_length);
 
   free(string);
   free(value);
@@ -1692,19 +1690,19 @@ static test_return_t mget_test(memcached_st *memc)
 
   /* We need to empty the server before continueing test */
   rc= memcached_flush(memc, 0);
-  test_true(rc == MEMCACHED_SUCCESS);
+  test_compare(MEMCACHED_SUCCESS, rc);
 
   rc= memcached_mget(memc, keys, key_length, 3);
-  test_true(rc == MEMCACHED_SUCCESS);
+  test_compare(MEMCACHED_SUCCESS, rc);
 
   while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
                       &return_value_length, &flags, &rc)) != NULL)
   {
     test_true(return_value);
   }
-  test_true(!return_value);
-  test_true(return_value_length == 0);
-  test_true(rc == MEMCACHED_END);
+  test_false(return_value);
+  test_compare(0, return_value_length);
+  test_compare(MEMCACHED_END, rc);
 
   for (x= 0; x < 3; x++)
   {
@@ -1811,10 +1809,7 @@ static test_return_t mget_execute(memcached_st *memc)
 
 static test_return_t key_setup(memcached_st *memc)
 {
-  (void)memc;
-
-  if (pre_binary(memc) != TEST_SUCCESS)
-    return TEST_SKIPPED;
+  test_skip(TEST_SUCCESS, pre_binary(memc));
 
   global_pairs= pairs_generate(REGRESSION_BINARY_VS_BLOCK_COUNT, 0);
 
@@ -1883,22 +1878,17 @@ static test_return_t version_string_test(memcached_st *memc)
 
 static test_return_t get_stats(memcached_st *memc)
 {
- char **stat_list;
- char **ptr;
  memcached_return_t rc;
- memcached_stat_st *memc_stat;
-
- memc_stat= memcached_stat(memc, NULL, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
 
- test_true(rc == MEMCACHED_SUCCESS);
+ memcached_stat_st *memc_stat= memcached_stat(memc, NULL, &rc);
+ test_compare(MEMCACHED_SUCCESS, rc);
  test_true(memc_stat);
 
  for (uint32_t x= 0; x < memcached_server_count(memc); x++)
  {
-   stat_list= memcached_stat_get_keys(memc, memc_stat+x, &rc);
-   test_true(rc == MEMCACHED_SUCCESS);
-   for (ptr= stat_list; *ptr; ptr++);
+   char **stat_list= memcached_stat_get_keys(memc, memc_stat+x, &rc);
+   test_compare(MEMCACHED_SUCCESS, rc);
+   for (char **ptr= stat_list; *ptr; ptr++);
 
    free(stat_list);
  }
@@ -2591,34 +2581,34 @@ static test_return_t user_supplied_bug9(memcached_st *memc)
 static test_return_t user_supplied_bug10(memcached_st *memc)
 {
   const char *key= "foo";
-  char *value;
   size_t value_length= 512;
-  unsigned int x;
   size_t key_len= 3;
   unsigned int set= 1;
   memcached_st *mclone= memcached_clone(NULL, memc);
-  int32_t timeout;
 
   memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_NO_BLOCK, set);
   memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_TCP_NODELAY, set);
-  timeout= 2;
-  memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT,
-                         (uint64_t)timeout);
+  int32_t timeout= 0;
+  memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, (uint64_t)timeout);
 
-  value = (char*)malloc(value_length * sizeof(char));
+  char *value= (char*)malloc(value_length * sizeof(char));
 
-  for (x= 0; x < value_length; x++)
+  for (unsigned int x= 0; x < value_length; x++)
+  {
     value[x]= (char) (x % 127);
+  }
 
-  for (x= 1; x <= 100000; ++x)
+  for (unsigned int x= 1; x <= 100000; ++x)
   {
     memcached_return_t rc= memcached_set(mclone, key, key_len,value, value_length, 0, 0);
 
-    test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_WRITE_FAILURE ||
-           rc == MEMCACHED_BUFFERED || rc == MEMCACHED_TIMEOUT);
+    test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_WRITE_FAILURE or rc == MEMCACHED_BUFFERED or rc == MEMCACHED_TIMEOUT or rc == MEMCACHED_CONNECTION_FAILURE, 
+                  memcached_strerror(NULL, rc));
 
-    if (rc == MEMCACHED_WRITE_FAILURE || rc == MEMCACHED_TIMEOUT)
+    if (rc == MEMCACHED_WRITE_FAILURE or rc == MEMCACHED_TIMEOUT)
+    {
       x--;
+    }
   }
 
   free(value);
@@ -2633,33 +2623,31 @@ static test_return_t user_supplied_bug10(memcached_st *memc)
 static test_return_t user_supplied_bug11(memcached_st *memc)
 {
   const char *key= "foo";
-  char *value;
   size_t value_length= 512;
-  unsigned int x;
   size_t key_len= 3;
-  memcached_return_t rc;
   unsigned int set= 1;
-  int32_t timeout;
   memcached_st *mclone= memcached_clone(NULL, memc);
 
   memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_NO_BLOCK, set);
   memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_TCP_NODELAY, set);
-  timeout= -1;
-  memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT,
-                         (size_t)timeout);
+  int32_t timeout= -1;
+  memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, (size_t)timeout);
 
   timeout= (int32_t)memcached_behavior_get(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT);
 
   test_true(timeout == -1);
 
-  value = (char*)malloc(value_length * sizeof(char));
+  char *value= (char*)malloc(value_length * sizeof(char));
 
-  for (x= 0; x < value_length; x++)
+  for (unsigned int x= 0; x < value_length; x++)
+  {
     value[x]= (char) (x % 127);
+  }
 
-  for (x= 1; x <= 100000; ++x)
+  for (unsigned int x= 1; x <= 100000; ++x)
   {
-    rc= memcached_set(mclone, key, key_len,value, value_length, 0, 0);
+    memcached_return_t rc= memcached_set(mclone, key, key_len,value, value_length, 0, 0);
+    (void)rc;
   }
 
   free(value);
@@ -3019,9 +3007,8 @@ static test_return_t user_supplied_bug18(memcached_st *trash)
  */
 
 /* sighandler_t function that always asserts false */
-static void fail(int unused)
+static void fail(int)
 {
-  (void)unused;
   assert(0);
 }
 
@@ -3414,8 +3401,7 @@ static test_return_t get_read(memcached_st *memc)
 static test_return_t mget_read(memcached_st *memc)
 {
 
-  if (not libmemcached_util_version_check(memc, 1, 4, 4))
-    return TEST_SKIPPED;
+  test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
 
   memcached_return_t rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
 
@@ -3437,8 +3423,7 @@ static test_return_t mget_read(memcached_st *memc)
 static test_return_t mget_read_result(memcached_st *memc)
 {
 
-  if (not libmemcached_util_version_check(memc, 1, 4, 4))
-    return TEST_SKIPPED;
+  test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
 
   memcached_return_t rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
 
@@ -3463,9 +3448,7 @@ static test_return_t mget_read_result(memcached_st *memc)
 
 static test_return_t mget_read_function(memcached_st *memc)
 {
-
-  if (not libmemcached_util_version_check(memc, 1, 4, 4))
-    return TEST_SKIPPED;
+  test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
 
   memcached_return_t rc= memcached_mget(memc, global_keys, global_keys_length, global_count);
 
@@ -3733,7 +3716,7 @@ static test_return_t pre_sasl(memcached_st *memc)
 
 static test_return_t pre_replication(memcached_st *memc)
 {
-  test_true(TEST_SUCCESS == pre_binary(memc));
+  test_skip(TEST_SUCCESS, pre_binary(memc));
 
   /*
    * Make sure that we store the item on all servers
@@ -3750,7 +3733,7 @@ static test_return_t pre_replication(memcached_st *memc)
 
 static test_return_t pre_replication_noblock(memcached_st *memc)
 {
-  test_compare(TEST_SUCCESS, pre_replication(memc));
+  test_skip(TEST_SUCCESS, pre_replication(memc));
 
   return pre_nonblock(memc);
 }
@@ -4080,15 +4063,13 @@ static test_return_t pre_settimer(memcached_st *memc)
 
 static test_return_t poll_timeout(memcached_st *memc)
 {
-  size_t timeout;
-
-  timeout= 100;
+  size_t timeout= 100; // Not using, just checking that it sets
 
   memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, timeout);
 
   timeout= (size_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT);
 
-  test_true(timeout == 100);
+  test_compare(100, timeout);
 
   return TEST_SUCCESS;
 }
@@ -4771,7 +4752,6 @@ static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *memc)
 {
   (void)memc;
   memcached_st *tl_memc_h;
-  memcached_server_st *servers;
 
   const char *key= "MemcachedLives";
   size_t len;
@@ -4781,7 +4761,8 @@ static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *memc)
 
   // Create a handle.
   tl_memc_h= memcached_create(NULL);
-  servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist
+  memcached_server_st *servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist
+  test_true(servers);
   memcached_server_push(tl_memc_h, servers);
   memcached_server_list_free(servers);
 
@@ -4789,7 +4770,7 @@ static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *memc)
   value= memcached_get(tl_memc_h, key, strlen(key), &len, &flags, &rc);
 
   test_false(value);
-  test_true(len == 0);
+  test_compare(0, len);
   test_false(rc == MEMCACHED_SUCCESS);
 
   memcached_free(tl_memc_h);
@@ -5440,7 +5421,7 @@ static test_return_t test_multiple_get_last_disconnect(memcached_st *)
     {
       const char *msg=  memcached_strerror(memc, memcached_return_t(x));
       memcached_return_t ret= memcached_set(memc, msg, strlen(msg), NULL, 0, (time_t)0, (uint32_t)0);
-      test_compare_got(MEMCACHED_WRITE_FAILURE, ret, memcached_strerror(NULL, ret));
+      test_compare_got(MEMCACHED_CONNECTION_FAILURE, ret, memcached_last_error_message(memc));
 
       memcached_server_instance_st disconnected_server= memcached_server_get_last_disconnect(memc);
       test_true(disconnected_server);
@@ -5468,17 +5449,16 @@ static test_return_t test_verbosity(memcached_st *memc)
 
 static test_return_t test_server_failure(memcached_st *memc)
 {
-  memcached_st *local_memc;
   memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0);
 
-  local_memc= memcached_create(NULL);
+  memcached_st *local_memc= memcached_create(NULL);
 
   memcached_server_add(local_memc, memcached_server_name(instance), memcached_server_port(instance));
   memcached_behavior_set(local_memc, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, 2);
 
   uint32_t server_count= memcached_server_count(local_memc);
 
-  test_true(server_count == 1);
+  test_compare(1, server_count);
 
   // Disable the server
   instance= memcached_server_instance_by_position(local_memc, 0);
@@ -5488,13 +5468,13 @@ static test_return_t test_server_failure(memcached_st *memc)
   rc= memcached_set(local_memc, "foo", strlen("foo"),
                     NULL, 0,
                     (time_t)0, (uint32_t)0);
-  test_true(rc == MEMCACHED_SERVER_MARKED_DEAD);
+  test_compare_got(MEMCACHED_SERVER_MARKED_DEAD, rc, memcached_last_error_message(local_memc));
 
   ((memcached_server_write_instance_st)instance)->server_failure_counter= 0;
   rc= memcached_set(local_memc, "foo", strlen("foo"),
                     NULL, 0,
                     (time_t)0, (uint32_t)0);
-  test_true(rc == MEMCACHED_SUCCESS);
+  test_compare_got(MEMCACHED_SUCCESS, rc, memcached_last_error_message(local_memc));
 
 
   memcached_free(local_memc);
@@ -5683,47 +5663,26 @@ static test_return_t regression_bug_490486(memcached_st *memc)
   size_t *key_length= (size_t *)calloc(max_keys, sizeof(size_t));
 
   /* First add all of the items.. */
-  bool slept= false;
   char blob[1024]= { 0 };
-  memcached_return rc;
   for (size_t x= 0; x < max_keys; ++x)
   {
     char k[251];
     key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%lu", (unsigned long)x);
     keys[x]= strdup(k);
     assert(keys[x] != NULL);
-    rc= memcached_set(memc, keys[x], key_length[x], blob, sizeof(blob), 0, 0);
-#ifdef __APPLE__
-    if (rc == MEMCACHED_SERVER_MARKED_DEAD)
-    {
-      break; // We are out of business
-    }
-#endif
-    test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED || rc == MEMCACHED_TIMEOUT); // MEMCACHED_TIMEOUT <-- only observed on OSX
-
-    if (rc == MEMCACHED_TIMEOUT && slept == false)
-    {
-      x++;
-      sleep(1);// We will try to sleep
-      slept= true;
-    }
-    else if (rc == MEMCACHED_TIMEOUT && slept == true)
-    {
-      // We failed to send everything.
-      break;
-    }
+    memcached_return rc= memcached_set(memc, keys[x], key_length[x], blob, sizeof(blob), 0, 0);
+    test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); // MEMCACHED_TIMEOUT <-- hash been observed on OSX
   }
 
-  if (rc != MEMCACHED_SERVER_MARKED_DEAD)
   {
 
     /* Try to get all of them with a large multiget */
     size_t counter= 0;
     memcached_execute_function callbacks[]= { &callback_counter };
-    rc= memcached_mget_execute(memc, (const char**)keys, key_length,
-                               (size_t)max_keys, callbacks, &counter, 1);
+    memcached_return_t rc= memcached_mget_execute(memc, (const char**)keys, key_length,
+                                                  (size_t)max_keys, callbacks, &counter, 1);
+    test_compare(MEMCACHED_SUCCESS, rc);
 
-    assert(rc == MEMCACHED_SUCCESS);
     char* the_value= NULL;
     char the_key[MEMCACHED_MAX_KEY];
     size_t the_key_length;
@@ -5742,7 +5701,7 @@ static test_return_t regression_bug_490486(memcached_st *memc)
     } while ( (the_value!= NULL) && (rc == MEMCACHED_SUCCESS));
 
 
-    assert(rc == MEMCACHED_END);
+    test_compare(MEMCACHED_END, rc);
 
     /* Verify that we got all of the items */
     assert(counter == max_keys);
@@ -5782,7 +5741,7 @@ static test_return_t regression_bug_583031(memcached_st *)
   test_false(value);
   test_compare(0, length);
 
-  test_true_got(rc == MEMCACHED_TIMEOUT || rc == MEMCACHED_ERRNO || rc == MEMCACHED_FAILURE, memcached_strerror(memc, rc));
+  test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_strerror(memc, rc));
 
   memcached_free(memc);
 
@@ -5801,6 +5760,91 @@ static test_return_t regression_bug_581030(memcached_st *)
   return TEST_SUCCESS;
 }
 
+#define regression_bug_655423_COUNT 6000
+static test_return_t regression_bug_655423(memcached_st *memc)
+{
+  memcached_st *clone= memcached_clone(NULL, memc);
+  memc= NULL; // Just to make sure it is not used
+  test_true(clone);
+  char payload[100];
+
+  test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1));
+  test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_SUPPORT_CAS, 1));
+  test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1));
+  test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, 1));
+
+  memset(payload, int('x'), sizeof(payload));
+
+  for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++)
+  {
+    char key[1024];
+    snprintf(key, sizeof(key), "%u", x);
+
+    test_compare(MEMCACHED_SUCCESS, memcached_set(clone, key, strlen(key), payload, sizeof(payload), 0, 0));
+  }
+
+  for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++)
+  {
+    char key[1024];
+    snprintf(key, sizeof(key), "%u", x);
+
+    size_t value_length;
+    memcached_return_t rc;
+    char *value= memcached_get(clone, key, strlen(key), &value_length, NULL, &rc);
+
+    if (rc == MEMCACHED_NOTFOUND)
+    {
+      test_false(value);
+      test_compare(0, value_length);
+      continue;
+    }
+
+    test_compare(MEMCACHED_SUCCESS, rc);
+    test_true(value);
+    test_compare(100, value_length);
+    free(value);
+  }
+
+  char **keys= (char**)calloc(regression_bug_655423_COUNT, sizeof(char*));
+  size_t *key_length= (size_t *)calloc(regression_bug_655423_COUNT, sizeof(size_t));
+  for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++)
+  {
+    char key[1024];
+    snprintf(key, sizeof(key), "%u", x);
+
+    keys[x]= strdup(key);
+    key_length[x]= strlen(key);
+  }
+
+  memcached_return_t rc;
+  test_compare_got(MEMCACHED_SUCCESS,
+                   rc= memcached_mget(clone, (const char* const *)keys, key_length, regression_bug_655423_COUNT),
+                   memcached_strerror(NULL, rc));
+
+  uint32_t count= 0;
+  memcached_result_st *result= NULL;
+  while ((result= memcached_fetch_result(clone, result, NULL)))
+  {
+    test_compare(100, memcached_result_length(result));
+    count++;
+  }
+
+  test_true(count > 100); // If we don't get back atleast this, something is up
+
+  /* Release all allocated resources */
+  for (size_t x= 0; x < regression_bug_655423_COUNT; ++x)
+  {
+    free(keys[x]);
+  }
+  free(keys);
+  free(key_length);
+
+
+  memcached_free(clone);
+
+  return TEST_SUCCESS;
+}
+
 static void memcached_die(memcached_st* mc, memcached_return error, const char* what, uint32_t it)
 {
   fprintf(stderr, "Iteration #%u: ", it);
@@ -6139,6 +6183,9 @@ test_st regression_tests[]= {
   {"lp:?", 1, (test_callback_fn)regression_bug_ },
   {"lp:728286", 1, (test_callback_fn)regression_bug_728286 },
   {"lp:581030", 1, (test_callback_fn)regression_bug_581030 },
+  {"lp:71231153 connect()", 1, (test_callback_fn)regression_bug_71231153_connect },
+  {"lp:71231153 poll()", 1, (test_callback_fn)regression_bug_71231153_poll },
+  {"lp:655423", 1, (test_callback_fn)regression_bug_655423 },
   {0, 0, (test_callback_fn)0}
 };