#include "common.h"
#include <time.h>
#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/tcp.h>
static bool set_flag(uint64_t data)
{
ptr->server_failure_limit= (uint32_t)data;
break;
case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL:
+ memcached_quit(ptr); // We need t shutdown all of the connections to make sure we do the correct protocol
if (data)
{
ptr->flags.verify_key= false;
return MEMCACHED_SUCCESS;
}
-inline bool _is_auto_eject_host(const memcached_st *ptr)
+bool _is_auto_eject_host(const memcached_st *ptr)
{
return ptr->flags.auto_eject_hosts;
}
/* REFACTOR */
/* We just try the first host, and if it is down we return zero */
if ((memcached_connect(instance)) != MEMCACHED_SUCCESS)
+ {
+ return 0;
+ }
+
+ if (memcached_io_wait_for_write(instance) != MEMCACHED_SUCCESS)
+ {
return 0;
+ }
- if (getsockopt(instance->fd, SOL_SOCKET,
- SO_SNDBUF, &sock_size, &sock_length))
+ if (getsockopt(instance->fd, SOL_SOCKET, SO_SNDBUF, &sock_size, &sock_length) < 0)
+ {
+ ptr->cached_errno= errno;
return 0; /* Zero means error */
+ }
}
return (uint64_t) sock_size;
{
/* We just try the first host, and if it is down we return zero */
if ((memcached_connect(instance)) != MEMCACHED_SUCCESS)
+ {
+ return 0;
+ }
+
+ if (memcached_io_wait_for_write(instance) != MEMCACHED_SUCCESS)
+ {
return 0;
+ }
- if (getsockopt(instance->fd, SOL_SOCKET,
- SO_RCVBUF, &sock_size, &sock_length))
+ if (getsockopt(instance->fd, SOL_SOCKET, SO_RCVBUF, &sock_size, &sock_length) < 0)
+ {
+ ptr->cached_errno= errno;
return 0; /* Zero means error */
+ }
}