ustream-fd: only use read() == 0 as eof indication, and issue a state change notifica...
authorFelix Fietkau <nbd@openwrt.org>
Wed, 30 Jan 2013 16:48:55 +0000 (17:48 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 30 Jan 2013 16:48:55 +0000 (17:48 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ustream-fd.c

index a2527080ad44bf7ae2f3a51986da3b6aed162b4f..e39da98e3d5ccfa120b7f4a5ee8e6845626dd0f9 100644 (file)
@@ -72,6 +72,8 @@ static void ustream_fd_read_pending(struct ustream_fd *sf, bool *more)
 
                if (!len) {
                        sf->fd.eof = true;
+                       ustream_state_change(s);
+                       ustream_fd_set_uloop(s, false);
                        return;
                }
 
@@ -115,7 +117,6 @@ static int ustream_fd_write(struct ustream *s, const char *buf, int buflen, bool
 static bool __ustream_fd_poll(struct ustream_fd *sf, unsigned int events)
 {
        struct ustream *s = &sf->stream;
-       struct uloop_fd *fd = &sf->fd;
        bool more = false;
 
        if (events & ULOOP_READ)
@@ -126,12 +127,6 @@ static bool __ustream_fd_poll(struct ustream_fd *sf, unsigned int events)
                        ustream_fd_set_uloop(s, false);
        }
 
-       if (!s->eof && fd->eof) {
-               s->eof = true;
-               ustream_fd_set_uloop(s, false);
-               ustream_state_change(s);
-       }
-
        return more;
 }