#include "common.h"
+#include "memcached_io.h"
static char *memcached_value_fetch(memcached_st *ptr, char *key, size_t *key_length,
size_t *value_length,
if (load_key)
{
memset(key, 0, MEMCACHED_MAX_KEY);
+ *key_length= 0;
+
for (; end_ptr == string_ptr || *string_ptr != ' '; string_ptr++)
{
*key= *string_ptr;
key++;
+ (*key_length)++;
}
}
else /* Skip characters */
if (*value_length)
{
size_t read_length;
- size_t partial_length;
size_t to_read;
char *value;
char *value_ptr;
value_ptr= value;
read_length= 0;
to_read= (*value_length) + 2;
- /* This is overkill */
- while ((partial_length= recv(ptr->hosts[server_key].fd, value_ptr, to_read, 0)) > 0)
- {
- value_ptr+= partial_length;
- read_length+= partial_length;
- to_read-= partial_length;
- if (read_length == (size_t)(*value_length + 2))
- break;
- }
+
+ read_length= memcached_io_read(ptr, server_key,
+ value_ptr, to_read);
if (read_length != (size_t)(*value_length + 2))
{
send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, "get %.*s\r\n",
(int)key_length, key);
- if ((send(ptr->hosts[server_key].fd, buffer, send_length, 0) == -1))
+
+ if ((memcached_io_write(ptr, server_key, buffer, send_length, 1)) == -1)
{
*error= MEMCACHED_WRITE_FAILURE;
goto error;
}
else
{
- memcached_string_st *string= memcached_string_init(ptr, SMALL_STRING_LEN);
+ memcached_string_st *string= memcached_string_create(ptr, SMALL_STRING_LEN);
/* We need to figure out the correct way to error in case of this failure */
if (!string)
memcached_string_st *string= cursor_key_exec[x];
memcached_string_append(ptr, string, "\r\n", 2);
- if ((send(ptr->hosts[x].fd, string->string,
- memcached_string_length(ptr, string), 0) == -1))
+ if ((memcached_io_write(ptr, x, string->string,
+ memcached_string_length(ptr, string), 1)) == -1)
{
memcached_quit(ptr);
rc= MEMCACHED_SOME_ERRORS;