diff options
author | dormando <dormando@rydia.net> | 2022-08-23 15:59:46 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2022-08-23 15:59:46 -0700 |
commit | acb89505d3361d025be112a958a0c45ece0135fd (patch) | |
tree | e044b4bbcb01c91cfe51484511cfac15a5a15dd9 /proxy_lua.c | |
parent | e183fa37d7bbabd6499b73afcc39e2c579bebfae (diff) | |
download | memcached-acb89505d3361d025be112a958a0c45ece0135fd.tar.gz |
proxy: allow mcp.pool to ignore a nil second arg
just helps make the lua cleaner. if you pass in a non-nil wrong second
argument it'll still error out.
Diffstat (limited to 'proxy_lua.c')
-rw-r--r-- | proxy_lua.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/proxy_lua.c b/proxy_lua.c index d0b0702..66b0296 100644 --- a/proxy_lua.c +++ b/proxy_lua.c @@ -366,7 +366,9 @@ static int mcplib_pool(lua_State *L) { s->ref = luaL_ref(L, LUA_REGISTRYINDEX); // references and pops object. } - if (argc == 1) { + // Allow passing an ignored nil as a second argument. Makes the lua easier + int type = lua_type(L, 2); + if (argc == 1 || type == LUA_TNIL) { lua_getglobal(L, "mcp"); // TODO (v2): decide on a mcp.default_dist and use that instead if (lua_getfield(L, -1, "dist_jump_hash") != LUA_TNIL) { |