Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ustream_fd_read_pending(sf, &more);
if (events & ULOOP_WRITE) {
- if (ustream_write_pending(s))
+ if (!ustream_write_pending(s))
ustream_fd_set_uloop(s);
}
{
struct ustream_fd *sf = container_of(s, struct ustream_fd, stream);
- return __ustream_fd_poll(sf, ULOOP_READ);
+ return __ustream_fd_poll(sf, ULOOP_READ | ULOOP_WRITE);
}
static void ustream_uloop_cb(struct uloop_fd *fd, unsigned int events)
if (s->write_error)
return false;
- while (buf) {
+ while (buf && s->w.data_bytes) {
struct ustream_buf *next = buf->next;
int maxlen = buf->tail - buf->data;
struct ustream_buf_list *l = &s->w;
struct ustream_buf *buf;
int maxlen;
+ bool has_data = !!s->w.data_bytes;
while (len) {
if (!ustream_prepare_buf(s, &s->w, len))
l->data_bytes += maxlen;
}
+ if (s->poll && !has_data)
+ s->poll(s);
+
return wr;
}