- if ((sent_length = write(ptr->hosts[server_key].fd, buffer, send_length) == -1))
- return MEMCACHED_WRITE_FAILURE;
- if (sent_length != send_length)
- return MEMCACHED_WRITE_FAILURE;
+ to_write= (ptr->flags & MEM_BUFFER_REQUESTS) ? 0 : 1;
+
+ rc= memcached_do(ptr, server_key, buffer, send_length, to_write);
+ if (rc != MEMCACHED_SUCCESS)
+ goto error;
+
+ if ((ptr->flags & MEM_BUFFER_REQUESTS))
+ {
+ rc= MEMCACHED_BUFFERED;
+ }
+ else
+ {
+ rc= memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL, server_key);
+ if (rc == MEMCACHED_DELETED)
+ rc= MEMCACHED_SUCCESS;
+ }