Message ID | 20201020112903.24417-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | progress: Handle all progress_ipc_receive() error conditions | expand |
On 20.10.20 13:29, Christian Storm wrote: > progress_ipc_receive() returns as error conditions > 0 on EAGAIN and > -1 if the read bytes count doesn't match sizeof(*msg). > The latter is handled, but the former also qualifies > as a (temporary) error. Hence, also don't process the > returned progress message in this case. > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > bindings/lua_swupdate.c | 2 +- > suricatta/server_general.c | 2 +- > tools/swupdate-progress.c | 2 +- > tools/swupdate-sysrestart.c | 2 +- > 4 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/bindings/lua_swupdate.c b/bindings/lua_swupdate.c > index 73be15c..2fa0b61 100644 > --- a/bindings/lua_swupdate.c > +++ b/bindings/lua_swupdate.c > @@ -297,7 +297,7 @@ static int progress_close(lua_State __attribute__ ((__unused__)) *L) { > static int progress_receive(lua_State *L) { > struct prog_obj *p = (struct prog_obj *) auxiliar_checkclass(L, "swupdate_progress", 1); > int connfd = p->socket; > - if (progress_ipc_receive(&connfd, &p->msg) == -1) { > + if (progress_ipc_receive(&connfd, &p->msg) <= 0) { > lua_pushnil(L); > return 2; > }; > diff --git a/suricatta/server_general.c b/suricatta/server_general.c > index 57c09a8..e7abe93 100644 > --- a/suricatta/server_general.c > +++ b/suricatta/server_general.c > @@ -287,7 +287,7 @@ static void *server_progress_thread (void *data) > continue; > } > > - if (progress_ipc_receive(&progfd, &msg) == -1) { > + if (progress_ipc_receive(&progfd, &msg) <= 0) { > continue; > } > > diff --git a/tools/swupdate-progress.c b/tools/swupdate-progress.c > index 077f5af..4391075 100644 > --- a/tools/swupdate-progress.c > +++ b/tools/swupdate-progress.c > @@ -244,7 +244,7 @@ int main(int argc, char **argv) > continue; > } > > - if (progress_ipc_receive(&connfd, &msg) == -1) { > + if (progress_ipc_receive(&connfd, &msg) <= 0) { > continue; > } > > diff --git a/tools/swupdate-sysrestart.c b/tools/swupdate-sysrestart.c > index 3f4e441..9a9a4ff 100644 > --- a/tools/swupdate-sysrestart.c > +++ b/tools/swupdate-sysrestart.c > @@ -183,7 +183,7 @@ int main(int argc, char **argv) > continue; > } > > - if (progress_ipc_receive(&connfd, &msg) == -1) { > + if (progress_ipc_receive(&connfd, &msg) <= 0) { > continue; > } > > Reviewed-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/bindings/lua_swupdate.c b/bindings/lua_swupdate.c index 73be15c..2fa0b61 100644 --- a/bindings/lua_swupdate.c +++ b/bindings/lua_swupdate.c @@ -297,7 +297,7 @@ static int progress_close(lua_State __attribute__ ((__unused__)) *L) { static int progress_receive(lua_State *L) { struct prog_obj *p = (struct prog_obj *) auxiliar_checkclass(L, "swupdate_progress", 1); int connfd = p->socket; - if (progress_ipc_receive(&connfd, &p->msg) == -1) { + if (progress_ipc_receive(&connfd, &p->msg) <= 0) { lua_pushnil(L); return 2; }; diff --git a/suricatta/server_general.c b/suricatta/server_general.c index 57c09a8..e7abe93 100644 --- a/suricatta/server_general.c +++ b/suricatta/server_general.c @@ -287,7 +287,7 @@ static void *server_progress_thread (void *data) continue; } - if (progress_ipc_receive(&progfd, &msg) == -1) { + if (progress_ipc_receive(&progfd, &msg) <= 0) { continue; } diff --git a/tools/swupdate-progress.c b/tools/swupdate-progress.c index 077f5af..4391075 100644 --- a/tools/swupdate-progress.c +++ b/tools/swupdate-progress.c @@ -244,7 +244,7 @@ int main(int argc, char **argv) continue; } - if (progress_ipc_receive(&connfd, &msg) == -1) { + if (progress_ipc_receive(&connfd, &msg) <= 0) { continue; } diff --git a/tools/swupdate-sysrestart.c b/tools/swupdate-sysrestart.c index 3f4e441..9a9a4ff 100644 --- a/tools/swupdate-sysrestart.c +++ b/tools/swupdate-sysrestart.c @@ -183,7 +183,7 @@ int main(int argc, char **argv) continue; } - if (progress_ipc_receive(&connfd, &msg) == -1) { + if (progress_ipc_receive(&connfd, &msg) <= 0) { continue; }
progress_ipc_receive() returns as error conditions 0 on EAGAIN and -1 if the read bytes count doesn't match sizeof(*msg). The latter is handled, but the former also qualifies as a (temporary) error. Hence, also don't process the returned progress message in this case. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- bindings/lua_swupdate.c | 2 +- suricatta/server_general.c | 2 +- tools/swupdate-progress.c | 2 +- tools/swupdate-sysrestart.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)