From 81be4de01a86e73b9222f7e92d0a6f7476029864 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Mon, 1 Oct 2007 18:49:12 -0700 Subject: [PATCH] Optimization for read(), we now optimize on buffer size. --- lib/memcached_io.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/memcached_io.c b/lib/memcached_io.c index 77df4319..8615aa6e 100644 --- a/lib/memcached_io.c +++ b/lib/memcached_io.c @@ -17,10 +17,29 @@ ssize_t memcached_io_read(memcached_st *ptr, unsigned int server_key, { if (!ptr->read_buffer_length) { - ptr->read_buffer_length= recv(ptr->hosts[server_key].fd, - ptr->read_buffer, - MEMCACHED_MAX_BUFFER, 0); - ptr->read_ptr= ptr->read_buffer; + if (length > 1) + { + + size_t data_read; + data_read= recv(ptr->hosts[server_key].fd, + buffer_ptr, + length - x, 0); + if (data_read == -1) + return -1; + if (data_read == 0) + return x; + + data_read+= x; + + return data_read; + } + else + { + ptr->read_buffer_length= recv(ptr->hosts[server_key].fd, + ptr->read_buffer, + MEMCACHED_MAX_BUFFER, 0); + ptr->read_ptr= ptr->read_buffer; + } if (ptr->read_buffer_length == -1) return -1; -- 2.30.2