summaryrefslogtreecommitdiff
path: root/proxy_await.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2023-01-13 15:22:26 -0800
committerdormando <dormando@rydia.net>2023-02-24 17:43:54 -0800
commit6442017c545a2a5ad076697b8695cd64bd32b542 (patch)
treea95c5443a72f5cfbe5b1c32fe5cf552da3201b0c /proxy_await.c
parent833a7234bbaed264a9973141850a23df4eb1b939 (diff)
downloadmemcached-6442017c545a2a5ad076697b8695cd64bd32b542.tar.gz
proxy: allow workers to run IO optionally
`mcp.pool(p, { dist = etc, iothread = true }` By default the IO thread is not used; instead a backend connection is created for each worker thread. This can be overridden by setting `iothread = true` when creating a pool. `mcp.pool(p, { dist = etc, beprefix = "etc" }` If a `beprefix` is added to pool arguments, it will create unique backend connections for this pool. This allows you to create multiple sockets per backend by making multiple pools with unique prefixes. There are legitimate use cases for sharing backend connections across different pools, which is why that is the default behavior.
Diffstat (limited to 'proxy_await.c')
-rw-r--r--proxy_await.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/proxy_await.c b/proxy_await.c
index b0a4dee..d5e40d3 100644
--- a/proxy_await.c
+++ b/proxy_await.c
@@ -259,7 +259,11 @@ int mcplib_await_run(conn *c, mc_resp *resp, lua_State *L, int coro_ref) {
const char *key = MCP_PARSER_KEY(rq->pr);
size_t len = rq->pr.klen;
int n = 0;
- bool await_first = true;
+ // TODO (v3) await_first is used as a marker for upping the "wait for
+ // IO's" queue count, which means we need to force it off if we're in
+ // background mode, else we would accidentally wait for a response anyway.
+ // This note is for finding a less convoluted method for this.
+ bool await_first = (aw->type == AWAIT_BACKGROUND) ? false : true;
// loop arg table and run each hash selector
lua_pushnil(L); // -> 3
while (lua_next(L, 1) != 0) {
@@ -269,11 +273,10 @@ int mcplib_await_run(conn *c, mc_resp *resp, lua_State *L, int coro_ref) {
if (pp == NULL) {
proxy_lua_error(L, "mcp.await must be supplied with a pool");
}
- mcp_pool_t *p = pp->main;
// NOTE: rq->be is only held to help pass the backend into the IOP in
// mcp_queue call. Could be a local variable and an argument too.
- rq->be = mcplib_pool_proxy_call_helper(L, p, key, len);
+ rq->be = mcplib_pool_proxy_call_helper(L, pp, key, len);
mcp_queue_await_io(c, L, rq, await_ref, await_first);
await_first = false;