From 26ec654470aafe3772c2c7817f7089e95aabed4d Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Fri, 30 Dec 2011 17:04:02 -0800 Subject: [PATCH] Fix NULL bit to exist for UDP --- libmemcached/auto.cc | 8 +++++--- libmemcached/delete.cc | 15 +++++++++------ libmemcached/exist.cc | 6 ++++-- libmemcached/storage.cc | 8 +++++--- libmemcached/touch.cc | 6 ++++-- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/libmemcached/auto.cc b/libmemcached/auto.cc index c1764c4d..88b921c4 100644 --- a/libmemcached/auto.cc +++ b/libmemcached/auto.cc @@ -55,6 +55,7 @@ static memcached_return_t text_incr_decr(memcached_server_write_instance_st inst libmemcached_io_vector_st vector[]= { + { NULL, 0 }, { memcached_literal_param("incr ") }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length }, @@ -65,10 +66,10 @@ static memcached_return_t text_incr_decr(memcached_server_write_instance_st inst if (is_incr == false) { - vector[0].buffer= "decr "; + vector[1].buffer= "decr "; } - memcached_return_t rc= memcached_vdo(instance, vector, 6, true); + memcached_return_t rc= memcached_vdo(instance, vector, 7, true); if (reply == false) { @@ -121,13 +122,14 @@ static memcached_return_t binary_incr_decr(memcached_server_write_instance_st in libmemcached_io_vector_st vector[]= { + { NULL, 0 }, { request.bytes, sizeof(request.bytes) }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length } }; memcached_return_t rc; - if (memcached_failed(rc= memcached_vdo(instance, vector, 3, true))) + if (memcached_failed(rc= memcached_vdo(instance, vector, 4, true))) { memcached_io_reset(instance); return MEMCACHED_WRITE_FAILURE; diff --git a/libmemcached/delete.cc b/libmemcached/delete.cc index 1c4aba6c..9baf56b8 100644 --- a/libmemcached/delete.cc +++ b/libmemcached/delete.cc @@ -53,6 +53,7 @@ static inline memcached_return_t ascii_delete(memcached_server_write_instance_st { libmemcached_io_vector_st vector[]= { + { NULL, 0 }, { memcached_literal_param("delete ") }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length }, @@ -62,7 +63,7 @@ static inline memcached_return_t ascii_delete(memcached_server_write_instance_st if (memcached_is_udp(instance->root)) { - size_t send_length= io_vector_total_size(vector, 5); + size_t send_length= io_vector_total_size(vector, 6); if (send_length > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH) { @@ -76,7 +77,7 @@ static inline memcached_return_t ascii_delete(memcached_server_write_instance_st } /* Send command header */ - return memcached_vdo(instance, vector, 5, flush); + return memcached_vdo(instance, vector, 6, flush); } static inline memcached_return_t binary_delete(memcached_server_write_instance_st instance, @@ -117,6 +118,7 @@ static inline memcached_return_t binary_delete(memcached_server_write_instance_s libmemcached_io_vector_st vector[]= { + { NULL, 0 }, { request.bytes, sizeof(request.bytes) }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length } @@ -124,7 +126,7 @@ static inline memcached_return_t binary_delete(memcached_server_write_instance_s memcached_return_t rc= MEMCACHED_SUCCESS; - if ((rc= memcached_vdo(instance, vector, 3, flush)) != MEMCACHED_SUCCESS) + if ((rc= memcached_vdo(instance, vector, 4, flush)) != MEMCACHED_SUCCESS) { memcached_io_reset(instance); } @@ -135,15 +137,16 @@ static inline memcached_return_t binary_delete(memcached_server_write_instance_s for (uint32_t x= 0; x < instance->root->number_of_replicas; ++x) { - memcached_server_write_instance_st replica; ++server_key; if (server_key == memcached_server_count(instance->root)) + { server_key= 0; + } - replica= memcached_server_instance_fetch(instance->root, server_key); + memcached_server_write_instance_st replica= memcached_server_instance_fetch(instance->root, server_key); - if (memcached_vdo(replica, vector, 3, flush) != MEMCACHED_SUCCESS) + if (memcached_vdo(replica, vector, 4, flush) != MEMCACHED_SUCCESS) { memcached_io_reset(replica); } diff --git a/libmemcached/exist.cc b/libmemcached/exist.cc index 6903f83b..d2dc34dd 100644 --- a/libmemcached/exist.cc +++ b/libmemcached/exist.cc @@ -40,6 +40,7 @@ static memcached_return_t ascii_exist(memcached_st *memc, memcached_server_write { libmemcached_io_vector_st vector[]= { + { NULL, 0 }, { memcached_literal_param("add ") }, { memcached_array_string(memc->_namespace), memcached_array_size(memc->_namespace) }, { key, key_length }, @@ -51,7 +52,7 @@ static memcached_return_t ascii_exist(memcached_st *memc, memcached_server_write }; /* Send command header */ - memcached_return_t rc= memcached_vdo(instance, vector, 8, true); + memcached_return_t rc= memcached_vdo(instance, vector, 9, true); if (rc == MEMCACHED_SUCCESS) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; @@ -95,6 +96,7 @@ static memcached_return_t binary_exist(memcached_st *memc, memcached_server_writ libmemcached_io_vector_st vector[]= { + { NULL, 0 }, { request.bytes, send_length }, { memcached_array_string(memc->_namespace), memcached_array_size(memc->_namespace) }, { key, key_length } @@ -102,7 +104,7 @@ static memcached_return_t binary_exist(memcached_st *memc, memcached_server_writ /* write the header */ memcached_return_t rc; - if ((rc= memcached_vdo(instance, vector, 3, true)) != MEMCACHED_SUCCESS) + if ((rc= memcached_vdo(instance, vector, 4, true)) != MEMCACHED_SUCCESS) { memcached_io_reset(instance); return (rc == MEMCACHED_SUCCESS) ? MEMCACHED_WRITE_FAILURE : rc; diff --git a/libmemcached/storage.cc b/libmemcached/storage.cc index 5453416f..0ce4ea61 100644 --- a/libmemcached/storage.cc +++ b/libmemcached/storage.cc @@ -162,6 +162,7 @@ static memcached_return_t memcached_send_binary(memcached_st *ptr, libmemcached_io_vector_st vector[]= { + { NULL, 0 }, { request.bytes, send_length }, { memcached_array_string(ptr->_namespace), memcached_array_size(ptr->_namespace) }, { key, key_length }, @@ -170,7 +171,7 @@ static memcached_return_t memcached_send_binary(memcached_st *ptr, /* write the header */ memcached_return_t rc; - if ((rc= memcached_vdo(server, vector, 4, flush)) != MEMCACHED_SUCCESS) + if ((rc= memcached_vdo(server, vector, 5, flush)) != MEMCACHED_SUCCESS) { memcached_io_reset(server); @@ -197,7 +198,7 @@ static memcached_return_t memcached_send_binary(memcached_st *ptr, memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key); - if (memcached_vdo(instance, vector, 4, false) != MEMCACHED_SUCCESS) + if (memcached_vdo(instance, vector, 5, false) != MEMCACHED_SUCCESS) { memcached_io_reset(instance); } @@ -273,6 +274,7 @@ static memcached_return_t memcached_send_ascii(memcached_st *ptr, libmemcached_io_vector_st vector[]= { + { NULL, 0 }, { storage_op_string(verb), strlen(storage_op_string(verb))}, { memcached_array_string(ptr->_namespace), memcached_array_size(ptr->_namespace) }, { key, key_length }, @@ -287,7 +289,7 @@ static memcached_return_t memcached_send_ascii(memcached_st *ptr, }; /* Send command header */ - memcached_return_t rc= memcached_vdo(instance, vector, 11, flush); + memcached_return_t rc= memcached_vdo(instance, vector, 12, flush); if (rc == MEMCACHED_SUCCESS) { if (flush == false) diff --git a/libmemcached/touch.cc b/libmemcached/touch.cc index ba73146f..8505d7e6 100644 --- a/libmemcached/touch.cc +++ b/libmemcached/touch.cc @@ -52,6 +52,7 @@ static memcached_return_t ascii_touch(memcached_server_write_instance_st instanc libmemcached_io_vector_st vector[]= { + { NULL, 0 }, { memcached_literal_param("touch ") }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length }, @@ -60,7 +61,7 @@ static memcached_return_t ascii_touch(memcached_server_write_instance_st instanc }; memcached_return_t rc; - if (memcached_failed(rc= memcached_vdo(instance, vector, 5, true))) + if (memcached_failed(rc= memcached_vdo(instance, vector, 6, true))) { memcached_io_reset(instance); return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); @@ -84,13 +85,14 @@ static memcached_return_t binary_touch(memcached_server_write_instance_st instan libmemcached_io_vector_st vector[]= { + { NULL, 0 }, { request.bytes, sizeof(request.bytes) }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length } }; memcached_return_t rc; - if (memcached_failed(rc= memcached_vdo(instance, vector, 3, true))) + if (memcached_failed(rc= memcached_vdo(instance, vector, 4, true))) { memcached_io_reset(instance); return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); -- 2.30.2