- char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
- uint32_t server_key;
- memcached_server_write_instance_st instance;
- bool no_reply= ptr->flags.no_reply;
-
- if (ptr->flags.verify_key && (memcached_key_test((const char **)&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
- return memcached_set_error(ptr, MEMCACHED_BAD_KEY_PROVIDED);
-
- server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length);
- instance= memcached_server_instance_fetch(ptr, server_key);
-
- int send_length;
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "%s %.*s%.*s %" PRIu64 "%s\r\n", verb,
- memcached_print_array(ptr->prefix_key),
- (int)key_length, key,
- offset, no_reply ? " noreply" : "");
- if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || send_length < 0)
- return memcached_set_error_string(ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)"));
-
- memcached_return_t rc= memcached_do(instance, buffer, (size_t)send_length, true);
- if (no_reply or memcached_failed(rc))
- return rc;
-
- rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
-
- /*
- So why recheck responce? Because the protocol is brain dead :)
- The number returned might end up equaling one of the string
- values. Less chance of a mistake with strncmp() so we will
- use it. We still called memcached_response() though since it
- worked its magic for non-blocking IO.
- */
- if (not strncmp(buffer, memcached_literal_param("ERROR\r\n")))