* Support for weighted Ketama from Yin Chen.
* Fix for Chinese
* Fix for 0 length key to trigger bad key.
+ * Added behaviors MEMCACHED_BEHAVIOR_SND_TIMEOUT, MEMCACHED_BEHAVIOR_RCV_TIMEOUT
0.22 Mon Jul 14 09:24:11 PDT 2008
* Fix where master key was no being checked for "bad key"
sinclude(config/dtrace.m4)
sinclude(config/byteorder.m4)
sinclude(config/64bit.m4)
-sinclude(config/protocol_binary.m4)
+#sinclude(config/protocol_binary.m4)
# We only support GCC and Sun's forte at the moment
if test "$GCC" = "yes"
similar in performance to the non-blocking method (this is being
looked into).
+=item MEMCACHED_BEHAVIOR_SND_TIMEOUT
+
+This sets the microsecond behavior of the socket against the SO_SNDTIMEO flag.
+In cases where you cannot use non-blocking IO this will allow you to still have
+timeouts on the sending of data.
+
+=item MEMCACHED_BEHAVIOR_RCV_TIMEOUT
+
+This sets the microsecond behavior of the socket against the SO_RCVTIMEO flag.
+In cases where you cannot use non-blocking IO this will allow you to still have
+timeouts on the reading of data.
+
=item MEMCACHED_BEHAVIOR_TCP_NODELAY
Turns on the no-delay feature for connecting sockets (may be faster in some
new_clone->hash_continuum= ptr->hash_continuum;
new_clone->user_data= ptr->user_data;
+ new_clone->snd_timeout= ptr->snd_timeout;
+ new_clone->rcv_timeout= ptr->rcv_timeout;
+
new_clone->on_clone= ptr->on_clone;
new_clone->on_cleanup= ptr->on_cleanup;
new_clone->call_free= ptr->call_free;
size_t prefix_key_length;
memcached_hash hash_continuum;
uint32_t continuum_points_counter;
+ int32_t snd_timeout;
+ int32_t rcv_timeout;
};
{
switch (flag)
{
+ case MEMCACHED_BEHAVIOR_SND_TIMEOUT:
+ ptr->snd_timeout= (int32_t)data;
+ break;
+ case MEMCACHED_BEHAVIOR_RCV_TIMEOUT:
+ ptr->rcv_timeout= (int32_t)data;
+ break;
case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL:
set_behavior_flag(ptr, MEM_BINARY_PROTOCOL, data);
break;
if (ptr->type == MEMCACHED_CONNECTION_UDP)
return MEMCACHED_SUCCESS;
- if (ptr->root->flags & MEM_NO_BLOCK)
+ if (ptr->root->snd_timeout)
{
int error;
struct timeval waittime;
- waittime.tv_sec= 10;
- waittime.tv_usec= 0;
+ waittime.tv_sec= 0;
+ waittime.tv_usec= ptr->root->snd_timeout;
error= setsockopt(ptr->fd, SOL_SOCKET, SO_SNDTIMEO,
&waittime, (socklen_t)sizeof(struct timeval));
WATCHPOINT_ASSERT(error == 0);
+ }
+
+ if (ptr->root->rcv_timeout)
+ {
+ int error;
+ struct timeval waittime;
+
+ waittime.tv_sec= 0;
+ waittime.tv_usec= ptr->root->rcv_timeout;
error= setsockopt(ptr->fd, SOL_SOCKET, SO_RCVTIMEO,
&waittime, (socklen_t)sizeof(struct timeval));
MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED,
MEMCACHED_BEHAVIOR_KETAMA_HASH,
MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
+ MEMCACHED_BEHAVIOR_SND_TIMEOUT,
+ MEMCACHED_BEHAVIOR_RCV_TIMEOUT,
} memcached_behavior;
typedef enum {
unsigned int number_of_keys)
{
memcached_return rc= MEMCACHED_NOTFOUND;
+ int x;
int flush= number_of_keys == 1;
If a server fails we warn about errors and start all over with sending keys
to the server.
*/
- for (int x= 0; x < number_of_keys; x++)
+ for (x= 0; x < number_of_keys; x++)
{
unsigned int server_key;
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_NOOP;
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
- for (int x= 0; x < ptr->number_of_hosts; x++)
+ for (x= 0; x < ptr->number_of_hosts; x++)
if (memcached_server_response_count(&ptr->hosts[x]))
{
if (memcached_io_write(&ptr->hosts[x], NULL, 0, 1) == -1)
return MEMCACHED_SUCCESS;
}
+memcached_return pre_settimer(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SND_TIMEOUT, 1000);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RCV_TIMEOUT, 1000);
+
+ return MEMCACHED_SUCCESS;
+}
+
memcached_return poll_timeout(memcached_st *memc)
{
int32_t timeout;
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},
{"md5", pre_md5, 0, tests},
{"crc", pre_crc, 0, tests},
{"hsieh", pre_hsieh, 0, tests},