[OpenWrt-Devel] [PATCH][libubox] ustream-fd: handle uloop errors

Philip Craig philipjcraig at gmail.com
Fri Jul 10 03:23:48 EDT 2015


Otherwise uloop will delete the fd and the ustream will receive no
notification of the error.

Signed-off-by: Philip Craig <philipjcraig at gmail.com>
---
 ustream-fd.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ustream-fd.c b/ustream-fd.c
index 5ffca53..2c15b42 100644
--- a/ustream-fd.c
+++ b/ustream-fd.c
@@ -25,7 +25,7 @@ static void ustream_fd_set_uloop(struct ustream *s, bool write)
 {
 	struct ustream_fd *sf = container_of(s, struct ustream_fd, stream);
 	struct ustream_buf *buf;
-	unsigned int flags = ULOOP_EDGE_TRIGGER;
+	unsigned int flags = ULOOP_EDGE_TRIGGER | ULOOP_ERROR_CB;
 
 	if (!s->read_blocked && !s->eof)
 		flags |= ULOOP_READ;
@@ -127,6 +127,12 @@ static bool __ustream_fd_poll(struct ustream_fd *sf, unsigned int events)
 			ustream_fd_set_uloop(s, false);
 	}
 
+	if (sf->fd.error) {
+		if (!s->write_error)
+			ustream_state_change(s);
+		s->write_error = true;
+	}
+
 	return more;
 }
 
-- 
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