if (rrc != MEMCACHED_SUCCESS)
return rrc;
- if (read_length != (size_t)(value_length + 2))
+ if (read_length != (ssize_t)(value_length + 2))
{
goto read_error;
}
memcached_server_response_increment(ptr);
return MEMCACHED_STAT;
}
- else if (buffer[1] == 'E')
- return MEMCACHED_SERVER_ERROR;
+ else if (buffer[1] == 'E') /* SERVER_ERROR */
+ {
+ char *rel_ptr;
+ char *startptr= buffer + 13, *endptr= startptr;
+
+ while (*endptr != '\r' && *endptr != '\n') endptr++;
+
+ /*
+ Yes, we could make this "efficent" but to do that we would need
+ to maintain more state for the size of the buffer. Why waste
+ memory in the struct, which is important, for something that
+ rarely should happen?
+ */
+ rel_ptr= (char *)ptr->root->call_realloc(ptr->root, ptr->cached_server_error, endptr - startptr + 1);
+
+ if (rel_ptr == NULL)
+ {
+ /* If we happened to have some memory, we just null it since we don't know the size */
+ if (ptr->cached_server_error)
+ ptr->cached_server_error[0]= 0;
+ return MEMCACHED_SERVER_ERROR;
+ }
+ ptr->cached_server_error= rel_ptr;
+
+ 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
else
return MEMCACHED_UNKNOWN_READ_FAILURE;
}
+ case 'I': /* CLIENT ERROR */
+ /* We add back in one because we will need to search for END */
+ memcached_server_response_increment(ptr);
+ return MEMCACHED_ITEM;
case 'C': /* CLIENT ERROR */
return MEMCACHED_CLIENT_ERROR;
default:
WATCHPOINT_ASSERT(bodylen == 0);
return MEMCACHED_SUCCESS;
}
- break;
case PROTOCOL_BINARY_CMD_NOOP:
{
WATCHPOINT_ASSERT(bodylen == 0);
return MEMCACHED_END;
}
- break;
case PROTOCOL_BINARY_CMD_STAT:
{
if (bodylen == 0)