X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fflush.cc;h=9702771f68b64be9b699f680bca51e52c65987c7;hb=9973d386ac8476cd09cc4d9cf7bd2234a42740c7;hp=6b8ea4b0815a7b6ae4daf7bfd4832a1aff934f94;hpb=324548f9250e1c0ad5814f1436e401ad989c84f3;p=awesomized%2Flibmemcached diff --git a/libmemcached/flush.cc b/libmemcached/flush.cc index 6b8ea4b0..9702771f 100644 --- a/libmemcached/flush.cc +++ b/libmemcached/flush.cc @@ -36,13 +36,12 @@ #include -static memcached_return_t memcached_flush_binary(memcached_st *ptr, +static memcached_return_t memcached_flush_binary(Memcached *ptr, time_t expiration, const bool reply) { protocol_binary_request_flush request= {}; - request.message.header.request.magic= (uint8_t)PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_FLUSH; request.message.header.request.extlen= 4; request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; @@ -53,7 +52,8 @@ static memcached_return_t memcached_flush_binary(memcached_st *ptr, for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { - memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); + memcached_instance_st* instance= memcached_instance_fetch(ptr, x); + initialize_binary_request(instance, request.message.header); if (reply) { @@ -77,16 +77,15 @@ static memcached_return_t memcached_flush_binary(memcached_st *ptr, { memcached_set_error(*instance, rrc, MEMCACHED_AT); } - memcached_io_reset(instance); rc= MEMCACHED_SOME_ERRORS; } } for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { - memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); + memcached_instance_st* instance= memcached_instance_fetch(ptr, x); - if (memcached_server_response_count(instance) > 0) + if (instance->response_count() > 0) { (void)memcached_response(instance, NULL, 0, NULL); } @@ -95,7 +94,7 @@ static memcached_return_t memcached_flush_binary(memcached_st *ptr, return rc; } -static memcached_return_t memcached_flush_textual(memcached_st *ptr, +static memcached_return_t memcached_flush_textual(Memcached *ptr, time_t expiration, const bool reply) { @@ -115,13 +114,13 @@ static memcached_return_t memcached_flush_textual(memcached_st *ptr, memcached_return_t rc= MEMCACHED_SUCCESS; for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { - memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); + memcached_instance_st* instance= memcached_instance_fetch(ptr, x); libmemcached_io_vector_st vector[]= { { NULL, 0 }, { memcached_literal_param("flush_all ") }, - { buffer, send_length }, + { buffer, size_t(send_length) }, { " noreply", reply ? 0 : memcached_literal_param_size(" noreply") }, { memcached_literal_param("\r\n") } }; @@ -147,8 +146,9 @@ static memcached_return_t memcached_flush_textual(memcached_st *ptr, return rc; } -memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration) +memcached_return_t memcached_flush(memcached_st *shell, time_t expiration) { + Memcached* ptr= memcached2Memcached(shell); memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr, true))) {