that connnect() does not block/loop when using non-block mode.
+0.17
+ * MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT added for connect timeout in
+ non-block mode.
+
0.16
* Work on the UDP protocol
* Added get_by_key, set_by_key tests for C++ API
Enabling this will cause hosts that are added to be placed in the host list in
sorted order. This will defeat consisten hashing.
+=item MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT
+
+In non-blocking mode this changes the value of the timeout during socket
+connection.
+
=back
=head1 RETURN
MEMCACHED_BEHAVIOR_USER_DATA,
MEMCACHED_BEHAVIOR_SORT_HOSTS,
MEMCACHED_BEHAVIOR_VERIFY_KEY,
+ MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT,
} memcached_behavior;
typedef enum {
int send_size;
int recv_size;
int32_t poll_timeout;
+ int32_t connect_timeout;
memcached_result_st result;
memcached_hash hash;
memcached_server_distribution distribution;
ptr->poll_timeout= timeout;
break;
}
+ case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT:
+ {
+ int32_t timeout= (*((int32_t *)data));
+
+ ptr->connect_timeout= timeout;
+ break;
+ }
case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE:
{
ptr->send_size= (*((int *)data));
{
return (unsigned long long)ptr->poll_timeout;
}
+ case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT:
+ {
+ return (unsigned long long)ptr->connect_timeout;
+ }
case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE:
{
int sock_size;
sizeof(servAddr)) < 0)
{
switch (errno) {
+ case EINPROGRESS:
+ {
+ struct timeval tm = { ptr->root->connect_timeout, 0 };
+ socklen_t len= sizeof(int);
+ fd_set wset;
+ int error=0, value;
+
+ FD_ZERO(&wset);
+ FD_SET(ptr->fd, &wset);
+
+ select(ptr->fd+1, NULL, &wset, NULL, &tm);
+ if (FD_ISSET(ptr->fd, &wset) != 0)
+ {
+ if (getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &value, &len) == 0)
+ {
+ if (value)
+ {
+ error= 1;
+ }
+ }
+ else
+ {
+ error= 1;
+ }
+ }
+ else
+ {
+ error= 1;
+ }
+
+ if (error)
+ {
+ ptr->cached_errno= errno;
+ WATCHPOINT_ERRNO(ptr->cached_errno);
+ close(ptr->fd);
+ ptr->fd= -1;
+ return MEMCACHED_ERRNO;
+ }
+
+ break;
+ }
/* We are spinning waiting on connect */
case EALREADY:
- case EINPROGRESS:
case EINTR:
goto test_connect;
case EISCONN: /* We were spinning waiting on connect */