summaryrefslogtreecommitdiff
path: root/methods/rred.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-04-11 17:45:36 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-04-11 17:45:36 +0200
commitc3753d1de25737aed66d6ca14d0473042b7c55a7 (patch)
tree750745b523fee36d66b4cdd041fc8117be22c5fe /methods/rred.cc
parent621aeca0bc8fe39c57d6221c7581c758e5822fd0 (diff)
parentd68d65ad637526e46ea77ab83e07470d26df15fc (diff)
merged from donkults experimental branch
Diffstat (limited to 'methods/rred.cc')
-rw-r--r--methods/rred.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/methods/rred.cc b/methods/rred.cc
index 1e352d0e7..78d1595d4 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -227,6 +227,21 @@ struct EdCommand {
char type;
};
#define IOV_COUNT 1024 /* Don't really want IOV_MAX since it can be arbitrarily large */
+static ssize_t retry_writev(int fd, const struct iovec *iov, int iovcnt) {
+ ssize_t Res;
+ errno = 0;
+ ssize_t i = 0;
+ do {
+ Res = writev(fd, iov + i, iovcnt);
+ if (Res < 0 && errno == EINTR)
+ continue;
+ if (Res < 0)
+ return _error->Errno("writev",_("Write error"));
+ iovcnt -= Res;
+ i += Res;
+ } while (Res > 0 && iovcnt > 0);
+ return i;
+}
#endif
/*}}}*/
RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/
@@ -377,7 +392,7 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/
hash->Add((const unsigned char*) begin, input - begin);
if(++iov_size == IOV_COUNT) {
- writev(out_file.Fd(), iov, IOV_COUNT);
+ retry_writev(out_file.Fd(), iov, IOV_COUNT);
iov_size = 0;
}
}
@@ -402,7 +417,7 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/
iov[iov_size].iov_len);
if(++iov_size == IOV_COUNT) {
- writev(out_file.Fd(), iov, IOV_COUNT);
+ retry_writev(out_file.Fd(), iov, IOV_COUNT);
iov_size = 0;
}
}
@@ -417,15 +432,15 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/
}
if(iov_size) {
- writev(out_file.Fd(), iov, iov_size);
+ retry_writev(out_file.Fd(), iov, iov_size);
iov_size = 0;
}
for(i = 0; i < iov_size; i += IOV_COUNT) {
if(iov_size - i < IOV_COUNT)
- writev(out_file.Fd(), iov + i, iov_size - i);
+ retry_writev(out_file.Fd(), iov + i, iov_size - i);
else
- writev(out_file.Fd(), iov + i, IOV_COUNT);
+ retry_writev(out_file.Fd(), iov + i, IOV_COUNT);
}
delete [] iov;