projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
This is a rewrite of some of the IO code to handle larger loads of set data
[m6w6/libmemcached]
/
lib
/
memcached_response.c
diff --git
a/lib/memcached_response.c
b/lib/memcached_response.c
index 91ae3fe60870e48092bd2c1bff8f28c56c81717e..10547504743c476956ade3a7a5ebfe664f44aa4c 100644
(file)
--- a/
lib/memcached_response.c
+++ b/
lib/memcached_response.c
@@
-5,31
+5,45
@@
from an issued command.
*/
from an issued command.
*/
-#include <memcached.h>
+#include "common.h"
+#include "memcached_io.h"
memcached_return memcached_response(memcached_st *ptr,
char *buffer, size_t buffer_length,
unsigned int server_key)
{
memcached_return memcached_response(memcached_st *ptr,
char *buffer, size_t buffer_length,
unsigned int server_key)
{
+ unsigned int x;
size_t send_length;
char *buffer_ptr;
size_t send_length;
char *buffer_ptr;
+ unsigned int max_messages;
+
memset(buffer, 0, buffer_length);
send_length= 0;
memset(buffer, 0, buffer_length);
send_length= 0;
-
buffer_ptr= buffer
;
-
while (1
)
+
max_messages= memcached_server_response_count(ptr, server_key)
;
+
for (x= 0; x <= max_messages; x++
)
{
{
- unsigned int read_length;
- read_length= read(ptr->hosts[server_key].fd, buffer_ptr, 1);
+ buffer_ptr= buffer;
+
+ while (1)
+ {
+ unsigned int read_length;
- if (read_length != 1)
-
return MEMCACHED_UNKNOWN_READ_FAILURE
;
+ read_length= memcached_io_read(ptr, server_key,
+
buffer_ptr, 1)
;
- if (*buffer_ptr == '\n')
- break;
- else
- buffer_ptr++;
+ if (read_length != 1)
+ return MEMCACHED_UNKNOWN_READ_FAILURE;
+
+ if (*buffer_ptr == '\n')
+ break;
+ else
+ buffer_ptr++;
+ }
+
+ if (memcached_server_response_count(ptr, server_key))
+ memcached_server_response_decrement(ptr, server_key);
}
switch(buffer[0])
}
switch(buffer[0])
@@
-40,15
+54,17
@@
memcached_return memcached_response(memcached_st *ptr,
return MEMCACHED_SUCCESS;
case 'S': /* STORED STATS SERVER_ERROR */
{
return MEMCACHED_SUCCESS;
case 'S': /* STORED STATS SERVER_ERROR */
{
- if (buffer[
1] == 'T
') /* STORED STATS */
- return MEMCACHED_S
UCCESS
;
+ if (buffer[
2] == 'A
') /* STORED STATS */
+ return MEMCACHED_S
TAT
;
else if (buffer[1] == 'E')
return MEMCACHED_SERVER_ERROR;
else if (buffer[1] == 'E')
return MEMCACHED_SERVER_ERROR;
+ else if (buffer[1] == 'T')
+ return MEMCACHED_STORED;
else
return MEMCACHED_UNKNOWN_READ_FAILURE;
}
case 'D': /* DELETED */
else
return MEMCACHED_UNKNOWN_READ_FAILURE;
}
case 'D': /* DELETED */
- return MEMCACHED_
SUCCESS
;
+ return MEMCACHED_
DELETED
;
case 'N': /* NOT_FOUND */
{
if (buffer[4] == 'F')
case 'N': /* NOT_FOUND */
{
if (buffer[4] == 'F')
@@
-61,7
+77,7
@@
memcached_return memcached_response(memcached_st *ptr,
case 'E': /* PROTOCOL ERROR or END */
{
if (buffer[1] == 'N')
case 'E': /* PROTOCOL ERROR or END */
{
if (buffer[1] == 'N')
- return MEMCACHED_
NOTFOU
ND;
+ return MEMCACHED_
E
ND;
else if (buffer[1] == 'R')
return MEMCACHED_PROTOCOL_ERROR;
else
else if (buffer[1] == 'R')
return MEMCACHED_PROTOCOL_ERROR;
else
@@
-72,7
+88,6
@@
memcached_return memcached_response(memcached_st *ptr,
default:
return MEMCACHED_UNKNOWN_READ_FAILURE;
default:
return MEMCACHED_UNKNOWN_READ_FAILURE;
- return MEMCACHED_READ_FAILURE;
}
return MEMCACHED_SUCCESS;
}
return MEMCACHED_SUCCESS;