Message ID | 20220221151850.127406-2-michael.adler@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/2] lua_swupdate: extend progress_connect method | expand |
On 21.02.22 16:18, Michael Adler wrote: > We do not auto-connect in the case of control() either, so this unifies > the API. Also, if we are interested in the connection handle, we would > need to call connect() anyway, which results in closing the original connection. > > Signed-off-by: Michael Adler <michael.adler@siemens.com> > --- > bindings/lua_swupdate.c | 17 +++-------------- > 1 file changed, 3 insertions(+), 14 deletions(-) > > diff --git a/bindings/lua_swupdate.c b/bindings/lua_swupdate.c > index e8cf8a7..74efad7 100644 > --- a/bindings/lua_swupdate.c > +++ b/bindings/lua_swupdate.c > @@ -338,28 +338,17 @@ static int progress_receive(lua_State *L) { > } > > static int progress(lua_State *L) { > - > - int connfd; > - > - connfd = progress_ipc_connect(WAIT); > - > - if (connfd < 0) { > - lua_pushnil(L); > - return 2; > - } > - > - /* allocate progress object */ > + /* allocate progress object */ I can do it, but I have to synchronize with : https://github.com/sbabic/SWUpdateGUI/blob/master/SWUpdateGUI.lua#L979 That means after merging these I have to update in SWUpdateGUI with: prog = sw:progress() prog->connect() Right ? > struct prog_obj *p = (struct prog_obj *) lua_newuserdata(L, sizeof(*p)); > - p->socket = connfd; > + p->socket = -1; > p->status = IDLE; > > /* set its type as master object */ > auxiliar_setclass(L, "swupdate_progress", -1); > > return 1; > - > } > - > + > static const luaL_Reg lua_swupdate[] = { > {"progress", progress}, > {"control", ctrl}, Regards, Stefano
Hi Stefano, > That means after merging these I have to update in SWUpdateGUI with: > prog = sw:progress() > prog->connect() correct, but : instead of ->. Further you can now check for an error condition, e.g. local prog = swupdate.prog() local fd, err = prog:connect() if not fd then print(err) end Kind regards, Michael
On 22.03.22 08:14, Michael Adler wrote: > Hi Stefano, > >> That means after merging these I have to update in SWUpdateGUI with: >> prog = sw:progress() >> prog->connect() > > correct, but : instead of ->. Of course ! > Further you can now check for an error condition, e.g. > > local prog = swupdate.prog() > local fd, err = prog:connect() > if not fd then print(err) end > Ok, I will take care of it, I will merge first your patches. Regards, Stefano > Kind regards, > Michael >
diff --git a/bindings/lua_swupdate.c b/bindings/lua_swupdate.c index e8cf8a7..74efad7 100644 --- a/bindings/lua_swupdate.c +++ b/bindings/lua_swupdate.c @@ -338,28 +338,17 @@ static int progress_receive(lua_State *L) { } static int progress(lua_State *L) { - - int connfd; - - connfd = progress_ipc_connect(WAIT); - - if (connfd < 0) { - lua_pushnil(L); - return 2; - } - - /* allocate progress object */ + /* allocate progress object */ struct prog_obj *p = (struct prog_obj *) lua_newuserdata(L, sizeof(*p)); - p->socket = connfd; + p->socket = -1; p->status = IDLE; /* set its type as master object */ auxiliar_setclass(L, "swupdate_progress", -1); return 1; - } - + static const luaL_Reg lua_swupdate[] = { {"progress", progress}, {"control", ctrl},
We do not auto-connect in the case of control() either, so this unifies the API. Also, if we are interested in the connection handle, we would need to call connect() anyway, which results in closing the original connection. Signed-off-by: Michael Adler <michael.adler@siemens.com> --- bindings/lua_swupdate.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)