Kevin Dalley's patch for EOF
authorBrian Aker <brian@tangent.org>
Tue, 8 Jan 2008 20:00:21 +0000 (12:00 -0800)
committerBrian Aker <brian@tangent.org>
Tue, 8 Jan 2008 20:00:21 +0000 (12:00 -0800)
lib/memcached_io.c

index 05974ed5c5622637f99fbae2933ac0f488f6946f..299d4390659616b21ebd8a4b4b050dc6df7603ca 100644 (file)
@@ -83,6 +83,7 @@ ssize_t memcached_io_read(memcached_st *ptr, unsigned  int server_key,
 
   while (length)
   {
+    uint8_t found_eof= 0;
     if (!ptr->hosts[server_key].read_buffer_length)
     {
       size_t data_read;
@@ -120,7 +121,11 @@ ssize_t memcached_io_read(memcached_st *ptr, unsigned  int server_key,
           break;
         /* If zero, just keep looping unless testing, then assert() */
         else
+        {
           WATCHPOINT_ASSERT(0);
+          found_eof= 1;
+          break;
+        }
       }
 
       ptr->hosts[server_key].read_data_length= data_read;
@@ -148,6 +153,9 @@ ssize_t memcached_io_read(memcached_st *ptr, unsigned  int server_key,
       ptr->hosts[server_key].read_buffer_length--;
       buffer_ptr++;
     }
+
+    if (found_eof)
+      break;
   }
 
   return (size_t)(buffer_ptr - buffer);