Hi Adis, I missed this one. Thierry, I *think* it's OK, are you OK with me merging it ?
Willy On Mon, Jun 05, 2017 at 05:37:23PM +0200, Adis Nezirovic wrote: > Hi guys, > > While playing with Lua API I've noticed that core.proxies attribute > doesn't return all the proxies, more precisely the ones with same names > (e.g. for frontend and backend with the same name it would only return > the latter one). > > Here is a patch which tries to fix that, avoiding using the proxy name > as a key for Lua table. > We use a plain integer offsets (starting from 1) to create numerical > array/table iterable by both pairs() and ipairs() in Lua. > > The patch also applies cleanly to 1.7 branch. > > Best regards, > Adis > >From f201afcd5ec9790a40907ab24e089db28a9cb6f1 Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?Adis=20Nezirovi=C4=87?= <[email protected]> > Date: Mon, 5 Jun 2017 17:10:51 +0200 > Subject: [PATCH] BUG/MEDIUM: lua: Support proxies with identical names in > core.proxies > > When we have frontends/backends with identical names, core.proxies > returns only the last one, using proxy->id (i.e. proxy name) to insert > the value in Lua table. We should add them to numerical array/table, to > be able to access all proxies. > --- > src/hlua_fcn.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c > index 8406bfe5..89bf0b3f 100644 > --- a/src/hlua_fcn.c > +++ b/src/hlua_fcn.c > @@ -893,6 +893,7 @@ int hlua_proxy_shut_bcksess(lua_State *L) > int hlua_fcn_post_init(lua_State *L) > { > struct proxy *px; > + int index; > > /* get core array. */ > if (lua_getglobal(L, "core") != LUA_TTABLE) > @@ -903,8 +904,9 @@ int hlua_fcn_post_init(lua_State *L) > lua_newtable(L); > > /* List all proxies. */ > + index = 1; > for (px = proxy; px; px = px->next) { > - lua_pushstring(L, px->id); > + lua_pushinteger(L, index++); > hlua_fcn_new_proxy(L, px); > lua_settable(L, -3); > } > -- > 2.13.0 >

