diff options
author | dormando <dormando@rydia.net> | 2023-02-14 17:57:09 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2023-02-14 17:57:09 -0800 |
commit | 58f81a51772163d641bc91b9af07756acad98bce (patch) | |
tree | 42a28c15b3223e4dca351186fd88eb252fa7c44a /proto_proxy.c | |
parent | 3722d0d12be07ede1a8c3081c2e8e0a4c2b477b5 (diff) | |
download | memcached-58f81a51772163d641bc91b9af07756acad98bce.tar.gz |
proxy: fix partial responses on backend timeouts
Response object error conditions were not being checked before looking
at the response buffer. If a response was partially filled then the
backend timed out, a partial response could be sent intead of the
proper backend error.
Diffstat (limited to 'proto_proxy.c')
-rw-r--r-- | proto_proxy.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/proto_proxy.c b/proto_proxy.c index feeddc9..535800d 100644 --- a/proto_proxy.c +++ b/proto_proxy.c @@ -548,7 +548,9 @@ int proxy_run_coroutine(lua_State *Lc, mc_resp *resp, io_pending_proxy_t *p, con if (type == LUA_TUSERDATA) { mcp_resp_t *r = luaL_checkudata(Lc, 1, "mcp.response"); _set_noreply_mode(resp, r); - if (r->buf) { + if (r->status != MCMC_OK) { + proxy_out_errstring(resp, "backend failure"); + } else if (r->buf) { // response set from C. // FIXME (v2): write_and_free() ? it's a bit wrong for here. resp->write_and_free = r->buf; @@ -562,8 +564,6 @@ int proxy_run_coroutine(lua_State *Lc, mc_resp *resp, io_pending_proxy_t *p, con memcpy(resp->wbuf, s, l); resp_add_iov(resp, resp->wbuf, l); lua_pop(Lc, 1); - } else if (r->status != MCMC_OK) { - proxy_out_errstring(resp, "backend failure"); } else { // Empty response: used for ascii multiget emulation. } |