- 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;
- }
- } else {
- return(off);
+ 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);