Skip to content

Commit

Permalink
proxy: fix trailingdata error with ascii multiget
Browse files Browse the repository at this point in the history
One of the side effects of pre-warming all of the tests I did with
multiget, and not having done a second round on the unit tests, is that
we somehow never tried an ascii multiget against a damn miss.

Easy to test, easy to fix.
  • Loading branch information
dormando committed Mar 1, 2023
1 parent b72d969 commit 1a68343
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions proxy_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,11 @@ static int proxy_backend_drive_machine(mcp_backend_t *be) {

if (p->ascii_multiget && r->resp.type == MCMC_RESP_END) {
// Ascii multiget hack mode; consume END's
be->rbufused -= r->resp.reslen;
if (be->rbufused > 0) {
memmove(be->rbuf, be->rbuf+r->resp.reslen, be->rbufused);
}

be->state = mcp_backend_next;
break;
}
Expand Down
15 changes: 15 additions & 0 deletions t/proxyunits.t
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,21 @@ check_version($ps);
is(scalar <$ps>, "$key\r\n", "multiget value $key");
}
is(scalar <$ps>, "END\r\n", "final END from multiget");

# Test multiget workaround with misses (known bug)
print $ps $cmd;
is(scalar <$be>, "get /b/c\r\n", "multiget breakdown c");
is(scalar <$be>, "get /b/b\r\n", "multiget breakdown b");
is(scalar <$be>, "get /b/a\r\n", "multiget breakdown a");

print $be "END\r\nEND\r\nEND\r\n";
is(scalar <$ps>, "END\r\n", "final END from multiget");

# If bugged, the backend will have closed.
print $ps "get /b/a\r\n";
is(scalar <$be>, "get /b/a\r\n", "get works after empty multiget");
print $be "END\r\n";
is(scalar <$ps>, "END\r\n", "end after empty multiget");
}

check_version($ps);
Expand Down

0 comments on commit 1a68343

Please sign in to comment.