ustream-fd: prevent callbacks during init
authorFelix Fietkau <nbd@openwrt.org>
Thu, 3 Jan 2013 14:58:04 +0000 (15:58 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 3 Jan 2013 15:32:45 +0000 (16:32 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ustream-fd.c

index 397ce5d..a47ff94 100644 (file)
@@ -21,6 +21,8 @@
 #include <stdio.h>
 #include "ustream.h"
 
 #include <stdio.h>
 #include "ustream.h"
 
+static bool _init = false;
+
 static void ustream_fd_set_uloop(struct ustream *s, bool write)
 {
        struct ustream_fd *sf = container_of(s, struct ustream_fd, stream);
 static void ustream_fd_set_uloop(struct ustream *s, bool write)
 {
        struct ustream_fd *sf = container_of(s, struct ustream_fd, stream);
@@ -36,7 +38,7 @@ static void ustream_fd_set_uloop(struct ustream *s, bool write)
 
        uloop_fd_add(&sf->fd, flags);
 
 
        uloop_fd_add(&sf->fd, flags);
 
-       if (flags & ULOOP_READ)
+       if ((flags & ULOOP_READ) && !_init);
                sf->fd.cb(&sf->fd, ULOOP_READ);
 }
 
                sf->fd.cb(&sf->fd, ULOOP_READ);
 }
 
@@ -161,5 +163,7 @@ void ustream_fd_init(struct ustream_fd *sf, int fd)
        s->write = ustream_fd_write;
        s->free = ustream_fd_free;
        s->poll = ustream_fd_poll;
        s->write = ustream_fd_write;
        s->free = ustream_fd_free;
        s->poll = ustream_fd_poll;
+       _init = true;
        ustream_fd_set_uloop(s, false);
        ustream_fd_set_uloop(s, false);
+       _init = false;
 }
 }