From 271ee75d2e4206ad7f22493a8fb9f65673a9ecf5 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sat, 13 Oct 2007 18:46:45 -0700 Subject: [PATCH] Update for async delete. --- lib/memcached_delete.c | 22 +++++++++++++++++----- tests/test.c | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/memcached_delete.c b/lib/memcached_delete.c index ff085453..6a849533 100644 --- a/lib/memcached_delete.c +++ b/lib/memcached_delete.c @@ -3,6 +3,7 @@ memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_length, time_t expiration) { + char to_write; size_t send_length, sent_length; memcached_return rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; @@ -30,18 +31,29 @@ memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_lengt goto error; } - sent_length= memcached_io_write(ptr, server_key, buffer, send_length, 1); + if ((ptr->flags & MEM_NO_BLOCK)) + to_write= 0; + else + to_write= 1; - if (sent_length == -1 || sent_length != send_length) + if ((sent_length= memcached_io_write(ptr, server_key, buffer, send_length, to_write)) == -1) { + memcached_quit_server(ptr, server_key); rc= MEMCACHED_WRITE_FAILURE; goto error; } - rc= memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, server_key); - - if (rc == MEMCACHED_DELETED) + if ((ptr->flags & MEM_NO_BLOCK)) + { rc= MEMCACHED_SUCCESS; + memcached_server_response_increment(ptr, server_key); + } + else + { + rc= memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, server_key); + if (rc == MEMCACHED_DELETED) + rc= MEMCACHED_SUCCESS; + } LIBMEMCACHED_MEMCACHED_DELETE_END(); diff --git a/tests/test.c b/tests/test.c index 755455f6..4e5369d6 100644 --- a/tests/test.c +++ b/tests/test.c @@ -101,6 +101,7 @@ void delete_test(memcached_st *memc) assert(rc == MEMCACHED_SUCCESS); rc= memcached_delete(memc, key, strlen(key), (time_t)0); + WATCHPOINT_ERROR(rc); assert(rc == MEMCACHED_SUCCESS); } -- 2.30.2