Make FileStore not segfault with concurrent accesses. (#28812)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/28812
FileStore isn't thread-safe. We've observed a few FB unittests
already using this class in an unsafe manner.
This change enforces at most a single concurrent use of
the various file options, from this specific Store instance.
This protects the cache_, pos_, and the relative integrity
of the operations.
An alternative would be simply to explicitly document this
class as non-thread-safe, though perhaps not everybody will
read the warning.
ghstack-source-id: 92874098
Test Plan:
buck test mode/dev-nosan caffe2/...
Actual observed failures were in ThreadRpcAgentTest
Differential Revision: D18187821
fbshipit-source-id: 67c765da74c836a9ac9f887cdf1a28a75247e04b