X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fstorage.cc;h=1d75eb9a3aa143d21c4406aa30f73bf8849181e4;hb=5d90dfa139600be998cd8bab9008e77c7882f336;hp=5453416f2aaf0d6a80abf4df11b163b80ff0c679;hpb=3c74b93b3db239f4240c907a91678ed401fa41ad;p=m6w6%2Flibmemcached diff --git a/libmemcached/storage.cc b/libmemcached/storage.cc index 5453416f..1d75eb9a 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,14 +171,16 @@ 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); +#if 0 if (memcached_has_error(ptr)) { memcached_set_error(*server, rc, MEMCACHED_AT); } +#endif return MEMCACHED_WRITE_FAILURE; } @@ -197,7 +200,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 +276,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,21 +291,23 @@ static memcached_return_t memcached_send_ascii(memcached_st *ptr, }; /* Send command header */ - memcached_return_t rc= memcached_vdo(instance, vector, 11, flush); - if (rc == MEMCACHED_SUCCESS) + memcached_return_t rc= memcached_vdo(instance, vector, 12, flush); + + // If we should not reply, return with MEMCACHED_SUCCESS, unless error + if (reply == false) { - if (flush == false) - { - return MEMCACHED_BUFFERED; - } + return memcached_success(rc) ? MEMCACHED_SUCCESS : rc; + } - if (reply == false) - { - return MEMCACHED_SUCCESS; - } + if (flush == false) + { + return memcached_success(rc) ? MEMCACHED_BUFFERED : rc; + } + if (rc == MEMCACHED_SUCCESS) + { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); + rc= memcached_response(instance, buffer, sizeof(buffer), NULL); if (rc == MEMCACHED_STORED) { @@ -315,10 +321,12 @@ static memcached_return_t memcached_send_ascii(memcached_st *ptr, } assert(memcached_failed(rc)); +#if 0 if (memcached_has_error(ptr) == false) { return memcached_set_error(*ptr, rc, MEMCACHED_AT); } +#endif return rc; } @@ -338,14 +346,9 @@ static inline memcached_return_t memcached_send(memcached_st *ptr, return rc; } - if (memcached_failed(rc= memcached_validate_key_length(key_length, memcached_is_binary(ptr)))) - { - return rc; - } - if (memcached_failed(memcached_key_test(*ptr, (const char **)&key, &key_length, 1))) { - return MEMCACHED_BAD_KEY_PROVIDED; + return memcached_last_error(ptr); } uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length); @@ -404,10 +407,6 @@ memcached_return_t memcached_add(memcached_st *ptr, key, key_length, value, value_length, expiration, flags, 0, ADD_OP); - if (rc == MEMCACHED_NOTSTORED or rc == MEMCACHED_DATA_EXISTS) - { - memcached_set_error(*ptr, rc, MEMCACHED_AT); - } LIBMEMCACHED_MEMCACHED_ADD_END(); return rc; }