#include <libmemcached/common.h>
-#include <cassert>
#include <ctime>
#include <sys/time.h>
size_t loop_max= 5;
- while (--loop_max) // Should only loop on cases of ERESTART or EINTR
+ if (ptr->root->poll_timeout == 0)
{
- int error;
- if (ptr->root->poll_timeout)
- {
- error= poll(fds, 1, ptr->root->connect_timeout);
- }
- else
- {
- error= 0;
- }
+ return memcached_set_error(*ptr, MEMCACHED_TIMEOUT, MEMCACHED_AT);
+ }
+ while (--loop_max) // Should only loop on cases of ERESTART or EINTR
+ {
+ int error= poll(fds, 1, ptr->root->connect_timeout);
switch (error)
{
case 1:
int err;
socklen_t len= sizeof (err);
(void)getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len);
- ptr->cached_errno= (err == 0) ? get_socket_errno() : err;
+ memcached_set_errno(*ptr, (err == 0) ? get_socket_errno() : err, MEMCACHED_AT);
}
else
{
- ptr->cached_errno= get_socket_errno();
+ memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT);
}
WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
char str_port[NI_MAXSERV];
int length= snprintf(str_port, NI_MAXSERV, "%u", (uint32_t)server->port);
if (length >= NI_MAXSERV || length < 0)
+ {
return MEMCACHED_FAILURE;
+ }
struct addrinfo hints;
memset(&hints, 0, sizeof(struct addrinfo));
if ((ptr->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
- return memcached_set_errno(*ptr, errno, NULL);
+ memcached_set_errno(*ptr, errno, NULL);
+ return MEMCACHED_CONNECTION_FAILURE;
}
struct sockaddr_un servAddr;
default:
WATCHPOINT_ERRNO(errno);
- return memcached_set_errno(*ptr, errno, MEMCACHED_AT);
+ memcached_set_errno(*ptr, errno, MEMCACHED_AT);
+ return MEMCACHED_CONNECTION_FAILURE;
}
}
} while (0);
memcached_return_t rc= MEMCACHED_NO_SERVERS;
if (ptr->fd != INVALID_SOCKET)
+ {
return MEMCACHED_SUCCESS;
+ }
LIBMEMCACHED_MEMCACHED_CONNECT_START();