projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Merge in fixes for rpm/instance lookup.
[awesomized/libmemcached]
/
libmemcached
/
server.c
diff --git
a/libmemcached/server.c
b/libmemcached/server.c
index fa750c257424b9ce98c4f24d6028f7f559caf615..4fe676b05a82691493c326f61ed4962bb83e9cea 100644
(file)
--- a/
libmemcached/server.c
+++ b/
libmemcached/server.c
@@
-19,6
+19,7
@@
static inline void _server_init(memcached_server_st *self, const memcached_st *r
uint32_t weight, memcached_connection_t type)
{
self->options.is_shutting_down= false;
uint32_t weight, memcached_connection_t type)
{
self->options.is_shutting_down= false;
+ self->options.is_dead= false;
self->number_of_hosts= 0;
self->cursor_active= 0;
self->port= port;
self->number_of_hosts= 0;
self->cursor_active= 0;
self->port= port;
@@
-27,8
+28,6
@@
static inline void _server_init(memcached_server_st *self, const memcached_st *r
self->io_bytes_sent= 0;
self->server_failure_counter= 0;
self->weight= weight ? weight : 1; // 1 is the default weight value
self->io_bytes_sent= 0;
self->server_failure_counter= 0;
self->weight= weight ? weight : 1; // 1 is the default weight value
- self->state.is_corked= false;
- self->state.is_dead= false;
WATCHPOINT_SET(self->io_wait_count.read= 0);
WATCHPOINT_SET(self->io_wait_count.write= 0);
self->major_version= UINT8_MAX;
WATCHPOINT_SET(self->io_wait_count.read= 0);
WATCHPOINT_SET(self->io_wait_count.write= 0);
self->major_version= UINT8_MAX;
@@
-52,12
+51,21
@@
static inline void _server_init(memcached_server_st *self, const memcached_st *r
self->next_retry= 0;
}
self->next_retry= 0;
}
+ if (self->weight > 1 && root)
+ {
+ ((memcached_st *)root)->ketama.weighted= true;
+ }
+
self->root= root;
self->limit_maxbytes= 0;
if (hostname == NULL)
self->root= root;
self->limit_maxbytes= 0;
if (hostname == NULL)
+ {
self->hostname[0]= 0;
self->hostname[0]= 0;
+ }
else
else
+ {
strncpy(self->hostname, hostname, NI_MAXHOST - 1);
strncpy(self->hostname, hostname, NI_MAXHOST - 1);
+ }
}
static memcached_server_st *_server_create(memcached_server_st *self, const memcached_st *memc)
}
static memcached_server_st *_server_create(memcached_server_st *self, const memcached_st *memc)
@@
-160,6
+168,12
@@
memcached_return_t memcached_server_cursor(const memcached_st *ptr,
void *context,
uint32_t number_of_callbacks)
{
void *context,
uint32_t number_of_callbacks)
{
+ memcached_return_t rc;
+ if ((rc= initialize_const_query(ptr)) != MEMCACHED_SUCCESS)
+ {
+ return rc;
+ }
+
for (uint32_t x= 0; x < memcached_server_count(ptr); x++)
{
memcached_server_instance_st instance=
for (uint32_t x= 0; x < memcached_server_count(ptr); x++)
{
memcached_server_instance_st instance=
@@
-207,14
+221,20
@@
memcached_server_instance_st memcached_server_by_key(const memcached_st *ptr,
uint32_t server_key;
memcached_server_instance_st instance;
uint32_t server_key;
memcached_server_instance_st instance;
- *error= memcached_validate_key_length(key_length,
- ptr->flags.binary_protocol);
- unlikely (*error != MEMCACHED_SUCCESS)
+ memcached_return_t rc;
+ if ((rc= initialize_const_query(ptr)) != MEMCACHED_SUCCESS)
+ {
+ if (error)
+ *error= rc;
+
return NULL;
return NULL;
+ }
-
unlikely (memcached_server_count(ptr) == 0
)
+
if ((rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol)) != MEMCACHED_SUCCESS
)
{
{
- *error= MEMCACHED_NO_SERVERS;
+ if (error)
+ *error= rc;
+
return NULL;
}
return NULL;
}
@@
-231,14
+251,22
@@
memcached_server_instance_st memcached_server_by_key(const memcached_st *ptr,
}
}
-void memcached_server_error_reset(memcached_server_st *
ptr
)
+void memcached_server_error_reset(memcached_server_st *
self
)
{
{
- ptr->cached_server_error[0]= 0;
+ WATCHPOINT_ASSERT(self);
+ if (! self)
+ return;
+
+ self->cached_server_error[0]= 0;
}
}
-memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *
ptr
)
+memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *
self
)
{
{
- return ptr->last_disconnected_server;
+ WATCHPOINT_ASSERT(self);
+ if (! self)
+ return 0;
+
+ return self->last_disconnected_server;
}
void memcached_server_list_free(memcached_server_list_st self)
}
void memcached_server_list_free(memcached_server_list_st self)
@@
-246,8
+274,6
@@
void memcached_server_list_free(memcached_server_list_st self)
if (self == NULL)
return;
if (self == NULL)
return;
- const memcached_st *root= self->root;
-
for (uint32_t x= 0; x < memcached_server_list_count(self); x++)
{
if (self[x].address_info)
for (uint32_t x= 0; x < memcached_server_list_count(self); x++)
{
if (self[x].address_info)
@@
-257,6
+283,7
@@
void memcached_server_list_free(memcached_server_list_st self)
}
}
}
}
+ const memcached_st *root= self->root;
if (root)
{
libmemcached_free(root, self);
if (root)
{
libmemcached_free(root, self);
@@
-269,26
+296,46
@@
void memcached_server_list_free(memcached_server_list_st self)
uint32_t memcached_servers_set_count(memcached_server_st *servers, uint32_t count)
{
uint32_t memcached_servers_set_count(memcached_server_st *servers, uint32_t count)
{
+ WATCHPOINT_ASSERT(servers);
+ if (! servers)
+ return 0;
+
return servers->number_of_hosts= count;
}
uint32_t memcached_server_count(const memcached_st *self)
{
return servers->number_of_hosts= count;
}
uint32_t memcached_server_count(const memcached_st *self)
{
+ WATCHPOINT_ASSERT(self);
+ if (! self)
+ return 0;
+
return self->number_of_hosts;
}
const char *memcached_server_name(memcached_server_instance_st self)
{
return self->number_of_hosts;
}
const char *memcached_server_name(memcached_server_instance_st self)
{
+ WATCHPOINT_ASSERT(self);
+ if (! self)
+ return NULL;
+
return self->hostname;
}
in_port_t memcached_server_port(memcached_server_instance_st self)
{
return self->hostname;
}
in_port_t memcached_server_port(memcached_server_instance_st self)
{
+ WATCHPOINT_ASSERT(self);
+ if (! self)
+ return 0;
+
return self->port;
}
uint32_t memcached_server_response_count(memcached_server_instance_st self)
{
return self->port;
}
uint32_t memcached_server_response_count(memcached_server_instance_st self)
{
+ WATCHPOINT_ASSERT(self);
+ if (! self)
+ return 0;
+
return self->cursor_active;
}
return self->cursor_active;
}