tests/mem_functions.cc
/*
 * The test case isn't obvious so I should probably document why
 * it works the way it does. Bug 442914 was caused by a bug
 * in the logic in memcached_purge (it did not handle the case
 * where the number of bytes sent was equal to the watermark).
 * In this test case, create messages so that we hit that case
 * and then disable noreply mode and issue a new command to
 * verify that it isn't stuck. If we change the format for the
 * delete command or the watermarks, we need to update this
 * test....
 */
The test case isn't obvious so I should probably document why
it works the way it does. Bug 442914 was caused by a bug
in the logic in memcached_purge (it did not handle the case
where the number of bytes sent was equal to the watermark).
In this test case, create messages so that we hit that case
and then disable noreply mode and issue a new command to
verify that it isn't stuck. If we change the format for the
delete command or the watermarks, we need to update this
test
The test case isn ' t obvious so I should probably document why it works the way it does . Bug 442914 was caused by a bug in the logic in memcached_purge ( it did not handle the case where the number of bytes sent was equal to the watermark ) . In this test case create messages so that we hit that case and then disable noreply mode and issue a new command to verify that it isn ' t stuck . If we change the format for the delete command or the watermarks we need to update this test
static test_return_t regression_bug_442914(memcached_st *memc)
{
  test_skip(MEMCACHED_SUCCESS,  memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1));
  memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1);
  uint32_t number_of_hosts= memcached_server_count(memc);
  memc->number_of_hosts= 1;
  char k[250];
  size_t len;
  for (uint32_t x= 0; x < 250; ++x)
  {
     len= (size_t)snprintf(k, sizeof(k), "%0250u", x);
     memcached_return_t rc= memcached_delete(memc, k, len, 0);
     test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
  }
  (void)snprintf(k, sizeof(k), "%037u", 251U);
  len= strlen(k);
  memcached_return_t rc= memcached_delete(memc, k, len, 0);
  test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
  test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0));
  test_compare(MEMCACHED_NOTFOUND, memcached_delete(memc, k, len, 0));
  memc->number_of_hosts= number_of_hosts;
  return TEST_SUCCESS;
}
static test_return_t regression_bug_442914 ( memcached_st * memc ) { test_skip ( MEMCACHED_SUCCESS , memcached_behavior_set ( memc , MEMCACHED_BEHAVIOR_NOREPLY , 1 ) ) ; memcached_behavior_set ( memc , MEMCACHED_BEHAVIOR_TCP_NODELAY , 1 ) ; uint32_t number_of_hosts = memcached_server_count ( memc ) ; memc -> number_of_hosts = 1 ; char k [ 250 ] ; size_t len ; for ( uint32_t x = 0 ; x < 250 ; ++ x ) { len = ( size_t ) snprintf ( k , sizeof ( k ) , " " , x ) ; memcached_return_t rc = memcached_delete ( memc , k , len , 0 ) ; test_true ( rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED ) ; } ( void ) snprintf ( k , sizeof ( k ) , " " , 251U ) ; len = strlen ( k ) ; memcached_return_t rc = memcached_delete ( memc , k , len , 0 ) ; test_true ( rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED ) ; test_compare ( MEMCACHED_SUCCESS , memcached_behavior_set ( memc , MEMCACHED_BEHAVIOR_NOREPLY , 0 ) ) ; test_compare ( MEMCACHED_NOTFOUND , memcached_delete ( memc , k , len , 0 ) ) ; memc -> number_of_hosts = number_of_hosts ; return TEST_SUCCESS ; }
The test case isn't obvious so I should probably document why
 it works the way it does.
The test case isn ' t obvious so I should probably document why it works the way it does .