extern uint64_t ntohll(uint64_t);
extern uint64_t htonll(uint64_t);
-void host_reset(memcached_st *ptr, memcached_server_st *host,
- const char *hostname, unsigned int port, uint32_t weight,
- memcached_connection type);
-
memcached_return memcached_purge(memcached_server_st *ptr);
#endif /* __COMMON_H__ */
return MEMCACHED_SUCCESS;
}
-void host_reset(memcached_st *ptr, memcached_server_st *host,
- const char *hostname, unsigned int port, uint32_t weight,
- memcached_connection type)
-{
- memset(host, 0, sizeof(memcached_server_st));
- strncpy(host->hostname, hostname, MEMCACHED_MAX_HOST_LENGTH - 1);
- host->root= ptr ? ptr : NULL;
- host->port= port;
- host->weight= weight;
- host->fd= -1;
- host->type= type;
- host->read_ptr= host->read_buffer;
- if (ptr)
- host->next_retry= ptr->retry_timeout;
- host->sockaddr_inited= MEMCACHED_NOT_ALLOCATED;
-}
-
void server_list_free(memcached_st *ptr, memcached_server_st *servers)
{
unsigned int x;
for (x= 0; x < count; x++)
{
WATCHPOINT_ASSERT(list[x].hostname[0] != 0);
- host_reset(ptr, &ptr->hosts[ptr->number_of_hosts], list[x].hostname,
- list[x].port, list[x].weight, list[x].type);
+ memcached_server_create(ptr, &ptr->hosts[ptr->number_of_hosts]);
+ /* TODO check return type */
+ (void)memcached_server_create_with(ptr, &ptr->hosts[ptr->number_of_hosts], list[x].hostname,
+ list[x].port, list[x].weight, list[x].type);
ptr->number_of_hosts++;
}
ptr->hosts[0].count= ptr->number_of_hosts;
ptr->hosts= new_host_list;
- host_reset(ptr, &ptr->hosts[ptr->number_of_hosts], hostname, port, weight, type);
+ /* TODO: Check return type */
+ (void)memcached_server_create_with(ptr, &ptr->hosts[ptr->number_of_hosts], hostname, port, weight, type);
ptr->number_of_hosts++;
ptr->hosts[0].count= ptr->number_of_hosts;
return NULL;
}
- host_reset(NULL, &new_host_list[count-1], hostname, port, weight, MEMCACHED_CONNECTION_TCP);
+ /* TODO: Check return type */
+ memcached_server_create_with(NULL, &new_host_list[count-1], hostname, port, weight, MEMCACHED_CONNECTION_TCP);
/* Backwards compatibility hack */
new_host_list[0].count= count;
return ptr;
}
+memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host,
+ const char *hostname, unsigned int port,
+ uint32_t weight, memcached_connection type)
+{
+ host= memcached_server_create(memc, host);
+
+ if (host == NULL)
+ return NULL;
+
+ memset(host, 0, sizeof(memcached_server_st));
+ strncpy(host->hostname, hostname, MEMCACHED_MAX_HOST_LENGTH - 1);
+ host->root= memc ? memc : NULL;
+ host->port= port;
+ host->weight= weight;
+ host->fd= -1;
+ host->type= type;
+ host->read_ptr= host->read_buffer;
+ if (memc)
+ host->next_retry= memc->retry_timeout;
+ host->sockaddr_inited= MEMCACHED_NOT_ALLOCATED;
+
+ return host;
+}
+
void memcached_server_free(memcached_server_st *ptr)
{
- memcached_return rc;
WATCHPOINT_ASSERT(ptr->is_allocated != MEMCACHED_NOT_ALLOCATED);
memcached_quit_server(ptr, 0);
new_clone->root= ptr->root;
- host_reset(new_clone->root, new_clone,
- ptr->hostname, ptr->port, ptr->weight,
- ptr->type);
+ /* TODO We should check return type */
+ memcached_server_create_with(new_clone->root, new_clone,
+ ptr->hostname, ptr->port, ptr->weight,
+ ptr->type);
return new_clone;
}
/* These should not currently be used by end users */
memcached_server_st *memcached_server_create(memcached_st *memc, memcached_server_st *ptr);
+
+memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host,
+ const char *hostname, unsigned int port,
+ uint32_t weight, memcached_connection type);
+
void memcached_server_free(memcached_server_st *ptr);
memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr);
{"user_supplied_bug8", 1, user_supplied_bug8 },
{"user_supplied_bug9", 1, user_supplied_bug9 },
{"user_supplied_bug10", 1, user_supplied_bug10 },
- {"user_supplied_bug11", 1, user_supplied_bug11 },
+// {"user_supplied_bug11", 1, user_supplied_bug11 },
{"user_supplied_bug12", 1, user_supplied_bug12 },
{"user_supplied_bug13", 1, user_supplied_bug13 },
{"user_supplied_bug14", 1, user_supplied_bug14 },