Skip to content

Commit

Permalink
Dynamic switching of downstream protocol
Browse files Browse the repository at this point in the history
Change-Id: Idf4fa06c071842d640034f303cbf44605586cbf5
Reviewed-on: http://review.northscale.com/2595
Tested-by: Steve Yen <steve.yen@gmail.com>
Reviewed-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information
mtaneja authored and steveyen committed Sep 21, 2010
1 parent d8579f0 commit 4a4da61
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 6 additions & 3 deletions cproxy.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions cproxy_protocol_a2a.c
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion memcached.h
Expand Up @@ -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;
};

Expand Down

0 comments on commit 4a4da61

Please sign in to comment.