Skip to content

Commit

Permalink
cproxy_max_retries() helper func
Browse files Browse the repository at this point in the history
Change-Id: I2d7ce84693d728646a9253a291d1b9de3e981b7c
Reviewed-on: http://review.northscale.com/1972
Reviewed-by: Dustin Sallings <dustin@spy.net>
Tested-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information
steveyen committed Aug 17, 2010
1 parent b7a208f commit f76dee5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion cproxy.c
Expand Up @@ -752,7 +752,7 @@ bool cproxy_release_downstream(downstream *d, bool force) {
//
// TODO: Add a stat for retrying.
//
int max_retries = mcs_server_count(&d->mst) * 2;
int max_retries = cproxy_max_retries(d);

if (d->upstream_retries <= max_retries) {
if (settings.verbose > 2) {
Expand Down Expand Up @@ -2381,3 +2381,8 @@ void cproxy_upstream_state_change(conn *c, enum conn_states next_state) {
}
}
}

int cproxy_max_retries(downstream *d) {
return mcs_server_count(&d->mst) * 2;
}

2 changes: 2 additions & 0 deletions cproxy.h
Expand Up @@ -479,6 +479,8 @@ int downstream_conn_index(downstream *d, conn *c);

void cproxy_dump_header(int prefix, char *bb);

int cproxy_max_retries(downstream *d);

// ---------------------------------------------------------------

void cproxy_process_upstream_ascii(conn *c, char *line);
Expand Down
2 changes: 1 addition & 1 deletion cproxy_protocol_a2b.c
Expand Up @@ -1607,7 +1607,7 @@ bool a2b_not_my_vbucket(conn *uc, conn *c,
// As long as the upstream is still open and we haven't
// retried too many times already.
//
int max_retries = (mcs_server_count(&d->mst) * 2);
int max_retries = cproxy_max_retries(d);

if (uc->cmd_retries < max_retries) {
uc->cmd_retries++;
Expand Down
2 changes: 1 addition & 1 deletion cproxy_protocol_b2b.c
Expand Up @@ -458,7 +458,7 @@ void cproxy_process_b2b_downstream_nread(conn *c) {
// As long as the upstream is still open and we haven't
// retried too many times already.
//
int max_retries = (mcs_server_count(&d->mst) * 2);
int max_retries = cproxy_max_retries(d);

if (uc->cmd_retries < max_retries) {
uc->cmd_retries++;
Expand Down

0 comments on commit f76dee5

Please sign in to comment.