summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDustin Sallings <dustin@spy.net>2009-03-10 08:48:53 -0700
committerDustin Sallings <dustin@spy.net>2009-03-10 12:59:14 -0700
commit0a77fdfacfd6f3b860b9f30d407f6eb048c51325 (patch)
tree348459ecb0936be6750f890a4cf8f4055eefe299
parent9d274fde124ec8f87ff9b136b9a1f12b598ee8a8 (diff)
downloadmemcached-0a77fdfacfd6f3b860b9f30d407f6eb048c51325.tar.gz
Have just one field for a connection's current cmd.
316 -> 312
-rw-r--r--memcached.c28
-rw-r--r--memcached.h3
2 files changed, 15 insertions, 16 deletions
diff --git a/memcached.c b/memcached.c
index 8922a08..bc84375 100644
--- a/memcached.c
+++ b/memcached.c
@@ -824,13 +824,13 @@ static void out_string(conn *c, const char *str) {
/*
* we get here after reading the value in set/add/replace commands. The command
- * has been stored in c->item_comm, and the item is ready in c->item.
+ * has been stored in c->cmd, and the item is ready in c->item.
*/
static void complete_nread_ascii(conn *c) {
assert(c != NULL);
item *it = c->item;
- int comm = c->item_comm;
+ int comm = c->cmd;
enum store_item_type ret;
pthread_mutex_lock(&c->thread->stats.mutex);
@@ -844,7 +844,7 @@ static void complete_nread_ascii(conn *c) {
#ifdef ENABLE_DTRACE
uint64_t cas = ITEM_get_cas(it);
- switch (c->item_comm) {
+ switch (c->cmd) {
case NREAD_ADD:
MEMCACHED_COMMAND_ADD(c->sfd, ITEM_key(it), it->nkey,
(ret == 1) ? it->nbytes : -1, cas);
@@ -1139,11 +1139,11 @@ static void complete_update_bin(conn *c) {
*(ITEM_data(it) + it->nbytes - 2) = '\r';
*(ITEM_data(it) + it->nbytes - 1) = '\n';
- ret = store_item(it, c->item_comm, c);
+ ret = store_item(it, c->cmd, c);
#ifdef ENABLE_DTRACE
uint64_t cas = ITEM_get_cas(it);
- switch (c->item_comm) {
+ switch (c->cmd) {
case NREAD_ADD:
MEMCACHED_COMMAND_ADD(c->sfd, ITEM_key(it), it->nkey,
(ret == STORED) ? it->nbytes : -1, cas);
@@ -1179,9 +1179,9 @@ static void complete_update_bin(conn *c) {
write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0);
break;
case NOT_STORED:
- if (c->item_comm == NREAD_ADD) {
+ if (c->cmd == NREAD_ADD) {
eno = PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS;
- } else if(c->item_comm == NREAD_REPLACE) {
+ } else if(c->cmd == NREAD_REPLACE) {
eno = PROTOCOL_BINARY_RESPONSE_KEY_ENOENT;
} else {
eno = PROTOCOL_BINARY_RESPONSE_NOT_STORED;
@@ -1662,20 +1662,20 @@ static void process_bin_update(conn *c) {
switch (c->cmd) {
case PROTOCOL_BINARY_CMD_ADD:
- c->item_comm = NREAD_ADD;
+ c->cmd = NREAD_ADD;
break;
case PROTOCOL_BINARY_CMD_SET:
- c->item_comm = NREAD_SET;
+ c->cmd = NREAD_SET;
break;
case PROTOCOL_BINARY_CMD_REPLACE:
- c->item_comm = NREAD_REPLACE;
+ c->cmd = NREAD_REPLACE;
break;
default:
assert(0);
}
if (ITEM_get_cas(it) != 0) {
- c->item_comm = NREAD_CAS;
+ c->cmd = NREAD_CAS;
}
c->item = it;
@@ -1722,10 +1722,10 @@ static void process_bin_append_prepend(conn *c) {
switch (c->cmd) {
case PROTOCOL_BINARY_CMD_APPEND:
- c->item_comm = NREAD_APPEND;
+ c->cmd = NREAD_APPEND;
break;
case PROTOCOL_BINARY_CMD_PREPEND:
- c->item_comm = NREAD_PREPEND;
+ c->cmd = NREAD_PREPEND;
break;
default:
assert(0);
@@ -2665,7 +2665,7 @@ static void process_update_command(conn *c, token_t *tokens, const size_t ntoken
c->item = it;
c->ritem = ITEM_data(it);
c->rlbytes = it->nbytes;
- c->item_comm = comm;
+ c->cmd = comm;
conn_set_state(c, conn_nread);
}
diff --git a/memcached.h b/memcached.h
index ba613d3..2378848 100644
--- a/memcached.h
+++ b/memcached.h
@@ -266,7 +266,6 @@ struct conn {
*/
void *item; /* for commands set/add/replace */
- int item_comm; /* which one is it: set/add/replace */
/* data for the swallow state */
int sbytes; /* how many bytes to swallow */
@@ -306,7 +305,7 @@ struct conn {
/* This is where the binary header goes */
protocol_binary_request_header binary_header;
uint64_t cas; /* the cas to return */
- short cmd;
+ short cmd; /* current command being processed */
int opaque;
int keylen;
conn *next; /* Used for generating a list of conn structures */