From 91a9a08ed74976c3631ea8d1e0e3926a16305ab1 Mon Sep 17 00:00:00 2001 From: Eugen Sawin Date: Wed, 17 Aug 2016 21:33:18 +0200 Subject: [PATCH] Bug 1294731 - [4.3] Don't unlink cached extracted files on shutdown. r=glandium --- mozglue/linker/Mappable.cpp | 12 +----------- mozglue/linker/Mappable.h | 14 +++++--------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/mozglue/linker/Mappable.cpp b/mozglue/linker/Mappable.cpp index 626b6ba90378..d19304ef3cd9 100644 --- a/mozglue/linker/Mappable.cpp +++ b/mozglue/linker/Mappable.cpp @@ -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()); } /** diff --git a/mozglue/linker/Mappable.h b/mozglue/linker/Mappable.h index 7ab7a66555b8..17668d00a267 100644 --- a/mozglue/linker/Mappable.h +++ b/mozglue/linker/Mappable.h @@ -5,7 +5,6 @@ #ifndef Mappable_h #define Mappable_h -#include #include #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 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 path; }; class _MappableBuffer;