Turns out the protocol docs were in error, and that the size for 1.2 was a
[awesomized/libmemcached] / lib / memcached_fetch.c
index ac4f49112c51e7c88e1a348b1bedf49b78511452..4f6a575cb03732152427fe34f0bf72acfb54a9d5 100644 (file)
@@ -3,7 +3,7 @@
 
 static memcached_return memcached_value_fetch(memcached_st *ptr, char *key, size_t *key_length, 
                                               memcached_string_st *value,
-                                              uint16_t *flags,
+                                              uint32_t *flags,
                                               uint64_t *cas,
                                               unsigned int server_key)
 {
@@ -35,7 +35,7 @@ static memcached_return memcached_value_fetch(memcached_st *ptr, char *key, size
     {
       *key_length= 0;
 
-      for (; isalnum(*string_ptr); string_ptr++)
+      for (; isgraph(*string_ptr); string_ptr++)
       {
         *key= *string_ptr;
         key++;
@@ -43,7 +43,7 @@ static memcached_return memcached_value_fetch(memcached_st *ptr, char *key, size
       }
     }
     else /* Skip characters */
-      for (; isalnum(*string_ptr); string_ptr++);
+      for (; isgraph(*string_ptr); string_ptr++);
 
     if (end_ptr == string_ptr)
         goto read_error;
@@ -54,7 +54,7 @@ static memcached_return memcached_value_fetch(memcached_st *ptr, char *key, size
         goto read_error;
     for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++);
     if (flags)
-      *flags= (uint16_t)strtol(next_ptr, &string_ptr, 10);
+      *flags= (uint32_t)strtol(next_ptr, &string_ptr, 10);
 
     if (end_ptr == string_ptr)
         goto read_error;
@@ -141,12 +141,15 @@ read_error:
 
 char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, 
                     size_t *value_length, 
-                    uint16_t *flags,
+                    uint32_t *flags,
                     memcached_return *error)
 {
   memcached_string_st *result_buffer;
   result_buffer= &ptr->result_buffer;
 
+  if (ptr->flags & MEM_NO_BLOCK)
+    memcached_io_preread(ptr);
+
   while (ptr->cursor_server < ptr->number_of_hosts)
   {
     if (!ptr->hosts[ptr->cursor_server].cursor_active)
@@ -185,6 +188,9 @@ memcached_result_st *memcached_fetch_result(memcached_st *ptr,
 
   WATCHPOINT_ASSERT(result->value.is_allocated != MEMCACHED_USED);
 
+  if (ptr->flags & MEM_NO_BLOCK)
+    memcached_io_preread(ptr);
+
   while (ptr->cursor_server < ptr->number_of_hosts)
   {
     if (!ptr->hosts[ptr->cursor_server].cursor_active)