- if (flags & ULOOP_READ)
- sf->fd.cb(&sf->fd, ULOOP_READ);
+static void ustream_fd_set_read_blocked(struct ustream *s)
+{
+ ustream_fd_set_uloop(s, false);
static int ustream_fd_write(struct ustream *s, const char *buf, int buflen, bool more)
{
struct ustream_fd *sf = container_of(s, struct ustream_fd, stream);
static int ustream_fd_write(struct ustream *s, const char *buf, int buflen, bool more)
{
struct ustream_fd *sf = container_of(s, struct ustream_fd, stream);
-retry:
- len = write(sf->fd.fd, buf, buflen);
- if (!len)
- goto retry;
+ while (buflen) {
+ len = write(sf->fd.fd, buf, buflen);
+
+ if (len < 0) {
+ if (errno == EINTR)
+ continue;
+
+ if (errno == EAGAIN || errno == EWOULDBLOCK)
+ break;
}
static bool __ustream_fd_poll(struct ustream_fd *sf, unsigned int events)
{
struct ustream *s = &sf->stream;
}
static bool __ustream_fd_poll(struct ustream_fd *sf, unsigned int events)
{
struct ustream *s = &sf->stream;
- ustream_fd_set_uloop(s);
- }
-
- if (!s->eof && fd->eof) {
- s->eof = true;
- ustream_fd_set_uloop(s);
- ustream_state_change(s);
+ ustream_fd_set_uloop(s, false);
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;