The process notification thread gets messages from swupdate to submit
them to the hawkbit server.
Before this patch, ipc_get_status_timeout() was called in a tight loop,
probably with the assumption that it would wait until the timeout
happens if no message was available.
Unfortunately, the server just replies immediately that there is no
message, so this would just hammer the server in a tight loop.
Furthermore, on slow devices if the server takes more than 100ms to
reply we close our socket so the server would crash to sigpipe without
the previous fix.
Adjust this loop to:
- since ipc_get_status() always returns immediately the timeout is
useless, use the version without timeout.
- wait 100ms before calling ipc_get_status() again if no message was
available.
Signed-off-by: Dominique Martinet <
dominique...@atmark-techno.com>
---
suricatta/server_hawkbit.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
index 1633c5cca65b..7ceb1dc038fd 100644
--- a/suricatta/server_hawkbit.c
+++ b/suricatta/server_hawkbit.c
@@ -997,7 +997,7 @@ static void *process_notification_thread(void *data)
for (;;) {
ipc_message msg;
bool data_avail = false;
- int ret = ipc_get_status_timeout(&msg, 100);
+ int ret = ipc_get_status(&msg);
data_avail = ret > 0 && (strlen(msg.data.status.desc) != 0);
@@ -1060,6 +1060,10 @@ static void *process_notification_thread(void *data)
if (stop && !data_avail)
break;
+
+ // wait a bit for next message...
+ if (!data_avail)
+ usleep(100000);
}
pthread_mutex_unlock(¬ifylock);
--
2.39.2