return MEMCACHED_STAT;
}
else if (buffer[1] == 'E')
- return MEMCACHED_SERVER_ERROR;
+ {
+ /* SERVER_ERROR */
+ char *startptr= buffer + 13, *endptr= startptr;
+ while (*endptr != '\r' && *endptr != '\n') endptr++;
+ if (ptr->cached_server_error) free(ptr->cached_server_error);
+ ptr->cached_server_error= malloc(endptr - startptr + 1);
+ memcpy(ptr->cached_server_error, startptr, endptr - startptr);
+ ptr->cached_server_error[endptr - startptr]= 0;
+ return MEMCACHED_SERVER_ERROR;
+ }
else if (buffer[1] == 'T')
return MEMCACHED_STORED;
else
{
memcached_quit_server(ptr, 0);
+ if (ptr->cached_server_error)
+ {
+ free(ptr->cached_server_error);
+ ptr->cached_server_error= NULL;
+ }
+
if (ptr->address_info)
{
freeaddrinfo(ptr->address_info);
*/
memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr)
{
+ memcached_server_st *rv = NULL;
+
/* We just do a normal create if ptr is missing */
if (ptr == NULL)
return NULL;
- /* TODO We should check return type */
- return memcached_server_create_with(ptr->root, clone,
- ptr->hostname, ptr->port, ptr->weight,
- ptr->type);
+ rv = memcached_server_create_with(ptr->root, clone,
+ ptr->hostname, ptr->port, ptr->weight,
+ ptr->type);
+ if (rv != NULL)
+ {
+ rv->cached_errno= ptr->cached_errno;
+ if (ptr->cached_server_error)
+ rv->cached_server_error= strdup(ptr->cached_server_error);
+ }
+
+ return rv;
+
}
memcached_return memcached_server_cursor(memcached_st *ptr,