зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1313451 - [1.1] Make Zip thread-safe. r=glandium
This commit is contained in:
Родитель
faba7fa1af
Коммит
8f140cc639
|
@ -65,6 +65,7 @@ Zip::Zip(const char *filename, void *mapped, size_t size)
|
|||
, nextDir(nullptr)
|
||||
, entries(nullptr)
|
||||
{
|
||||
pthread_mutex_init(&mutex, nullptr);
|
||||
// If the first local file entry couldn't be found (which can happen
|
||||
// with optimized jars), check the first central directory entry.
|
||||
if (!nextFile)
|
||||
|
@ -79,11 +80,14 @@ Zip::~Zip()
|
|||
DEBUG_LOG("Unmapped %s @%p", name, mapped);
|
||||
free(name);
|
||||
}
|
||||
pthread_mutex_destroy(&mutex);
|
||||
}
|
||||
|
||||
bool
|
||||
Zip::GetStream(const char *path, Zip::Stream *out) const
|
||||
{
|
||||
AutoLock lock(&mutex);
|
||||
|
||||
DEBUG_LOG("%s - GetFile %s", name, path);
|
||||
/* Fast path: if the Local File header on store matches, we can return the
|
||||
* corresponding stream right away.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <zlib.h>
|
||||
#include <pthread.h>
|
||||
#include "Utils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/RefCounted.h"
|
||||
|
@ -459,6 +460,8 @@ private:
|
|||
|
||||
/* Pointer to the Directory entries */
|
||||
mutable const DirectoryEntry *entries;
|
||||
|
||||
mutable pthread_mutex_t mutex;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче