ustream-fd: fix read error handling
authorFelix Fietkau <nbd@openwrt.org>
Thu, 3 Jan 2013 14:46:21 +0000 (15:46 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 3 Jan 2013 15:32:40 +0000 (16:32 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ustream-fd.c

index 93fd501903701e50f82edafa111c730e70001dd9..397ce5dbfd8c488aff663bbbf5a97847d23b2209 100644 (file)
@@ -58,17 +58,19 @@ static void ustream_fd_read_pending(struct ustream_fd *sf, bool *more)
                        break;
 
                len = read(sf->fd.fd, buf, buflen);
-               if (!len) {
-                       sf->fd.eof = true;
-                       return;
-               }
-
                if (len < 0) {
                        if (errno == EINTR)
                                continue;
 
                        if (errno == EAGAIN)
                                return;
+
+                       len = 0;
+               }
+
+               if (!len) {
+                       sf->fd.eof = true;
+                       return;
                }
 
                ustream_fill_read(s, len);