if (u->write_data) {
pa_assert(u->write_index < u->write_length);
- if ((r = pa_iochannel_write(u->io, (uint8_t*) u->write_data + u->write_index, u->write_length - u->write_index)) <= 0) {
+ if ((r = pa_iochannel_write(u->io, (uint8_t*) u->write_data + u->write_index, u->write_length - u->write_index)) < 0) {
pa_log("write() failed: %s", pa_cstrerror(errno));
return -1;
}
pa_assert(l);
pa_assert(io->ofd >= 0);
- if ((r = pa_write(io->ofd, data, l, &io->ofd_type)) >= 0) {
- io->writable = io->hungup = FALSE;
- enable_events(io);
+ r = pa_write(io->ofd, data, l, &io->ofd_type);
+
+ if ((size_t) r == l)
+ return r; /* Fast path - we almost always successfully write everything */
+
+ if (r < 0) {
+ if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)
+ r = 0;
+ else
+ return r;
}
+ /* Partial write - let's get a notification when we can write more */
+ io->writable = io->hungup = FALSE;
+ enable_events(io);
+
return r;
}
while (l->io && !l->dead && pa_iochannel_is_writable(l->io) && l->wbuf_valid_length > 0) {
- if ((r = pa_iochannel_write(l->io, l->wbuf+l->wbuf_index, l->wbuf_valid_length)) <= 0) {
+ if ((r = pa_iochannel_write(l->io, l->wbuf+l->wbuf_index, l->wbuf_valid_length)) < 0) {
- if (r < 0 && errno == EAGAIN)
- break;
-
- if (r < 0 && errno != EPIPE)
+ if (errno != EPIPE)
pa_log("write(): %s", pa_cstrerror(errno));
failure(l, FALSE);
pa_memblock_unref(chunk.memblock);
if (r < 0) {
-
- if (r < 0 && (errno == EINTR || errno == EAGAIN))
- return 0;
-
pa_log("write(): %s", pa_cstrerror(errno));
return -1;
}
pa_memblock_unref(chunk.memblock);
if (r < 0) {
-
- if (errno == EINTR || errno == EAGAIN)
- return 0;
-
pa_log("write(): %s", pa_cstrerror(errno));
return -1;
}
pa_memblock_unref(chunk.memblock);
if (r < 0) {
-
- if (errno == EINTR || errno == EAGAIN)
- return 0;
-
pa_log("write(): %s", pa_cstrerror(errno));
return -1;
}