fds[0].fd = ptr->fd;
fds[0].events = POLLOUT;
- int error;
size_t loop_max= 5;
while (--loop_max) // Should only loop on cases of ERESTART or EINTR
{
+ int error;
if (ptr->root->poll_timeout)
{
error= poll(fds, 1, ptr->root->connect_timeout);
}
else
{
- ptr->cached_errno= errno;
-
- return MEMCACHED_ERRNO;
+ return memcached_set_errno(*ptr, err, MEMCACHED_AT);
}
}
case 0:
#endif
case EINTR:
continue;
- default:
+
+ case EFAULT:
+ case ENOMEM:
+ return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
+
+ case EINVAL:
+ return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("RLIMIT_NOFILE exceeded, or if OSX the timeout value was invalid"));
+
+ default: // This should not happen
if (fds[0].revents & POLLERR)
{
int err;
error->rc= rc;
error->local_errno= local_errno;
- if (str and local_errno)
+ if (str and str->size and local_errno)
{
error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "%s(%s), %.*s -> %s",
memcached_strerror(&memc, rc),
strerror(local_errno),
- int(error->size), str->c_str, at);
+ memcached_string_printf(*str), at);
}
else if (local_errno)
{
memcached_strerror(&memc, rc),
strerror(local_errno), at);
}
- else if (str)
+ else if (str and str->size)
{
error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "%s, %.*s -> %s",
memcached_strerror(&memc, rc),
- int(error->size), str->c_str, at);
+ int(str->size), str->c_str, at);
}
else
{
case EINTR:
break;
+ case EFAULT:
+ case ENOMEM:
+ return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
+
+ case EINVAL:
+ return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("RLIMIT_NOFILE exceeded, or if OSX the timeout value was invalid"));
+
default:
if (fds.revents & POLLERR)
{
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
memcached_return_t rc= memcached_parse_configuration(memc_ptr, option_string, length);
- if (memcached_failed(rc) && error_buffer && error_buffer_size)
+ if (memcached_failed(rc) and error_buffer and error_buffer_size)
{
strncpy(error_buffer, memcached_last_error_message(memc_ptr), error_buffer_size);
+ error_buffer[length -1]= 0;
}
bool has_filename= memcached_behavior_get(memc_ptr, MEMCACHED_BEHAVIOR_LOAD_FROM_FILE);