bool to_write;
size_t write_length;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
- memcached_server_write_instance_st instance;
WATCHPOINT_ASSERT(!(value == NULL && value_length > 0));
}
if (memcached_failed(rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol)))
+ {
return rc;
+ }
- if (ptr->flags.verify_key && (memcached_key_test((const char **)&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
+ if (memcached_failed(memcached_key_test(*ptr, (const char **)&key, &key_length, 1)))
+ {
return MEMCACHED_BAD_KEY_PROVIDED;
+ }
uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length);
- instance= memcached_server_instance_fetch(ptr, server_key);
+ memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key);
WATCHPOINT_SET(instance->io_wait_count.read= 0);
WATCHPOINT_SET(instance->io_wait_count.write= 0);
check_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
"%s %.*s%.*s %u %llu %lu %llu%s\r\n",
storage_op_string(verb),
- memcached_print_array(ptr->prefix_key),
+ memcached_print_array(ptr->_namespace),
(int)key_length, key, flags,
(unsigned long long)expiration, (unsigned long)value_length,
(unsigned long long)cas,
(ptr->flags.no_reply) ? " noreply" : "");
if (check_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || check_length < 0)
{
- rc= MEMCACHED_WRITE_FAILURE;
+ rc= memcached_set_error(*instance, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT,
+ memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)"));
memcached_io_reset(instance);
return rc;
memcpy(buffer_ptr, command, strlen(command));
/* Copy in the key prefix, switch to the buffer_ptr */
- buffer_ptr= (char *)memcpy((char *)(buffer_ptr + strlen(command)), (char *)memcached_array_string(ptr->prefix_key), memcached_array_size(ptr->prefix_key));
+ buffer_ptr= (char *)memcpy((char *)(buffer_ptr + strlen(command)), (char *)memcached_array_string(ptr->_namespace), memcached_array_size(ptr->_namespace));
/* Copy in the key, adjust point if a key prefix was used. */
- buffer_ptr= (char *)memcpy(buffer_ptr + memcached_array_size(ptr->prefix_key),
+ buffer_ptr= (char *)memcpy(buffer_ptr + memcached_array_size(ptr->_namespace),
key, key_length);
buffer_ptr+= key_length;
buffer_ptr[0]= ' ';
ptr->flags.no_reply ? " noreply" : "");
if ((size_t)check_length >= MEMCACHED_DEFAULT_COMMAND_SIZE -size_t(buffer_ptr - buffer) || check_length < 0)
{
- rc= MEMCACHED_WRITE_FAILURE;
+ rc= memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT,
+ memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)"));
memcached_io_reset(instance);
return rc;
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
request.message.header.request.opcode= get_com_code(verb, noreply);
- request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(ptr->prefix_key)));
+ request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(ptr->_namespace)));
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
if (verb == APPEND_OP || verb == PREPEND_OP)
send_length -= 8; /* append & prepend does not contain extras! */
request.message.body.expiration= htonl((uint32_t)expiration);
}
- request.message.header.request.bodylen= htonl((uint32_t) (key_length + memcached_array_size(ptr->prefix_key) + value_length +
+ request.message.header.request.bodylen= htonl((uint32_t) (key_length + memcached_array_size(ptr->_namespace) + value_length +
request.message.header.request.extlen));
if (cas)
struct libmemcached_io_vector_st vector[]=
{
{ send_length, request.bytes },
- { memcached_array_size(ptr->prefix_key), memcached_array_string(ptr->prefix_key) },
+ { memcached_array_size(ptr->_namespace), memcached_array_string(ptr->_namespace) },
{ key_length, key },
{ value_length, value }
};