Skip to content

Commit

Permalink
bug 1497 - setting OPAQUE_IGNORE_REPLY for simple ascii mutation cmds
Browse files Browse the repository at this point in the history
The OPAQUE_IGNORE_REPLY value was getting correctly marked for item-based
mutation ascii noreply cmds (like set, prepend/append, add/replace), but
incorrectly not for simple ascii noreply mutation cmds (like delete, incr/decr).

This commit refactors out a helper function (a2b_set_opaque) to fix that.

Change-Id: Icb7f43b729774abdc6d2e6a18bd0af85c83e5452
Reviewed-on: http://review.northscale.com/1231
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information
steveyen committed Jul 19, 2010
1 parent 6d39b49 commit 647bb38
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions cproxy_protocol_a2b.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ int a2b_multiget_start(conn *c, char *cmd, int cmd_len);
int a2b_multiget_skey(conn *c, char *skey, int skey_len, int vbucket, int key_index);
int a2b_multiget_end(conn *c);

void a2b_set_opaque(conn *c, protocol_binary_request_header *header, bool noreply);

void cproxy_init_a2b() {
memset(&req_noop, 0, sizeof(req_noop));

Expand Down Expand Up @@ -1271,6 +1273,8 @@ bool cproxy_forward_a2b_simple_downstream(downstream *d,
header->request.bodylen =
htonl(out_keylen + out_extlen);

a2b_set_opaque(c, header, uc->noreply);

add_iov(c, header, size);

if (out_key != NULL &&
Expand All @@ -1279,8 +1283,10 @@ bool cproxy_forward_a2b_simple_downstream(downstream *d,
}

if (settings.verbose > 2) {
fprintf(stderr, "forwarding a2b to %d, cmd %x, noreply %d, vbucket %d\n",
fprintf(stderr, "forwarding a2b to %d, cmd %x, noreply %d, vbucket %d",
c->sfd, header->request.opcode, uc->noreply, vbucket);

cproxy_dump_header(c->sfd, (char *) header);
}

conn_set_state(c, conn_mwrite);
Expand Down Expand Up @@ -1608,19 +1614,7 @@ bool cproxy_forward_a2b_item_downstream(downstream *d, short cmd,
break;
}

if (uc->noreply) {
// Set a magic opaque value during quiet commands that tells us later
// that we can ignore the downstream's error response messge,
// since the upstream ascii client doesn't want it.
//
req->request.opaque = htonl(OPAQUE_IGNORE_REPLY);

if (settings.verbose > 2) {
fprintf(stderr,
"%d: cproxy_forward_a2b_item_downstream OPAQUE_IGNORE_REPLY, cmdq: %x\n",
c->sfd, req->request.opcode);
}
}
a2b_set_opaque(c, req, uc->noreply);

if (cmd != NREAD_APPEND &&
cmd != NREAD_PREPEND) {
Expand Down Expand Up @@ -1688,3 +1682,18 @@ bool cproxy_forward_a2b_item_downstream(downstream *d, short cmd,
return false;
}

void a2b_set_opaque(conn *c, protocol_binary_request_header *header, bool noreply) {
if (noreply) {
// Set a magic opaque value during quiet commands that tells us later
// that we can ignore the downstream's error response messge,
// since the upstream ascii client doesn't want it.
//
header->request.opaque = htonl(OPAQUE_IGNORE_REPLY);

if (settings.verbose > 2) {
fprintf(stderr,
"%d: a2b_set_opaque OPAQUE_IGNORE_REPLY, cmdq: %x\n",
c->sfd, header->request.opcode);
}
}
}

0 comments on commit 647bb38

Please sign in to comment.