Example #1
0
static inline bool _memcached_init(memcached_st *self)
{
  self->state= global_copy.state;
  self->flags= global_copy.flags;

  self->distribution= MEMCACHED_DISTRIBUTION_MODULA;

  hashkit_st *hash_ptr;
  hash_ptr= hashkit_create(&self->hashkit);
  if (! hash_ptr)
    return false;

  self->continuum_points_counter= 0;

  self->number_of_hosts= 0;
  self->servers= NULL;
  self->last_disconnected_server= NULL;

  self->snd_timeout= 0;
  self->rcv_timeout= 0;
  self->server_failure_limit= 0;

  /* TODO, Document why we picked these defaults */
  self->io_msg_watermark= 500;
  self->io_bytes_watermark= 65 * 1024;

  self->io_key_prefetch= 0;
  self->cached_errno= 0;
  self->poll_timeout= MEMCACHED_DEFAULT_TIMEOUT;
  self->connect_timeout= MEMCACHED_DEFAULT_TIMEOUT;
  self->retry_timeout= 0;
  self->continuum_count= 0;

  self->send_size= -1;
  self->recv_size= -1;

  self->user_data= NULL;
  self->next_distribution_rebuild= 0;
  self->prefix_key_length= 0;
  self->number_of_replicas= 0;
  hash_ptr= hashkit_create(&self->distribution_hashkit);
  if (! hash_ptr)
    return false;
  self->continuum= NULL;

  self->allocators= memcached_allocators_return_default();

  self->on_clone= NULL;
  self->on_cleanup= NULL;
  self->get_key_failure= NULL;
  self->delete_trigger= NULL;
  self->callbacks= NULL;

  return true;
}
Example #2
0
static test_return_t allocation_test(void *not_used)
{
  hashkit_st *hashk_ptr;
  (void)not_used;

  hashk_ptr= hashkit_create(NULL);
  test_true(hashk_ptr);
  test_true(hashkit_is_allocated(hashk_ptr) == true);
  hashkit_free(hashk_ptr);

  return TEST_SUCCESS;
}
Example #3
0
static test_return_t init_test(void *not_used)
{
  hashkit_st hashk;
  hashkit_st *hashk_ptr;
  (void)not_used;

  hashk_ptr= hashkit_create(&hashk);
  test_true(hashk_ptr);
  test_true(hashk_ptr == &hashk);
  test_true(hashkit_is_allocated(hashk_ptr) == false);

  hashkit_free(hashk_ptr);

  return TEST_SUCCESS;
}
Example #4
0
void *world_create(test_return_t *error)
{
  hashkit_st *hashk_ptr;

  hashk_ptr= hashkit_create(&global_hashk);

  if (hashk_ptr != &global_hashk)
  {
    *error= TEST_FAILURE;
    return NULL;
  }

  if (hashkit_is_allocated(hashk_ptr) == true)
  {
    *error= TEST_FAILURE;
    return NULL;
  }

  *error= TEST_SUCCESS;

  return hashk_ptr;
}
Example #5
0
 Hashkit()
 {
     hashkit_create(&self);
 }