} state;
struct {
// Everything below here is pretty static.
- bool auto_eject_hosts MEMCACHED_BITFIELD;
- bool binary_protocol MEMCACHED_BITFIELD;
- bool buffer_requests MEMCACHED_BITFIELD;
- bool cork MEMCACHED_BITFIELD;
- bool hash_with_prefix_key MEMCACHED_BITFIELD;
- bool ketama_weighted MEMCACHED_BITFIELD;
- bool no_block MEMCACHED_BITFIELD;
- bool no_reply MEMCACHED_BITFIELD;
- bool randomize_replica_read MEMCACHED_BITFIELD;
- bool reuse_memory MEMCACHED_BITFIELD;
- bool support_cas MEMCACHED_BITFIELD;
- bool tcp_nodelay MEMCACHED_BITFIELD;
- bool use_cache_lookups MEMCACHED_BITFIELD;
- bool use_sort_hosts MEMCACHED_BITFIELD;
- bool use_udp MEMCACHED_BITFIELD;
- bool verify_key MEMCACHED_BITFIELD;
- bool tcp_keepalive MEMCACHED_BITFIELD;
+ bool auto_eject_hosts:1;
+ bool binary_protocol:1;
+ bool buffer_requests:1;
+ bool cork:1;
+ bool hash_with_prefix_key:1;
+ bool ketama_weighted:1;
+ bool no_block:1;
+ bool no_reply:1;
+ bool randomize_replica_read:1;
+ bool reuse_memory:1;
+ bool support_cas:1;
+ bool tcp_nodelay:1;
+ bool use_cache_lookups:1;
+ bool use_sort_hosts:1;
+ bool use_udp:1;
+ bool verify_key:1;
++ bool tcp_keepalive:1;
} flags;
memcached_server_distribution_t distribution;
hashkit_st hashkit;
if (write_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
{
rc= MEMCACHED_WRITE_FAILURE;
-- goto error;
-- }
--
- /* Send command header */
- rc= memcached_do(instance, buffer, write_length, false);
- if (rc != MEMCACHED_SUCCESS)
- goto error;
--
- struct __write_vector_st vector[]=
- /* Send command body */
- if (memcached_io_write(instance, value, value_length, false) == -1)
-- {
- { .length= write_length, .buffer= buffer },
- { .length= value_length, .buffer= value },
- { .length= 2, .buffer= "\r\n" }
- };
- rc= MEMCACHED_WRITE_FAILURE;
- goto error;
- }
--
-- if (ptr->flags.buffer_requests && verb == SET_OP)
-- {
-- to_write= false;
}
else
{
-- to_write= true;
-- }
-
- /* Send command header */
- rc= memcached_vdo(instance, vector, 3, to_write);
- if (rc == MEMCACHED_SUCCESS)
- {
-
- if (ptr->flags.no_reply)
- return (to_write == false) ? MEMCACHED_BUFFERED : MEMCACHED_SUCCESS;
-
- if (to_write == false)
- return MEMCACHED_BUFFERED;
-
- rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
-
- if (rc == MEMCACHED_STORED)
- return MEMCACHED_SUCCESS;
- else
- return rc;
++ struct __write_vector_st vector[]=
++ {
++ { .length= write_length, .buffer= buffer },
++ { .length= value_length, .buffer= value },
++ { .length= 2, .buffer= "\r\n" }
++ };
+
- if (memcached_io_write(instance, "\r\n", 2, to_write) == -1)
- {
- rc= MEMCACHED_WRITE_FAILURE;
- goto error;
- }
++ if (ptr->flags.buffer_requests && verb == SET_OP)
++ {
++ to_write= false;
++ }
++ else
++ {
++ to_write= true;
++ }
+
- if (ptr->flags.no_reply)
- return (to_write == false) ? MEMCACHED_BUFFERED : MEMCACHED_SUCCESS;
++ /* Send command header */
++ rc= memcached_vdo(instance, vector, 3, to_write);
++ if (rc == MEMCACHED_SUCCESS)
++ {
+
- if (to_write == false)
- return MEMCACHED_BUFFERED;
++ if (ptr->flags.no_reply)
++ return (to_write == false) ? MEMCACHED_BUFFERED : MEMCACHED_SUCCESS;
+
- rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
++ if (to_write == false)
++ return MEMCACHED_BUFFERED;
+
- if (rc == MEMCACHED_STORED)
- return MEMCACHED_SUCCESS;
- else
- return rc;
++ rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
++
++ if (rc == MEMCACHED_STORED)
++ return MEMCACHED_SUCCESS;
++ else
++ return rc;
++ }
+ }
--error:
-
- memcached_io_reset(instance);
+ if (rc == MEMCACHED_WRITE_FAILURE)
+ memcached_io_reset(instance);
return rc;
}
return TEST_SUCCESS;
}
++
++static test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test(memcached_st *memc)
++{
++ memcached_return_t rc;
++ bool set= true;
++ bool value;
++
++ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, set);
++ test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOT_SUPPORTED);
++
++ value= (bool)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE);
++
++ if (rc == MEMCACHED_SUCCESS)
++ {
++ test_true((bool)value == set);
++ }
++ else
++ {
++ test_false((bool)value == set);
++ }
++
++ return TEST_SUCCESS;
++}
++
++
++static test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test(memcached_st *memc)
++{
++ memcached_return_t rc;
++ bool set= true;
++ bool value;
++
++ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, set);
++ test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOT_SUPPORTED);
++
++ value= (bool)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_KEEPIDLE);
++
++ if (rc == MEMCACHED_SUCCESS)
++ {
++ test_true((bool)value == set);
++ }
++ else
++ {
++ test_false((bool)value == set);
++ }
++
++ return TEST_SUCCESS;
++}
++
static test_return_t fetch_all_results(memcached_st *memc)
{
memcached_return_t rc= MEMCACHED_SUCCESS;
test_st behavior_tests[] ={
{"behavior_test", 0, (test_callback_fn)behavior_test},
{"MEMCACHED_BEHAVIOR_CORK", 0, (test_callback_fn)MEMCACHED_BEHAVIOR_CORK_test},
++ {"MEMCACHED_BEHAVIOR_TCP_KEEPALIVE", 0, (test_callback_fn)MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test},
++ {"MEMCACHED_BEHAVIOR_TCP_KEEPIDLE", 0, (test_callback_fn)MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test},
{0, 0, 0}
};