Skip to content

Commit

Permalink
Allow a delete duration of 0.
Browse files Browse the repository at this point in the history
This change covers the case where a reply is requested.  A separate,
more complicated change mixes in noreplys and 0 duration deletes.
  • Loading branch information
dustin authored and dormando committed Nov 27, 2009
1 parent 51d5489 commit 6436b96
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -2883,7 +2883,8 @@ static void process_delete_command(conn *c, token_t *tokens, const size_t ntoken
assert(c != NULL);

if (ntokens == 4) {
if (!set_noreply_maybe(c, tokens, ntokens)) {
if (strcmp(tokens[KEY_TOKEN+1].value, "0") != 0
&& !set_noreply_maybe(c, tokens, ntokens)) {
out_string(c, "CLIENT_ERROR bad command line format. "
"Usage: delete <key> [noreply]");
return;
Expand Down
20 changes: 20 additions & 0 deletions t/issue_108.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/perl

use strict;
use Test::More tests => 3;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;

my $server = new_memcached();
my $sock = $server->sock;
my $key = "del_key";

print $sock "add $key 0 0 1\r\nx\r\n";
is (scalar <$sock>, "STORED\r\n", "Added a key");

print $sock "delete $key 0\r\n";
is (scalar <$sock>, "DELETED\r\n", "Properly deleted with 0");

print $sock "add $key 0 0 1\r\nx\r\n";
is (scalar <$sock>, "STORED\r\n", "Added again a key");

0 comments on commit 6436b96

Please sign in to comment.