mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Summary: It was possible for a set and a get to race such that the get would return an empty string, if the file for the key was created but not yet written to. This change updates the FileStoreHandler to first write to a temporary file and then atomically rename(2) the file to its final path. This removes the described race condition. This change also replaces the poor filename generation routine with using the 128-bit MurmurHash of a key. Differential Revision: D4502154 fbshipit-source-id: f2abc78b8bad68c06ad2f18a078935826e431f7a
35 lines
909 B
C++
35 lines
909 B
C++
//-----------------------------------------------------------------------------
|
|
// MurmurHash3 was written by Austin Appleby, and is placed in the public
|
|
// domain. The author hereby disclaims copyright to this source code.
|
|
|
|
#pragma once
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Platform-specific functions and macros
|
|
|
|
// Microsoft Visual Studio
|
|
|
|
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
|
|
|
typedef unsigned char uint8_t;
|
|
typedef unsigned int uint32_t;
|
|
typedef unsigned __int64 uint64_t;
|
|
|
|
// Other compilers
|
|
|
|
#else // defined(_MSC_VER)
|
|
|
|
#include <stdint.h>
|
|
|
|
#endif // !defined(_MSC_VER)
|
|
|
|
namespace caffe2 {
|
|
|
|
void MurmurHash3_x86_32(const void* key, int len, uint32_t seed, void* out);
|
|
|
|
void MurmurHash3_x86_128(const void* key, int len, uint32_t seed, void* out);
|
|
|
|
void MurmurHash3_x64_128(const void* key, int len, uint32_t seed, void* out);
|
|
|
|
} // namespace caffe2
|