If not, then libc considers it an error, as with the fwrite(3)
protocol. That does, however, seem to violate what is specified in the
manual, which states that mtwrite should work like write(2).
{
struct stdiofd *d = cookie;
int ev;
{
struct stdiofd *d = cookie;
int ev;
+ off = 0;
+ while(off < len) {
- ret = send(d->fd, buf, len, MSG_DONTWAIT | MSG_NOSIGNAL);
+ ret = send(d->fd, buf + off, len - off, MSG_DONTWAIT | MSG_NOSIGNAL);
- ret = write(d->fd, buf, len);
- if((ret < 0) && (errno == EAGAIN)) {
- ev = block(d->fd, EV_WRITE, d->timeout);
- if(ev < 0) {
- /* If we just go on, we should get the real error. */
- continue;
- } else if(ev == 0) {
- errno = ETIMEDOUT;
- return(-1);
+ ret = write(d->fd, buf + off, len - off);
+ if(ret < 0) {
+ if(errno == EAGAIN) {
+ ev = block(d->fd, EV_WRITE, d->timeout);
+ if(ev < 0) {
+ /* If we just go on, we should get the real error. */
+ continue;
+ } else if(ev == 0) {
+ errno = ETIMEDOUT;
+ return(off);
+ } else {
+ continue;
+ }
}
static int mtclose(void *cookie)
}
static int mtclose(void *cookie)