diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2012-03-20 19:23:32 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2012-03-20 19:23:32 +0100 |
commit | 319790f4f86f595724fb2bd5aa6274d345469010 (patch) | |
tree | 0c2686423a217f557fbdd990111d6947a5d228e7 /methods/rred.cc | |
parent | 571449d4444a8a6f5c55dce318cdf16805c04743 (diff) |
* methods/rred.cc:
- check return of writev() as gcc recommends
* methods/mirror.cc:
- check return of chdir() as gcc recommends
* apt-pkg/deb/dpkgpm.cc:
- check return of write() a gcc recommends
* apt-inst/deb/debfile.cc:
- check return of chdir() as gcc recommends
* apt-inst/deb/dpkgdb.cc:
- check return of chdir() as gcc recommends
Diffstat (limited to 'methods/rred.cc')
-rw-r--r-- | methods/rred.cc | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/methods/rred.cc b/methods/rred.cc index 1e352d0e7..38554464d 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 */ +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; |