memcached_return pre_binary(memcached_st *memc)
{
- memcached_return rc;
-
- rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
- assert(rc == MEMCACHED_SUCCESS);
+ memcached_return rc= MEMCACHED_FAILURE;
+ memcached_st *clone;
- assert(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1);
+ clone= memcached_clone(NULL, memc);
+ assert(clone);
+ // The memcached_version needs to be done on a clone, because the server
+ // will not toggle protocol on an connection.
+ memcached_version(clone);
- return MEMCACHED_SUCCESS;
+ if (clone->hosts[0].major_version >= 1 && clone->hosts[0].minor_version > 2)
+ {
+ rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
+ assert(rc == MEMCACHED_SUCCESS);
+ assert(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1);
+ }
+ memcached_free(clone);
+ return rc;
}
+
void my_free(memcached_st *ptr, void *mem)
{
free(mem);
collection_st collection[] ={
{"block", 0, 0, tests},
-// {"binary", pre_binary, 0, tests},
+ {"binary", pre_binary, 0, tests},
{"nonblock", pre_nonblock, 0, tests},
{"nodelay", pre_nodelay, 0, tests},
{"settimer", pre_settimer, 0, tests},