projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Added the ability to get the local port of a memcache_instance_st.
[awesomized/libmemcached]
/
libmemcached
/
hosts.cc
diff --git
a/libmemcached/hosts.cc
b/libmemcached/hosts.cc
index 20677694ff4db491feaa8e821e7dc30c733f06df..75bfbee696875e6c22a7f74756d4a9e3005f3cca 100644
(file)
--- a/
libmemcached/hosts.cc
+++ b/
libmemcached/hosts.cc
@@
-46,10
+46,10
@@
static memcached_return_t update_continuum(Memcached *ptr);
static int compare_servers(const void *p1, const void *p2)
{
static int compare_servers(const void *p1, const void *p2)
{
-
memcached_server_instance_st a= (memcached_server_instance_st
)p1;
-
memcached_server_instance_st b= (memcached_server_instance_st
)p2;
+
const memcached_instance_st * a= (const memcached_instance_st *
)p1;
+
const memcached_instance_st * b= (const memcached_instance_st *
)p2;
- int return_value= strcmp(a->
hostname, b->
hostname);
+ int return_value= strcmp(a->
_hostname, b->_
hostname);
if (return_value == 0)
{
if (return_value == 0)
{
@@
-63,7
+63,7
@@
static void sort_hosts(Memcached *ptr)
{
if (memcached_server_count(ptr))
{
{
if (memcached_server_count(ptr))
{
- qsort(memcached_instance_list(ptr), memcached_server_count(ptr), sizeof(
org::libmemcached::Instance
), compare_servers);
+ qsort(memcached_instance_list(ptr), memcached_server_count(ptr), sizeof(
memcached_instance_st
), compare_servers);
}
}
}
}
@@
-146,7
+146,7
@@
static memcached_return_t update_continuum(Memcached *ptr)
return memcached_set_errno(*ptr, errno, MEMCACHED_AT);
}
return memcached_set_errno(*ptr, errno, MEMCACHED_AT);
}
-
org::libmemcached::Instance
* list= memcached_instance_list(ptr);
+
memcached_instance_st
* list= memcached_instance_list(ptr);
/* count live servers (those without a retry delay set) */
bool is_auto_ejecting= _is_auto_eject_host(ptr);
/* count live servers (those without a retry delay set) */
bool is_auto_ejecting= _is_auto_eject_host(ptr);
@@
-224,7
+224,7
@@
static memcached_return_t update_continuum(Memcached *ptr)
if (DEBUG)
{
printf("ketama_weighted:%s|%d|%llu|%u\n",
if (DEBUG)
{
printf("ketama_weighted:%s|%d|%llu|%u\n",
- list[host_index].hostname,
+ list[host_index].
_
hostname,
list[host_index].port(),
(unsigned long long)list[host_index].weight,
pointer_per_server);
list[host_index].port(),
(unsigned long long)list[host_index].weight,
pointer_per_server);
@@
-245,7
+245,7
@@
static memcached_return_t update_continuum(Memcached *ptr)
// If hostname is not available then: /ip:port-index
sort_host_length= snprintf(sort_host, sizeof(sort_host),
"/%s:%u-%u",
// If hostname is not available then: /ip:port-index
sort_host_length= snprintf(sort_host, sizeof(sort_host),
"/%s:%u-%u",
- list[host_index].hostname,
+ list[host_index].
_
hostname,
(uint32_t)list[host_index].port(),
pointer_index);
(uint32_t)list[host_index].port(),
pointer_index);
@@
-290,14
+290,14
@@
static memcached_return_t update_continuum(Memcached *ptr)
{
sort_host_length= snprintf(sort_host, sizeof(sort_host),
"%s-%u",
{
sort_host_length= snprintf(sort_host, sizeof(sort_host),
"%s-%u",
- list[host_index].hostname,
+ list[host_index].
_
hostname,
pointer_index - 1);
}
else
{
sort_host_length= snprintf(sort_host, sizeof(sort_host),
"%s:%u-%u",
pointer_index - 1);
}
else
{
sort_host_length= snprintf(sort_host, sizeof(sort_host),
"%s:%u-%u",
- list[host_index].hostname,
+ list[host_index].
_
hostname,
(uint32_t)list[host_index].port(),
pointer_index - 1);
}
(uint32_t)list[host_index].port(),
pointer_index - 1);
}
@@
-365,7
+365,7
@@
static memcached_return_t server_add(Memcached *memc,
}
uint32_t host_list_size= memc->number_of_hosts +1;
}
uint32_t host_list_size= memc->number_of_hosts +1;
-
org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(memc, memcached_instance_list(memc), host_list_size, org::libmemcached::Instance
);
+
memcached_instance_st* new_host_list= libmemcached_xrealloc(memc, memcached_instance_list(memc), host_list_size, memcached_instance_st
);
if (new_host_list == NULL)
{
if (new_host_list == NULL)
{
@@
-376,7
+376,7
@@
static memcached_return_t server_add(Memcached *memc,
assert(memc->number_of_hosts == host_list_size);
/* TODO: Check return type */
assert(memc->number_of_hosts == host_list_size);
/* TODO: Check return type */
-
org::libmemcached::Instance
* instance= memcached_instance_fetch(memc, memcached_server_count(memc) -1);
+
memcached_instance_st
* instance= memcached_instance_fetch(memc, memcached_server_count(memc) -1);
if (__instance_create_with(memc, instance, hostname, port, weight, type) == NULL)
{
if (__instance_create_with(memc, instance, hostname, port, weight, type) == NULL)
{
@@
-409,7
+409,7
@@
memcached_return_t memcached_server_push(memcached_st *shell, const memcached_se
uint32_t count= memcached_server_list_count(list);
uint32_t host_list_size= count +original_host_size;
uint32_t count= memcached_server_list_count(list);
uint32_t host_list_size= count +original_host_size;
-
org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, org::libmemcached::Instance
);
+
memcached_instance_st* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, memcached_instance_st
);
if (new_host_list == NULL)
{
if (new_host_list == NULL)
{
@@
-424,7
+424,7
@@
memcached_return_t memcached_server_push(memcached_st *shell, const memcached_se
WATCHPOINT_ASSERT(list[x].hostname[0] != 0);
// We have extended the array, and now we will find it, and use it.
WATCHPOINT_ASSERT(list[x].hostname[0] != 0);
// We have extended the array, and now we will find it, and use it.
-
org::libmemcached::Instance
* instance= memcached_instance_fetch(ptr, original_host_size);
+
memcached_instance_st
* instance= memcached_instance_fetch(ptr, original_host_size);
WATCHPOINT_ASSERT(instance);
memcached_string_t hostname= { memcached_string_make_from_cstr(list[x].hostname) };
WATCHPOINT_ASSERT(instance);
memcached_string_t hostname= { memcached_string_make_from_cstr(list[x].hostname) };
@@
-449,7
+449,7
@@
memcached_return_t memcached_server_push(memcached_st *shell, const memcached_se
return MEMCACHED_INVALID_ARGUMENTS;
}
return MEMCACHED_INVALID_ARGUMENTS;
}
-memcached_return_t memcached_instance_push(memcached_st *ptr, const struct
org::libmemcached::Instance
* list, uint32_t number_of_hosts)
+memcached_return_t memcached_instance_push(memcached_st *ptr, const struct
memcached_instance_st
* list, uint32_t number_of_hosts)
{
if (list == NULL)
{
{
if (list == NULL)
{
@@
-458,7
+458,7
@@
memcached_return_t memcached_instance_push(memcached_st *ptr, const struct org::
uint32_t original_host_size= memcached_server_count(ptr);
uint32_t host_list_size= number_of_hosts +original_host_size;
uint32_t original_host_size= memcached_server_count(ptr);
uint32_t host_list_size= number_of_hosts +original_host_size;
-
org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, org::libmemcached::Instance
);
+
memcached_instance_st* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, memcached_instance_st
);
if (new_host_list == NULL)
{
if (new_host_list == NULL)
{
@@
-474,13
+474,13
@@
memcached_return_t memcached_instance_push(memcached_st *ptr, const struct org::
// instance allocated.
for (uint32_t x= 0; x < number_of_hosts; ++x, ++original_host_size)
{
// instance allocated.
for (uint32_t x= 0; x < number_of_hosts; ++x, ++original_host_size)
{
- WATCHPOINT_ASSERT(list[x].hostname[0] != 0);
+ WATCHPOINT_ASSERT(list[x].
_
hostname[0] != 0);
// We have extended the array, and now we will find it, and use it.
// We have extended the array, and now we will find it, and use it.
-
org::libmemcached::Instance
* instance= memcached_instance_fetch(ptr, original_host_size);
+
memcached_instance_st
* instance= memcached_instance_fetch(ptr, original_host_size);
WATCHPOINT_ASSERT(instance);
WATCHPOINT_ASSERT(instance);
- memcached_string_t hostname= { memcached_string_make_from_cstr(list[x].hostname) };
+ memcached_string_t hostname= { memcached_string_make_from_cstr(list[x].
_
hostname) };
if (__instance_create_with(ptr, instance,
hostname,
list[x].port(), list[x].weight, list[x].type) == NULL)
if (__instance_create_with(ptr, instance,
hostname,
list[x].port(), list[x].weight, list[x].type) == NULL)
@@
-591,7
+591,7
@@
memcached_return_t memcached_server_add_parsed(memcached_st *ptr,
in_port_t port,
uint32_t weight)
{
in_port_t port,
uint32_t weight)
{
- char buffer[MEMCACHED_NI_MAXHOST];
+ char buffer[MEMCACHED_NI_MAXHOST]
= { 0 }
;
memcpy(buffer, hostname, hostname_length);
buffer[hostname_length]= 0;
memcpy(buffer, hostname, hostname_length);
buffer[hostname_length]= 0;