From: Brian Aker Date: Sun, 14 Oct 2007 01:46:45 +0000 (-0700) Subject: Update for async delete. X-Git-Tag: 0_7~35^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=271ee75d2e4206ad7f22493a8fb9f65673a9ecf5;p=m6w6%2Flibmemcached Update for async delete. --- 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); }