Bug 1294731 - [4.3] Don't unlink cached extracted files on shutdown. r=glandium

This commit is contained in:
Eugen Sawin 2016-08-17 21:33:18 +02:00
parent 6dfe56fd0a
commit 91a9a08ed7
2 changed files with 6 additions and 20 deletions

View File

@ -219,17 +219,7 @@ MappableExtractFile::Create(const char *name, Zip *zip, Zip::Stream *stream)
}
validator.CacheChecksum();
return new MappableExtractFile(fd.forget(), Move(file));
}
MappableExtractFile::~MappableExtractFile()
{
/* When destroying from a forked process, we don't want the file to be
* removed, as the main process is still using the file. Although it
* doesn't really matter, it helps e.g. valgrind that the file is there.
* The string still needs to be delete[]d, though */
if (pid != getpid())
delete [] path.release();
return new MappableExtractFile(fd.forget(), file.release());
}
/**

View File

@ -5,7 +5,6 @@
#ifndef Mappable_h
#define Mappable_h
#include <sys/types.h>
#include <pthread.h>
#include "Zip.h"
#include "SeekableZStream.h"
@ -110,7 +109,7 @@ private:
class MappableExtractFile: public MappableFile
{
public:
~MappableExtractFile();
~MappableExtractFile() = default;
/**
* Create a MappableExtractFile instance for the given Zip stream. The name
@ -136,14 +135,11 @@ private:
};
typedef mozilla::UniquePtr<char[], UnlinkFile> AutoUnlinkFile;
MappableExtractFile(int fd, AutoUnlinkFile path)
: MappableFile(fd), path(Move(path)), pid(getpid()) { }
MappableExtractFile(int fd, const char* path)
: MappableFile(fd), path(path) { }
/* Extracted file */
AutoUnlinkFile path;
/* Id of the process that initialized the instance */
pid_t pid;
/* Extracted file path */
mozilla::UniquePtr<const char[]> path;
};
class _MappableBuffer;