Skip to content

Commit

Permalink
router: ensure route using doesn't modify metric, PR #282
Browse files Browse the repository at this point in the history
This is an alternative take to the original PR.  Instead of having
ch_get_nodes copy the metric into the destinations struct
(undocumented), perform the copy in router_route_intern, like for all
other cases.  This is more transparent, and ensures that the correct
metric is added to the send queue.
  • Loading branch information
grobian committed Jul 19, 2017
1 parent d993fa6 commit 0cf430b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
regex matching slow on glibc due to lock contention
* [Issue #287](https://github.com/grobian/carbon-c-relay/issues/287)
unexpected warning about rejected socket bufsize
* [PR #282](https://github.com/grobian/carbon-c-relay/pull/282)
route using should not change the metric key sent


# 3.1 (29-04-2017)
Expand Down
2 changes: 0 additions & 2 deletions consistent-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ ch_get_nodes(
j = jump_bucketpos(hash, i);

(*ret).dest = bcklst[j];
(*ret).metric = strdup(metric);
ret++;

if (--pos == 0)
Expand Down Expand Up @@ -403,7 +402,6 @@ ch_get_nodes(
continue;
}
ret[i].dest = ring->entrylist[t].server;
ret[i].metric = strdup(metric);
}
}

Expand Down
5 changes: 3 additions & 2 deletions router.c
Original file line number Diff line number Diff line change
Expand Up @@ -2521,6 +2521,7 @@ router_route_intern(
case CARBON_CH:
case FNV1A_CH:
case JUMP_CH: {
size_t i;
/* let the ring(bearer) decide */
failif(retsize,
*curlen + d->cl->members.ch->repl_factor);
Expand All @@ -2544,7 +2545,8 @@ router_route_intern(
d->cl->members.ch->repl_factor,
w->masq ? newmetric : metric,
w->masq ? newfirstspace : firstspace);
*curlen += d->cl->members.ch->repl_factor;
for (i = 0; i < d->cl->members.ch->repl_factor; i++)
ret[(*curlen)++].metric = strdup(metric);
wassent = 1;
} break;
case AGGREGATION: {
Expand Down Expand Up @@ -2903,7 +2905,6 @@ router_test_intern(char *metric, char *firstspace, route *routes)
fprintf(stdout, " %s:%d\n",
serverip(dst[i].dest),
server_port(dst[i].dest));
free((char *)dst[i].metric);
}
} break;
case FAILOVER:
Expand Down

0 comments on commit 0cf430b

Please sign in to comment.