summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2011-09-27 01:29:39 -0700
committerdormando <dormando@rydia.net>2011-09-27 01:29:39 -0700
commit0d16e8c0176d720613b8d4122bd63e3718c996a9 (patch)
treee7e974a824decee09af272e32fb774b679794e92
parentd87f568a95ed1abe468188476fa5ed9288799223 (diff)
downloadmemcached-0d16e8c0176d720613b8d4122bd63e3718c996a9.tar.gz
Add binary GATK/GATKQ
Apparently nothing tests GETK/GETKQ, so tests still have to be added. 1.6 doesn't have GATK/GATKQ because the membase folks didn't need it. I'm adding them for completeness and because I don't want to argue about why people can't have it. If you're reading this, please use opaques :)
-rw-r--r--memcached.c26
-rw-r--r--protocol_binary.h6
-rwxr-xr-xt/binary.t2
-rw-r--r--testapp.c7
4 files changed, 37 insertions, 4 deletions
diff --git a/memcached.c b/memcached.c
index 8ac4f51..08bfbe9 100644
--- a/memcached.c
+++ b/memcached.c
@@ -1215,6 +1215,9 @@ static void process_bin_touch(conn *c) {
if (c->cmd == PROTOCOL_BINARY_CMD_TOUCH) {
bodylen -= it->nbytes - 2;
+ } else if (c->cmd == PROTOCOL_BINARY_CMD_GATK) {
+ bodylen += nkey;
+ keylen = nkey;
}
add_bin_header(c, 0, sizeof(rsp->message.body), keylen, bodylen);
@@ -1224,10 +1227,15 @@ static void process_bin_touch(conn *c) {
rsp->message.body.flags = htonl(strtoul(ITEM_suffix(it), NULL, 10));
add_iov(c, &rsp->message.body, sizeof(rsp->message.body));
+ if (c->cmd == PROTOCOL_BINARY_CMD_GATK) {
+ add_iov(c, ITEM_key(it), nkey);
+ }
+
/* Add the data minus the CRLF */
if (c->cmd != PROTOCOL_BINARY_CMD_TOUCH) {
add_iov(c, ITEM_data(it), it->nbytes - 2);
}
+
conn_set_state(c, conn_mwrite);
/* Remember this command so we can garbage collect it later */
c->item = it;
@@ -1242,7 +1250,16 @@ static void process_bin_touch(conn *c) {
if (c->noreply) {
conn_set_state(c, conn_new_cmd);
} else {
- write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0);
+ if (c->cmd == PROTOCOL_BINARY_CMD_GATK) {
+ char *ofs = c->wbuf + sizeof(protocol_binary_response_header);
+ add_bin_header(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT,
+ 0, nkey, nkey);
+ memcpy(ofs, key, nkey);
+ add_iov(c, ofs, nkey);
+ conn_set_state(c, conn_mwrite);
+ } else {
+ write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0);
+ }
}
}
@@ -1810,7 +1827,10 @@ static void dispatch_bin_command(conn *c) {
c->cmd = PROTOCOL_BINARY_CMD_GETK;
break;
case PROTOCOL_BINARY_CMD_GATQ:
- c->cmd = PROTOCOL_BINARY_CMD_GATQ;
+ c->cmd = PROTOCOL_BINARY_CMD_GAT;
+ break;
+ case PROTOCOL_BINARY_CMD_GATKQ:
+ c->cmd = PROTOCOL_BINARY_CMD_GAT;
break;
default:
c->noreply = false;
@@ -1916,6 +1936,8 @@ static void dispatch_bin_command(conn *c) {
case PROTOCOL_BINARY_CMD_TOUCH:
case PROTOCOL_BINARY_CMD_GAT:
case PROTOCOL_BINARY_CMD_GATQ:
+ case PROTOCOL_BINARY_CMD_GATK:
+ case PROTOCOL_BINARY_CMD_GATKQ:
if (extlen == 4 && keylen != 0) {
bin_read_key(c, bin_reading_touch_key, 4);
} else {
diff --git a/protocol_binary.h b/protocol_binary.h
index 4fd9df5..dfc59c8 100644
--- a/protocol_binary.h
+++ b/protocol_binary.h
@@ -108,6 +108,8 @@ extern "C"
PROTOCOL_BINARY_CMD_TOUCH = 0x1c,
PROTOCOL_BINARY_CMD_GAT = 0x1d,
PROTOCOL_BINARY_CMD_GATQ = 0x1e,
+ PROTOCOL_BINARY_CMD_GATK = 0x23,
+ PROTOCOL_BINARY_CMD_GATKQ = 0x24,
PROTOCOL_BINARY_CMD_SASL_LIST_MECHS = 0x20,
PROTOCOL_BINARY_CMD_SASL_AUTH = 0x21,
@@ -416,12 +418,16 @@ extern "C"
} protocol_binary_request_gat;
typedef protocol_binary_request_gat protocol_binary_request_gatq;
+ typedef protocol_binary_request_gat protocol_binary_request_gatk;
+ typedef protocol_binary_request_gat protocol_binary_request_gatkq;
/**
* Definition of the packet returned from the GAT(Q)
*/
typedef protocol_binary_response_get protocol_binary_response_gat;
typedef protocol_binary_response_get protocol_binary_response_gatq;
+ typedef protocol_binary_response_get protocol_binary_response_gatk;
+ typedef protocol_binary_response_get protocol_binary_response_gatkq;
/**
* Definition of a request for a range operation.
diff --git a/t/binary.t b/t/binary.t
index 349c5a9..838e948 100755
--- a/t/binary.t
+++ b/t/binary.t
@@ -44,6 +44,8 @@ use constant CMD_PREPENDQ => 0x1A;
use constant CMD_TOUCH => 0x1C;
use constant CMD_GAT => 0x1D;
use constant CMD_GATQ => 0x1E;
+use constant CMD_GATK => 0x23;
+use constant CMD_GATKQ => 0x24;
# REQ and RES formats are divided even though they currently share
# the same format, since they _could_ differ in the future.
diff --git a/testapp.c b/testapp.c
index 769a618..aba0b90 100644
--- a/testapp.c
+++ b/testapp.c
@@ -967,7 +967,8 @@ static void validate_response_header(protocol_binary_response_no_extras *respons
} else {
assert(response->message.header.response.cas == 0);
assert(response->message.header.response.extlen == 0);
- if (cmd != PROTOCOL_BINARY_CMD_GETK) {
+ if (cmd != PROTOCOL_BINARY_CMD_GETK &&
+ cmd != PROTOCOL_BINARY_CMD_GATK) {
assert(response->message.header.response.keylen == 0);
}
}
@@ -1597,7 +1598,7 @@ static enum test_return test_binary_stat(void) {
}
static enum test_return test_binary_illegal(void) {
- uint8_t cmd = 0x23;
+ uint8_t cmd = 0x25;
while (cmd != 0x00) {
union {
protocol_binary_request_no_extras request;
@@ -1704,6 +1705,8 @@ static enum test_return test_binary_pipeline_hickup_chunk(void *buffer, size_t b
case PROTOCOL_BINARY_CMD_TOUCH:
case PROTOCOL_BINARY_CMD_GAT:
case PROTOCOL_BINARY_CMD_GATQ:
+ case PROTOCOL_BINARY_CMD_GATK:
+ case PROTOCOL_BINARY_CMD_GATKQ:
len = touch_command(command.bytes, sizeof(command.bytes), cmd,
key, keylen, 10);
break;