diff --git a/cproxy.c b/cproxy.c index bf10871a..8705327a 100644 --- a/cproxy.c +++ b/cproxy.c @@ -1337,7 +1337,8 @@ conn *cproxy_connect_downstream_conn(downstream *d, thread->base, &cproxy_downstream_funcs, d); if (c != NULL ) { - c->protocol = behavior->downstream_protocol; + c->protocol = d->upstream_conn->peer_protocol ? + d->upstream_conn->peer_protocol : behavior->downstream_protocol; c->thread = thread; c->cmd_start_time = start; @@ -1695,7 +1696,8 @@ bool cproxy_forward(downstream *d) { if (IS_ASCII(d->upstream_conn->protocol)) { // ASCII upstream. // - if (IS_ASCII(d->ptd->behavior_pool.base.downstream_protocol)) { + if (IS_ASCII(d->ptd->behavior_pool.base.downstream_protocol) || + IS_ASCII(d->upstream_conn->peer_protocol)) { return cproxy_forward_a2a_downstream(d); } else { return cproxy_forward_a2b_downstream(d); @@ -2929,7 +2931,8 @@ conn *zstored_acquire_downstream_conn(downstream *d, char host_ident_buf[300]; format_host_ident(host_ident_buf, sizeof(host_ident_buf), msst, - behavior->downstream_protocol); + (d->upstream_conn->peer_protocol ? + d->upstream_conn->peer_protocol : behavior->downstream_protocol)); conn *dc; diff --git a/cproxy_protocol_a2a.c b/cproxy_protocol_a2a.c index ca67d66c..7c48343b 100644 --- a/cproxy_protocol_a2a.c +++ b/cproxy_protocol_a2a.c @@ -346,6 +346,12 @@ bool cproxy_forward_a2a_simple_downstream(downstream *d, // bool self = false; + if (!strcmp(command, "version")) { + /* fake key for version command handling */ + key = "v"; + key_len = 1; + } + conn *c = cproxy_find_downstream_conn(d, key, key_len, &self); if (c != NULL) { diff --git a/memcached.h b/memcached.h index 50b487a2..e99a937b 100644 --- a/memcached.h +++ b/memcached.h @@ -489,7 +489,7 @@ struct conn { char *host_ident; // Uniquely identifies a memcached server, including // address:port and possibly optional bucket/usr/pwd info. char *peer_host; // this and the following two paramters are used for mcmux - int peer_protocol; // compatiblity mode + unsigned int peer_protocol; // compatiblity mode int peer_port; };