- 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);
buf = ustream_reserve(s, 1, &buflen);
if (!buf)
break;
len = read(sf->fd.fd, buf, buflen);
buf = ustream_reserve(s, 1, &buflen);
if (!buf)
break;
len = read(sf->fd.fd, buf, buflen);
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 || errno == ENOTCONN)
+ 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;
bool more = false;
if (events & ULOOP_READ)
ustream_fd_read_pending(sf, &more);
if (events & ULOOP_WRITE) {
bool more = false;
if (events & ULOOP_READ)
ustream_fd_read_pending(sf, &more);
if (events & ULOOP_WRITE) {
- if (ustream_write_pending(s))
- ustream_fd_set_uloop(s);
+ bool no_more = ustream_write_pending(s);
+ if (no_more)
+ 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;