[PATCH] Fix delete to accept both optional <time> and 'noreply'.

Tomash Brechko tomash.brechko at gmail.com
Fri Nov 9 12:59:17 UTC 2007


The fix is a bit ugly, but this is the cost of positional parameters ;).
---
 trunk/server/memcached.c |    2 +-
 trunk/server/t/noreply.t |    9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/trunk/server/memcached.c b/trunk/server/memcached.c
index 5a30251..6054f04 100644
--- a/trunk/server/memcached.c
+++ b/trunk/server/memcached.c
@@ -1461,7 +1461,7 @@ static void process_delete_command(conn *c, token_t *tokens, const size_t ntoken
         return;
     }
 
-    if(ntokens == 4) {
+    if(ntokens == (c->noreply ? 5 : 4)) {
         exptime = strtol(tokens[2].value, NULL, 10);
 
         if(errno == ERANGE) {
diff --git a/trunk/server/t/noreply.t b/trunk/server/t/noreply.t
index 0a0b8c5..b4dde02 100644
--- a/trunk/server/t/noreply.t
+++ b/trunk/server/t/noreply.t
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
 use strict;
-use Test::More tests => 9;
+use Test::More tests => 10;
 use FindBin qw($Bin);
 use lib "$Bin/lib";
 use MemcachedTest;
@@ -43,3 +43,10 @@ mem_get_is($sock, "noreply:foo", "7");
 
 print $sock "delete noreply:foo noreply\r\n";
 mem_get_is($sock, "noreply:foo");
+
+# Test that delete accepts both <time> and 'noreply'.
+print $sock "add noreply:foo 0 0 1 noreply\r\n1\r\n";
+print $sock "delete noreply:foo 10 noreply\r\n";
+print $sock "add noreply:foo 0 0 1 noreply\r\n1\r\n";
+# undef result means we couldn't add an entry because the key is locked.
+mem_get_is($sock, "noreply:foo");
-- 
1.5.3.5.529.ge3d6d


More information about the memcached mailing list