@@ -143,6 +143,13 @@ static void console_notifier (RECOVERY_STATUS status, int error, int level, cons
case SUBPROCESS:
snprintf(current, sizeof(current), "EVENT [%d] : ", error );
break;
+ /*
+ * PROGRESS is a special case. It is used for subprocesses to send
+ * progress information via the notifier. A trace with this status
+ * is processed by the progress notifier
+ */
+ case PROGRESS:
+ return;
case DONE:
strncpy(current, "SWUPDATE done : ", sizeof(current));
break;
@@ -203,6 +210,22 @@ static void process_notifier (RECOVERY_STATUS status, int event, int level, cons
}
+/*
+ * Progress notifier: the message should be forwarded to the progress
+ * interface only.
+ */
+static void progress_notifier (RECOVERY_STATUS status, int event, int level, const char *msg)
+{
+ (void)level;
+
+ /* Check just in case a process want to send an info outside */
+ if (status != PROGRESS)
+ return;
+
+ swupdate_progress_info(status, event, msg);
+}
+
+
#if defined(__FreeBSD__)
static char* socket_path = NULL;
static void unlink_socket(void)
@@ -365,6 +388,7 @@ void notify_init(void)
STAILQ_INIT(&clients);
register_notifier(console_notifier);
register_notifier(process_notifier);
+ register_notifier(progress_notifier);
start_thread(notifier_thread, NULL);
}
}
@@ -381,7 +381,7 @@ static int channel_callback_xferinfo(void *p, curl_off_t dltotal, curl_off_t dln
"{\"percent\": %d, \"msg\":\"Received %" CURL_FORMAT_CURL_OFF_T "B "
"of %" CURL_FORMAT_CURL_OFF_T "B\"}",
(int)percent, dlnow, dltotal) != ENOMEM_ASPRINTF) {
- notify(SUBPROCESS, RECOVERY_NO_ERROR, TRACELEVEL, info);
+ notify(PROGRESS, RECOVERY_NO_ERROR, TRACELEVEL, info);
free(info);
}
return 0;
@@ -27,6 +27,7 @@ typedef enum {
DOWNLOAD,
DONE,
SUBPROCESS,
+ PROGRESS,
} RECOVERY_STATUS;
typedef enum {
During downloading a TRACE is sent to the notifier with the goal to forward it to the progress interface. However, as TRACE, this is also shown and processed by all notifier causing an overflood of messages on the console that cna slow down the system. Move this to a separate notifier and drop it from console notifier. Signed-off-by: Stefano Babic <sbabic@denx.de> --- core/notifier.c | 24 ++++++++++++++++++++++++ corelib/channel_curl.c | 2 +- include/swupdate_status.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-)