char *buf;
do {
+ if (s->read_blocked)
+ break;
+
buf = ustream_reserve(s, 1, &buflen);
if (!buf)
break;
}
if (!len) {
+ if (!s->eof)
+ ustream_state_change(s);
s->eof = true;
- ustream_state_change(s);
ustream_fd_set_uloop(s, false);
return;
}
ustream_fd_read_pending(sf, &more);
if (events & ULOOP_WRITE) {
- if (!ustream_write_pending(s))
+ bool no_more = ustream_write_pending(s);
+ if (no_more)
ustream_fd_set_uloop(s, false);
}