run_distribution(root);
}
- root->last_disconnected_server = ptr;
+ if (ptr->root->last_disconnected_server)
+ memcached_server_free(ptr->root->last_disconnected_server);
+ root->last_disconnected_server= memcached_server_clone(NULL, ptr);
return MEMCACHED_SERVER_MARKED_DEAD;
}
WATCHPOINT_ASSERT(0);
}
+ LIBMEMCACHED_MEMCACHED_CONNECT_END();
+
unlikely ( rc != MEMCACHED_SUCCESS)
{
- //@todo create interface around last_discontected_server
memcached_st *root= (memcached_st *)ptr->root;
- root->last_disconnected_server = ptr;
- }
- LIBMEMCACHED_MEMCACHED_CONNECT_END();
+ //@todo create interface around last_discontected_server
+ if (ptr->root->last_disconnected_server)
+ memcached_server_free(ptr->root->last_disconnected_server);
+ root->last_disconnected_server= memcached_server_clone(NULL, ptr);
+ }
return rc;
}
WATCHPOINT_ASSERT(0); /* We have added a distribution without extending the logic */
}
- ptr->last_disconnected_server = NULL;
-
return MEMCACHED_SUCCESS;
}
.state= {
.is_purging= false,
.is_processing_input= false,
+ .is_time_for_rebuild= false,
},
.flags= {
.auto_eject_hosts= false,
memcached_server_list_set(ptr, NULL);
ptr->number_of_hosts= 0;
+ if (ptr->last_disconnected_server)
+ {
+ memcached_server_free(ptr->last_disconnected_server);
+ }
ptr->last_disconnected_server= NULL;
ptr->server_failure_limit= 0;
}
memcached_server_list_free(memcached_server_list(ptr));
memcached_result_free(&ptr->result);
+ if (ptr->last_disconnected_server)
+ memcached_server_free(ptr->last_disconnected_server);
+
if (ptr->on_cleanup)
ptr->on_cleanup(ptr);
struct {
bool is_purging:1;
bool is_processing_input:1;
+ bool is_time_for_rebuild:1;
} state;
struct {
// Everything below here is pretty static.
self->server_failure_counter= 0;
self->weight= weight;
self->state.is_corked= false;
+ self->state.is_dead= false;
self->major_version= 0;
self->micro_version= 0;
self->minor_version= 0;
uint32_t server_failure_counter;
uint32_t weight;
struct { // Place any "state" sort variables in here.
- bool is_corked;
+ bool is_corked:1;
+ bool is_dead:1;
} state;
uint8_t major_version;
uint8_t micro_version;
return TEST_SUCCESS;
}
+static test_return_t test_cull_servers(memcached_st *memc)
+{
+ uint32_t count = memcached_server_count(memc);
+
+ // Do not do this in your code, it is not supported.
+ memc->servers[1].state.is_dead= true;
+ memc->state.is_time_for_rebuild= true;
+
+ uint32_t new_count= memcached_server_count(memc);
+ test_true(count == new_count);
+
+#if 0
+ test_true(count == new_count + 1 );
+#endif
+
+ return TEST_SUCCESS;
+}
+
/*
* This test ensures that the failure counter isn't incremented during
* normal termination of the memcached instance.
#endif
{"test_get_last_disconnect", 1, (test_callback_fn)test_get_last_disconnect},
{"verbosity", 1, (test_callback_fn)test_verbosity},
+ {"cull_servers", 1, (test_callback_fn)test_cull_servers},
{0, 0, 0}
};