memcached_return ret= MEMCACHED_SUCCESS;
for (int x= 0; x < mem->number_of_hosts; ++x)
- if (memcached_io_write(&mem->hosts[x], NULL, 0, 1) == -1)
- ret= MEMCACHED_SOME_ERRORS;
+ if (mem->hosts[x].write_buffer_offset != 0)
+ {
+ if (mem->hosts[x].fd == -1 &&
+ (ret= memcached_connect(&mem->hosts[x])) != MEMCACHED_SUCCESS)
+ {
+ WATCHPOINT_ERROR(ret);
+ return ret;
+ }
+ if (memcached_io_write(&mem->hosts[x], NULL, 0, 1) == -1)
+ ret= MEMCACHED_SOME_ERRORS;
+ }
return ret;
}
if (cas)
write_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "%s %s%.*s %u %llu %zu %llu\r\n", storage_op_string(verb),
+ "%s %s%.*s %u %llu %zu %llu%s\r\n",
+ storage_op_string(verb),
ptr->prefix_key,
(int)key_length, key, flags,
(unsigned long long)expiration, value_length,
- (unsigned long long)cas);
+ (unsigned long long)cas,
+ (ptr->flags & MEM_NOREPLY) ? " noreply" : "");
else
write_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "%s %s%.*s %u %llu %zu\r\n", storage_op_string(verb),
+ "%s %s%.*s %u %llu %zu%s\r\n",
+ storage_op_string(verb),
ptr->prefix_key,
(int)key_length, key, flags,
- (unsigned long long)expiration, value_length);
+ (unsigned long long)expiration, value_length,
+ (ptr->flags & MEM_NOREPLY) ? " noreply" : "");
if (write_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
{
else
to_write= 1;
- if (ptr->flags & MEM_NOREPLY)
- {
- if (memcached_io_write(&ptr->hosts[server_key], " noreply\r\n",
- 10, to_write) == -1)
- {
- rc= MEMCACHED_WRITE_FAILURE;
- goto error;
- }
-
- memcached_server_response_decrement(&ptr->hosts[server_key]);
- return (to_write == 0) ? MEMCACHED_BUFFERED : MEMCACHED_SUCCESS;
- }
-
if ((sent_length= memcached_io_write(&ptr->hosts[server_key], "\r\n", 2, to_write)) == -1)
{
rc= MEMCACHED_WRITE_FAILURE;
goto error;
}
+ if (ptr->flags & MEM_NOREPLY)
+ {
+ memcached_server_response_decrement(&ptr->hosts[server_key]);
+ return (to_write == 0) ? MEMCACHED_BUFFERED : MEMCACHED_SUCCESS;
+ }
+
if (to_write == 0)
return MEMCACHED_BUFFERED;
assert(no_msg == 0);
assert(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS);
+
+ /*
+ ** Now validate that all items was set properly!
+ */
+ for (int x= 0; x < 100; ++x) {
+ char key[10];
+ size_t len= sprintf(key, "%d", x);
+ size_t length;
+ uint32_t flags;
+ char* value= memcached_get(memc, key, strlen(key),
+ &length, &flags, &ret);
+ assert(ret == MEMCACHED_SUCCESS && value != NULL);
+ assert(strncmp(value, key, len) == 0);
+ free(value);
+ }
+
return TEST_SUCCESS;
}