diff options
Diffstat (limited to 'methods')
-rw-r--r-- | methods/mirror.cc | 5 | ||||
-rw-r--r-- | methods/rred.cc | 25 |
2 files changed, 23 insertions, 7 deletions
diff --git a/methods/mirror.cc b/methods/mirror.cc index 3b2ab8ede..eb6d97425 100644 --- a/methods/mirror.cc +++ b/methods/mirror.cc @@ -124,9 +124,10 @@ bool MirrorMethod::Clean(string Dir) if (I == list.end()) unlink(Dir->d_name); }; - - chdir(StartDir.c_str()); + closedir(D); + if (chdir(StartDir.c_str()) != 0) + return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str()); return true; } 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; |