ipc_get_status_timeout() returns the size of the message on success, but
ipc_get_status() returns 0 in this case (both return a negative value on
error)
Changing the function to use ipc_get_status() didn't update the return
value check: fix this, and also properly check for errors.
Also remove obsolete comment describing the return value.
Reported-by: James Hilliard <
james.h...@gmail.com>
Fixes: da48265ad29f ("suricatta process notification: improve ipc_get_status scheduling")
Signed-off-by: Dominique Martinet <
dominique...@atmark-techno.com>
---
suricatta/server_hawkbit.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
index 9c3e97418361..26260b6bd5e0 100644
--- a/suricatta/server_hawkbit.c
+++ b/suricatta/server_hawkbit.c
@@ -1003,7 +1003,12 @@ static void *process_notification_thread(void *data)
bool data_avail = false;
int ret = ipc_get_status(&msg);
- data_avail = ret > 0 && (strlen(msg.data.status.desc) != 0);
+ if (ret < 0) {
+ ERROR("Error getting status, stopping notification thread");
+ stop = true;;
+ } else {
+ data_avail = (strlen(msg.data.status.desc) != 0);
+ }
/*
* Mutex used to synchronize end of the thread
@@ -1017,12 +1022,6 @@ static void *process_notification_thread(void *data)
if (data_avail && msg.data.status.current == PROGRESS)
continue;
- /*
- * If there is a message
- * ret > 0: data available
- * ret == 0: TIMEOUT, no more messages
- * ret < 0 : ERROR, exit
- */
if (data_avail && numdetails < MAX_DETAILS) {
for (int c = 0; c < strlen(msg.data.status.desc); c++) {
switch (msg.data.status.desc[c]) {
--
2.39.2