Permalink
Browse files

Allow noreply mixed with 0 delay.

  • Loading branch information...
dustin authored and dormando committed Nov 24, 2009
1 parent 6436b96 commit 62a0cf9e0ba4592870b5e86e5cb2f79e1a78f9ba
Showing with 25 additions and 7 deletions.
  1. +8 −4 memcached.c
  2. +8 −1 t/issue_108.t
  3. +9 −2 t/issue_3.t
View
@@ -2882,15 +2882,19 @@ static void process_delete_command(conn *c, token_t *tokens, const size_t ntoken
assert(c != NULL);
if (ntokens == 4) {
if (strcmp(tokens[KEY_TOKEN+1].value, "0") != 0
&& !set_noreply_maybe(c, tokens, ntokens)) {
if (ntokens > 3) {
bool hold_is_zero = strcmp(tokens[KEY_TOKEN+1].value, "0") == 0;
bool sets_noreply = set_noreply_maybe(c, tokens, ntokens);
bool valid = (ntokens == 4 && (hold_is_zero || sets_noreply))
|| (ntokens == 5 && hold_is_zero && sets_noreply);
if (!valid) {
out_string(c, "CLIENT_ERROR bad command line format. "
"Usage: delete <key> [noreply]");
return;
}
}
key = tokens[KEY_TOKEN].value;
nkey = tokens[KEY_TOKEN].length;
@@ -2994,7 +2998,7 @@ static void process_command(conn *c, char *command) {
process_arithmetic_command(c, tokens, ntokens, 0);
} else if (ntokens >= 3 && ntokens <= 4 && (strcmp(tokens[COMMAND_TOKEN].value, "delete") == 0)) {
} else if (ntokens >= 3 && ntokens <= 5 && (strcmp(tokens[COMMAND_TOKEN].value, "delete") == 0)) {
process_delete_command(c, tokens, ntokens);
View
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
use Test::More tests => 3;
use Test::More tests => 4;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;
@@ -18,3 +18,10 @@ 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");
print $sock "delete $key 0 noreply\r\n";
# will not reply, but a subsequent add will succeed
print $sock "add $key 0 0 1\r\nx\r\n";
is (scalar <$sock>, "STORED\r\n", "Add succeeded after quiet deletion.");
View
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
use Test::More tests => 7;
use Test::More tests => 8;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;
@@ -17,8 +17,15 @@ print $sock "delete $key 10\r\n";
is (scalar <$sock>, "CLIENT_ERROR bad command line format."
. " Usage: delete <key> [noreply]\r\n", "invalid delete");
print $sock "add $key 0 0 1\r\nx\r\n";
is (scalar <$sock>, "STORED\r\n", "Add before a broken delete.");
print $sock "delete $key 10 noreply\r\n";
is (scalar <$sock>, "ERROR\r\n", "Even more invalid delete");
# Does not reply
# is (scalar <$sock>, "ERROR\r\n", "Even more invalid delete");
print $sock "add $key 0 0 1\r\nx\r\n";
is (scalar <$sock>, "NOT_STORED\r\n", "Failed to add after failed silent delete.");
print $sock "delete $key noreply\r\n";
# Will not reply, so let's do a set and check that.

0 comments on commit 62a0cf9

Please sign in to comment.