New version update
[m6w6/libmemcached] / libmemcached / memcached_fetch_execute.c
1 #include "common.h"
2
3 memcached_return memcached_fetch_execute(memcached_st *ptr,
4 memcached_execute_function *callback,
5 void *context,
6 unsigned int number_of_callbacks
7 )
8 {
9 memcached_result_st *result= &ptr->result;
10
11 while (ptr->cursor_server < ptr->number_of_hosts)
12 {
13 memcached_return rc;
14
15 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
16
17 if (memcached_server_response_count(&ptr->hosts[ptr->cursor_server]) == 0)
18 {
19 ptr->cursor_server++;
20 continue;
21 }
22
23 rc= memcached_response(&ptr->hosts[ptr->cursor_server], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, result);
24
25 if (rc == MEMCACHED_END) /* END means that we move on to the next */
26 {
27 memcached_server_response_reset(&ptr->hosts[ptr->cursor_server]);
28 ptr->cursor_server++;
29 continue;
30 }
31 else if (rc == MEMCACHED_SUCCESS)
32 {
33 unsigned int x;
34
35 for (x= 0; x < number_of_callbacks; x++)
36 {
37 memcached_return iferror;
38
39 iferror= (*callback[x])(ptr, result, context);
40
41 if (iferror != MEMCACHED_SUCCESS)
42 continue;
43 }
44 }
45 }
46
47 return MEMCACHED_SUCCESS;
48 }