use it. We still called memcached_response() though since it
worked its magic for non-blocking IO.
*/
- if (!strncmp(buffer, "ERROR\r\n", 7))
+ if (! strncmp(buffer, "ERROR\r\n", 7))
+ {
+ *value= 0;
+ rc= MEMCACHED_PROTOCOL_ERROR;
+ }
+ else if (! strncmp(buffer, "CLIENT_ERROR\r\n", 14))
{
*value= 0;
rc= MEMCACHED_PROTOCOL_ERROR;
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
request.message.header.request.opcode= cmd;
- request.message.header.request.keylen= htons((uint16_t) key_length);
+ request.message.header.request.keylen= htons((uint16_t)(key_length + ptr->prefix_key_length));
request.message.header.request.extlen= 20;
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
- request.message.header.request.bodylen= htonl((uint32_t) (key_length + request.message.header.request.extlen));
+ request.message.header.request.bodylen= htonl((uint32_t)(key_length + ptr->prefix_key_length + request.message.header.request.extlen));
request.message.body.delta= htonll(offset);
request.message.body.initial= htonll(initial);
request.message.body.expiration= htonl((uint32_t) expiration);
- if ((memcached_do(instance, request.bytes,
- sizeof(request.bytes), false) != MEMCACHED_SUCCESS) ||
- (memcached_io_write(instance, key, key_length, true) == -1))
+ struct __write_vector_st vector[]=
+ {
+ { .length= sizeof(request.bytes), .buffer= request.bytes },
+ { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key },
+ { .length= key_length, .buffer= key }
+ };
+
+ memcached_return_t rc;
+ if ((rc= memcached_vdo(instance, vector, 3, true)) != MEMCACHED_SUCCESS)
{
memcached_io_reset(instance);
- return MEMCACHED_WRITE_FAILURE;
+ return (rc == MEMCACHED_SUCCESS) ? MEMCACHED_WRITE_FAILURE : rc;
}
if (no_reply)