3 #include <sys/socket.h>
4 #include <netinet/tcp.h>
7 This function is used to modify the behabior of running client.
9 We quit all connections so we can reset the sockets.
12 void set_behavior_flag(memcached_st
*ptr
, memcached_flags temp_flag
, void *data
)
14 unsigned int *truefalse
= (unsigned int *)data
;
18 ptr
->flags
|= temp_flag
;
20 ptr
->flags
+= temp_flag
;
23 memcached_return
memcached_behavior_set(memcached_st
*ptr
,
24 memcached_behavior flag
,
29 case MEMCACHED_BEHAVIOR_NO_BLOCK
:
30 set_behavior_flag(ptr
, MEM_NO_BLOCK
, data
);
32 case MEMCACHED_BEHAVIOR_TCP_NODELAY
:
33 set_behavior_flag(ptr
, MEM_TCP_NODELAY
, data
);
35 case MEMCACHED_BEHAVIOR_MD5_HASHING
:
36 set_behavior_flag(ptr
, MEM_USE_MD5
, data
);
38 case MEMCACHED_BEHAVIOR_KETAMA
:
39 set_behavior_flag(ptr
, MEM_USE_KETAMA
, data
);
43 return MEMCACHED_SUCCESS
;
46 unsigned long long memcached_behavior_get(memcached_st
*ptr
,
47 memcached_behavior flag
)
49 memcached_flags temp_flag
;
53 case MEMCACHED_BEHAVIOR_NO_BLOCK
:
54 temp_flag
= MEM_NO_BLOCK
;
56 case MEMCACHED_BEHAVIOR_TCP_NODELAY
:
57 temp_flag
= MEM_TCP_NODELAY
;
59 case MEMCACHED_BEHAVIOR_MD5_HASHING
:
60 temp_flag
= MEM_USE_MD5
;
62 case MEMCACHED_BEHAVIOR_KETAMA
:
63 temp_flag
= MEM_USE_KETAMA
;
67 if (ptr
->flags
& temp_flag
)
72 return MEMCACHED_SUCCESS
;