Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding changes for binary protocol when key with getl is not found

This is related to change ID Ib1114094064e1bb7cc9ae42e412f3ab3a934fe0c.
Extending the same fix for binary protocol.

Change-Id: Ibee2df61a726b70330104353097b528730b874fa
Reviewed-on: http://review.couchbase.org/9690
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information...
commit d5076d9c4ee8aeac1b5b00383eb059313e315638 1 parent a6fae63
@nimishzynga nimishzynga authored steveyen committed
Showing with 34 additions and 23 deletions.
  1. +34 −23 cproxy_protocol_a2b.c
View
57 cproxy_protocol_a2b.c
@@ -799,33 +799,44 @@ void a2b_process_downstream_response(conn *c) {
}
if (c->noreply == false) {
- if (status == 0) {
- assert(it != NULL);
- assert(it->nbytes >= 2);
- assert(extlen > 0);
+ switch (status) {
+ case PROTOCOL_BINARY_RESPONSE_SUCCESS:
+ assert(it != NULL);
+ assert(it->nbytes >= 2);
+ assert(extlen > 0);
- if (bodylen >= keylen + extlen) {
- *(ITEM_data(it) + it->nbytes - 2) = '\r';
- *(ITEM_data(it) + it->nbytes - 1) = '\n';
+ if (bodylen >= keylen + extlen) {
+ *(ITEM_data(it) + it->nbytes - 2) = '\r';
+ *(ITEM_data(it) + it->nbytes - 1) = '\n';
- cproxy_upstream_ascii_item_response(it, uc, -1);
- } else {
- assert(false); // TODO.
- }
+ cproxy_upstream_ascii_item_response(it, uc, -1);
+ } else {
+ assert(false); // TODO.
+ }
item_remove(it);
- } else if (PROTOCOL_BINARY_CMD_GETL == c->cmd &&
- (status == PROTOCOL_BINARY_RESPONSE_ETMPFAIL ||
- status == PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND)) {
- /*
- * currently membase does not send ETMPFAIL for
- * engine error code for ENGINE_TMPFAIL
- */
- d->upstream_suffix = "LOCK_ERROR\r\n";
- d->upstream_suffix_len = 0;
- d->upstream_status = status;
- d->upstream_retry = 0;
- d->target_host_ident = NULL;
+ break;
+
+ case PROTOCOL_BINARY_RESPONSE_ETMPFAIL:
+ case PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND:
+ /*
+ * currently membase does not send ETMPFAIL for
+ * engine error code for ENGINE_TMPFAIL
+ */
+ d->upstream_suffix = "LOCK_ERROR\r\n";
+ d->upstream_suffix_len = 0;
+ d->upstream_status = status;
+ d->upstream_retry = 0;
+ d->target_host_ident = NULL;
+ break;
+
+ case PROTOCOL_BINARY_RESPONSE_KEY_ENOENT:
+ d->upstream_suffix = "NOT_FOUND\r\n";
+ d->upstream_suffix_len = 0;
+ d->upstream_status = status;
+ d->upstream_retry = 0;
+ d->target_host_ident = NULL;
+ break;
}
conn_set_state(c, conn_pause);
Please sign in to comment.
Something went wrong with that request. Please try again.