[OpenWrt-Devel] [PATCH] uloop: handle waker pipe write() return value

Eyal Birger eyal.birger at gmail.com
Mon Jun 20 01:36:47 EDT 2016


Recent glibc warns if result of read() or write() is unused.

Added a retry in case of EINTR, all other faults are silently discarded.

Signed-off-by: Eyal Birger <eyal.birger at gmail.com>

-----
- I was not able to reproduce the EINTR case, but it seems to be the right
  thing to do
- Retrying on EAGAIN in this case would be weird as there is no one to read
  from the other end of the pipe. We could call waker_consume() directly but
  since the size of the message is just one byte, I think this would be dead
  code
---
 uloop.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/uloop.c b/uloop.c
index e60fb09..fd315c0 100644
--- a/uloop.c
+++ b/uloop.c
@@ -386,7 +386,13 @@ static void uloop_handle_processes(void)
 
 static void uloop_signal_wake(void)
 {
-	write(waker_pipe, "w", 1);
+	do {
+		if (write(waker_pipe, "w", 1) < 0) {
+			if (errno == EINTR)
+				continue;
+		}
+		break;
+	} while (1);
 }
 
 static void uloop_handle_sigint(int signo)
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list