projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Added MEMCACHED_BEHAVIOR_CACHE_LOOKUPS flag (you can now avoid multiple DNS
[m6w6/libmemcached]
/
lib
/
memcached_get.c
diff --git
a/lib/memcached_get.c
b/lib/memcached_get.c
index cbe94926ba0f169d2b27e00bed9facb64f01e10f..db626f6fa07eefc54b9159c64adc51f05abb5e64 100644
(file)
--- a/
lib/memcached_get.c
+++ b/
lib/memcached_get.c
@@
-12,7
+12,6
@@
static memcached_return memcached_value_fetch(memcached_st *ptr, char *key, size
char *string_ptr;
char *end_ptr;
char *string_ptr;
char *end_ptr;
- memset(buffer, 0, MEMCACHED_DEFAULT_COMMAND_SIZE);
end_ptr= buffer + MEMCACHED_DEFAULT_COMMAND_SIZE;
*flags= 0;
end_ptr= buffer + MEMCACHED_DEFAULT_COMMAND_SIZE;
*flags= 0;
@@
-32,7
+31,6
@@
static memcached_return memcached_value_fetch(memcached_st *ptr, char *key, size
/* We load the key */
if (load_key)
{
/* We load the key */
if (load_key)
{
- memset(key, 0, MEMCACHED_MAX_KEY);
*key_length= 0;
for (; end_ptr > string_ptr && *string_ptr != ' '; string_ptr++)
*key_length= 0;
for (; end_ptr > string_ptr && *string_ptr != ' '; string_ptr++)
@@
-216,7
+214,6
@@
memcached_return memcached_mget(memcached_st *ptr,
{
unsigned int x;
memcached_return rc= MEMCACHED_NOTFOUND;
{
unsigned int x;
memcached_return rc= MEMCACHED_NOTFOUND;
- char *cursor_key_exec;
LIBMEMCACHED_MEMCACHED_MGET_START();
ptr->cursor_server= 0;
LIBMEMCACHED_MEMCACHED_MGET_START();
ptr->cursor_server= 0;
@@
-226,41
+223,40
@@
memcached_return memcached_mget(memcached_st *ptr,
if (ptr->number_of_hosts == 0)
return MEMCACHED_NO_SERVERS;
if (ptr->number_of_hosts == 0)
return MEMCACHED_NO_SERVERS;
- cursor_key_exec= (char *)malloc(sizeof(char) * ptr->number_of_hosts);
- memset(cursor_key_exec, 0, sizeof(char) * ptr->number_of_hosts);
-
for (x= 0; x < number_of_keys; x++)
{
unsigned int server_key;
server_key= memcached_generate_hash(ptr, keys[x], key_length[x]);
for (x= 0; x < number_of_keys; x++)
{
unsigned int server_key;
server_key= memcached_generate_hash(ptr, keys[x], key_length[x]);
- if (
cursor_key_exec[server_key]
== 0)
+ if (
ptr->hosts[server_key].cursor_active
== 0)
{
rc= memcached_connect(ptr, server_key);
if ((memcached_io_write(ptr, server_key, "get ", 4, 0)) == -1)
{
{
rc= memcached_connect(ptr, server_key);
if ((memcached_io_write(ptr, server_key, "get ", 4, 0)) == -1)
{
- memcached_quit
(ptr
);
+ memcached_quit
_server(ptr, server_key
);
rc= MEMCACHED_SOME_ERRORS;
rc= MEMCACHED_SOME_ERRORS;
-
break
;
+
continue
;
}
}
+ ptr->hosts[server_key].cursor_active= 1;
}
if ((memcached_io_write(ptr, server_key, keys[x], key_length[x], 0)) == -1)
{
}
if ((memcached_io_write(ptr, server_key, keys[x], key_length[x], 0)) == -1)
{
- memcached_quit(ptr);
+ ptr->hosts[server_key].cursor_active = 0;
+ memcached_quit_server(ptr, server_key);
rc= MEMCACHED_SOME_ERRORS;
rc= MEMCACHED_SOME_ERRORS;
-
break
;
+
continue
;
}
if ((memcached_io_write(ptr, server_key, " ", 1, 0)) == -1)
{
}
if ((memcached_io_write(ptr, server_key, " ", 1, 0)) == -1)
{
- memcached_quit(ptr);
+ ptr->hosts[server_key].cursor_active = 0;
+ memcached_quit_server(ptr, server_key);
rc= MEMCACHED_SOME_ERRORS;
rc= MEMCACHED_SOME_ERRORS;
-
break
;
+
continue
;
}
}
- cursor_key_exec[server_key]= 1;
}
}
@@
-269,24
+265,17
@@
memcached_return memcached_mget(memcached_st *ptr,
*/
for (x= 0; x < ptr->number_of_hosts; x++)
{
*/
for (x= 0; x < ptr->number_of_hosts; x++)
{
- if (
cursor_key_exec[x]
)
+ if (
ptr->hosts[x].cursor_active == 1
)
{
/* We need to doo something about non-connnected hosts in the future */
if ((memcached_io_write(ptr, x, "\r\n", 2, 1)) == -1)
{
{
/* We need to doo something about non-connnected hosts in the future */
if ((memcached_io_write(ptr, x, "\r\n", 2, 1)) == -1)
{
- memcached_quit
(ptr
);
+ memcached_quit
_server(ptr, x
);
rc= MEMCACHED_SOME_ERRORS;
rc= MEMCACHED_SOME_ERRORS;
- break;
}
}
-
- ptr->hosts[x].cursor_active= 1;
}
}
- else
- ptr->hosts[x].cursor_active= 0;
}
}
- free(cursor_key_exec);
-
LIBMEMCACHED_MEMCACHED_MGET_END();
return rc;
}
LIBMEMCACHED_MEMCACHED_MGET_END();
return rc;
}
@@
-312,18
+301,28
@@
char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length,
*value_length= memcached_string_length(result_buffer);
if (*error == MEMCACHED_NOTFOUND)
*value_length= memcached_string_length(result_buffer);
if (*error == MEMCACHED_NOTFOUND)
+ {
+ ptr->hosts[ptr->cursor_server].cursor_active = 0;
ptr->cursor_server++;
ptr->cursor_server++;
+ }
else if (*error == MEMCACHED_END && *value_length == 0)
else if (*error == MEMCACHED_END && *value_length == 0)
+ {
return NULL;
return NULL;
+ }
else if (*error == MEMCACHED_END)
{
WATCHPOINT_ASSERT(0); /* If this happens we have somehow messed up the fetch */
else if (*error == MEMCACHED_END)
{
WATCHPOINT_ASSERT(0); /* If this happens we have somehow messed up the fetch */
+ *value_length= 0;
return NULL;
}
else if (*error != MEMCACHED_SUCCESS)
return NULL;
}
else if (*error != MEMCACHED_SUCCESS)
+ {
return NULL;
return NULL;
+ }
else
else
+ {
return memcached_string_c_copy(result_buffer);
return memcached_string_c_copy(result_buffer);
+ }
}
}
@@
-352,18
+351,27
@@
memcached_result_st *memcached_fetch_result(memcached_st *ptr,
1, ptr->cursor_server);
if (*error == MEMCACHED_NOTFOUND)
1, ptr->cursor_server);
if (*error == MEMCACHED_NOTFOUND)
+ {
+ ptr->hosts[ptr->cursor_server].cursor_active = 0;
ptr->cursor_server++;
ptr->cursor_server++;
+ }
else if (*error == MEMCACHED_END && memcached_string_length((memcached_string_st *)(&result->value)) == 0)
else if (*error == MEMCACHED_END && memcached_string_length((memcached_string_st *)(&result->value)) == 0)
+ {
return NULL;
return NULL;
+ }
else if (*error == MEMCACHED_END)
{
WATCHPOINT_ASSERT(0); /* If this happens we have somehow messed up the fetch */
return NULL;
}
else if (*error != MEMCACHED_SUCCESS)
else if (*error == MEMCACHED_END)
{
WATCHPOINT_ASSERT(0); /* If this happens we have somehow messed up the fetch */
return NULL;
}
else if (*error != MEMCACHED_SUCCESS)
+ {
return NULL;
return NULL;
+ }
else
else
+ {
return result;
return result;
+ }
}
}