diff mbox series

webserver: do not flood with ERROR when IPC ic closed

Message ID 20200115151137.4434-1-sbabic@denx.de
State Accepted
Headers show
Series webserver: do not flood with ERROR when IPC ic closed | expand

Commit Message

Stefano Babic Jan. 15, 2020, 3:11 p.m. UTC
Stop to write ERROR message after the first one.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 mongoose/mongoose_interface.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c
index 1d95556..55ebad2 100644
--- a/mongoose/mongoose_interface.c
+++ b/mongoose/mongoose_interface.c
@@ -58,6 +58,7 @@  struct mongoose_options {
 struct file_upload_state {
 	size_t len;
 	int fd;
+	bool error_report; /* if set, stop to flood with errors */
 };
 
 static bool run_postupdate;
@@ -344,7 +345,10 @@  static void upload_handler(struct mg_connection *nc, int ev, void *p)
 		 */
 		if (written != mp->data.len) {
 			if (errno != EAGAIN && errno != EWOULDBLOCK) {
-				ERROR("Writing to IPC fails due to %s", strerror(errno));
+				if (!fus->error_report) {
+					ERROR("Writing to IPC fails due to %s", strerror(errno));
+					fus->error_report = true;
+				}
 			}
 			usleep(100);