Signed-off-by: Felix Fietkau <nbd@openwrt.org>
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;
- if (len < 0) {
- if (errno == EINTR)
- goto retry;
- if (errno == EAGAIN || errno == EWOULDBLOCK)
- len = 0;
+ ret += len;
+ buf += len;
+ buflen -= len;
- if (len >= 0 && len < buflen)
ustream_fd_set_uloop(s, true);
ustream_fd_set_uloop(s, true);
}
static bool __ustream_fd_poll(struct ustream_fd *sf, unsigned int events)
}
static bool __ustream_fd_poll(struct ustream_fd *sf, unsigned int events)