Skip to content

Commit

Permalink
default downstream_retry is 1
Browse files Browse the repository at this point in the history
Otherwise moxi_mock.py tests fail, due to situation described in comments
in cproxy_on_close_downstream_conn(), where moxi doesn't notice until
very late that a connection is closed and unusable.
  • Loading branch information
steveyen committed May 23, 2009
1 parent feb04a8 commit 1021a58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions cproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ void cproxy_on_close_downstream_conn(conn *c) {
c->extra = NULL;

int n = memcached_server_count(&d->mst);
int k = -1; // Index of conn.

for (int i = 0; i < n; i++) {
if (d->downstream_conns[i] == c) {
Expand All @@ -415,6 +416,8 @@ void cproxy_on_close_downstream_conn(conn *c) {
assert(d->mst.hosts[i].fd == c->sfd);
memcached_quit_server(&d->mst.hosts[i], 1);
assert(d->mst.hosts[i].fd == -1);

k = i;
}
}

Expand Down Expand Up @@ -447,7 +450,8 @@ void cproxy_on_close_downstream_conn(conn *c) {
// ending up here. That is, drive_machine only
// seems to move to conn_closing from conn_read.
//
// If we haven't received any reply yet, we retry once.
// If we haven't received any reply yet, we retry based
// on our cmd_retries counter.
//
// TODO: Reconsider retry behavior, is it right in all situations?
//
Expand All @@ -457,9 +461,8 @@ void cproxy_on_close_downstream_conn(conn *c) {
d->downstream_used_start == 1 &&
d->upstream_conn->next == NULL &&
d->behaviors != NULL) {
int i = downstream_conn_index(d, c);
if (i >= 0 && i < d->behaviors_num) {
int retry_max = d->behaviors[i].downstream_retry;
if (k >= 0 && k < d->behaviors_num) {
int retry_max = d->behaviors[k].downstream_retry;
if (d->upstream_conn->cmd_retries < retry_max) {
d->upstream_conn->cmd_retries++;
uc_retry = d->upstream_conn;
Expand Down
2 changes: 1 addition & 1 deletion cproxy_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ proxy_behavior behavior_default_g = {
.cycle = 0,
.downstream_max = 1,
.downstream_weight = 0,
.downstream_retry = 0,
.downstream_retry = 1,
.downstream_protocol = proxy_downstream_ascii_prot,
.downstream_timeout = {
.tv_sec = 0,
Expand Down

0 comments on commit 1021a58

Please sign in to comment.