summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-05-10 00:14:50 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-05-10 00:14:50 +0200
commitadbd7eb4db58ce38965bf6340b8b059a07fdb5bc (patch)
tree9ba0987be61d69354ef927cca5ac243aee2732cc /apt-pkg/contrib/fileutl.cc
parentba667cf74b94846c0696ae7a27e53b28492554b6 (diff)
collect zombie (de)compressor processes on reopen
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 14c0b561f..4dc087983 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1022,6 +1022,11 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
#ifdef HAVE_ZLIB
else if (compressor.Name == "gzip")
{
+ if (d->gz != NULL)
+ {
+ gzclose(d->gz);
+ d->gz = NULL;
+ }
if ((Mode & ReadWrite) == ReadWrite)
d->gz = gzdopen(iFd, "r+");
else if ((Mode & WriteOnly) == WriteOnly)
@@ -1037,6 +1042,11 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
#ifdef HAVE_BZ2
else if (compressor.Name == "bzip2")
{
+ if (d->bz2 != NULL)
+ {
+ BZ2_bzclose(d->bz2);
+ d->bz2 = NULL;
+ }
if ((Mode & ReadWrite) == ReadWrite)
d->bz2 = BZ2_bzdopen(iFd, "r+");
else if ((Mode & WriteOnly) == WriteOnly)
@@ -1050,14 +1060,17 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
}
#endif
+ // collect zombies here in case we reopen
+ if (d->compressor_pid > 0)
+ ExecWait(d->compressor_pid, "FileFdCompressor", true);
if ((Mode & ReadWrite) == ReadWrite)
return _error->Error("ReadWrite mode is not supported for file %s", FileName.c_str());
bool const Comp = (Mode & WriteOnly) == WriteOnly;
- // Handle 'decompression' of empty files
if (Comp == false)
{
+ // Handle 'decompression' of empty files
struct stat Buf;
fstat(iFd, &Buf);
if (Buf.st_size == 0 && S_ISFIFO(Buf.st_mode) == false)