Commit Graph

1949 Commits

Author SHA1 Message Date
Zeyi Fan
fa10788fce Reuse CURL* handle from curl_easy interface
Summary: Since `CurlClient` is going to be used in multiple threads and each thread has its own instance of CurlClient, we are now able to assign one curl_easy handle for each of the client. So curl would be able to reuse the existing connections to Mononoke API Server.

Reviewed By: chadaustin

Differential Revision: D14334486

fbshipit-source-id: aacd210773c44dea6f1d9dd7f9b09d765a9c7a0a
2019-03-11 14:34:09 -07:00
Zeyi Fan
16687decb2 Use thread factory for curl clients
Summary: Put `CurlClient` into its own thread pool (like how `HgBackingStore` uses `HgImporter`)

Reviewed By: chadaustin

Differential Revision: D14334483

fbshipit-source-id: 3ce2a8245761c11bfa0f66691d10a66004b46fe6
2019-03-11 14:34:09 -07:00
Zeyi Fan
199eb0ed42 Use MononokeCurlBackingStore in HgBackingStore
Summary: This diff enables `MononokeCurlBackingStore` in HgBackingStore. It also adds a new config value `mononoke:connection-type` (values: `http`, `curl` and `thrift`).

Reviewed By: chadaustin

Differential Revision: D14135028

fbshipit-source-id: cc6fb95d94b3d98996d872d22ad1a95a97d562ab
2019-03-11 14:34:09 -07:00
Zeyi Fan
21a6606e1f Add MononokeCurlBackingStore
Summary: This diff add a MononokeBackingStore implemented based on libcurl so we could add Mononoke support on macOS.

Reviewed By: chadaustin

Differential Revision: D14096313

fbshipit-source-id: 2bcb0c49002dcbb0a0190ba505a6e814e74db747
2019-03-11 14:34:08 -07:00
Zeyi Fan
d9f1beb1a1 add mononoke:connector config and create initializeHttpMononokeBackingStore
Summary:
This diff added a configurable value "mononoke:connector" to EdenConfig, so that we can specify a particular type of connection we need when using Mononoke as backing store.

This diff also moved the logic of initializing the existing `MononokeHttpBackingStore` to `initializeHttpMononokeBackingStore`.

Reviewed By: wez, strager

Differential Revision: D14141725

fbshipit-source-id: c7208295d7b3853740d7b0e5166f8854457fcf8e
2019-03-11 14:34:08 -07:00
Jun Wu
1f30afc972 config: enable merge.printcandidatecommmits
Summary:
The feature was completed by Phil in D9816270. It's handy and can probably
reduce user support burden like: https://fb.intern.facebook.com/groups/scm/permalink/2039619916087618/

Therefore let's enable it.

Reviewed By: DurhamG

Differential Revision: D14293405

fbshipit-source-id: 54e934e0bf495c090109462e4f743d427df39380
2019-03-08 19:56:07 -08:00
Adam Simpkins
574c34ffbd fix "eden start --if-necessary" when using systemd
Summary:
Update `eden start` to honor the `--if-necessary` flag even when starting
with systemd.

Reviewed By: chadaustin, strager

Differential Revision: D14356541

fbshipit-source-id: b7c12b11a2fd63eeee84026bf4418702f794cbf0
2019-03-08 19:06:04 -08:00
Adam Simpkins
1b7f39fc56 convert most the CLI config code from str to Path
Summary:
Update most of the `eden/cli/config.py` to use `Path` instead of `str` where
appropriate.  This also updates several of the APIs in `util.py` that were
affected as well.

Reviewed By: chadaustin

Differential Revision: D14356543

fbshipit-source-id: a8f6d15b8870bf689eeb78f9fc0e9a0c65c97218
2019-03-08 19:06:04 -08:00
Chad Austin
eafd6107de add missing gflags headers
Summary:
Not sure why gflags is automatically included on Linux and not in
mode/mac, but add the includes nonetheless!

Reviewed By: strager

Differential Revision: D14389458

fbshipit-source-id: 27811ec4bb65b03e73b15bb51de1264dbfe053dc
2019-03-08 14:43:24 -08:00
Adam Simpkins
98ef256f4c remove CheckoutConfig.hooks_path
Summary:
Remove the `CheckoutConfig.hooks_path` attribute which is no longer used
anywhere.

Reviewed By: strager

Differential Revision: D14356542

fbshipit-source-id: 28b7e7aeb197aeb5d04edf8adfdcfe7946ffa0c7
2019-03-08 11:10:01 -08:00
Adam Simpkins
524bf4243d remove the old hooks configuration file
Summary:
This file has not been used D13447272, which moved creation of the `.hg`
directory from a separate hook into the CLI itself.  Remove it from the
packaging.

Reviewed By: strager

Differential Revision: D14356544

fbshipit-source-id: 18232c0e7e80e8cb255dd66f70b2a21b4abe6ca7
2019-03-08 11:10:01 -08:00
Adam Simpkins
4b9b3bf7fd fix exception in eden fsck when no mounts are configured
Summary:
If no mounts are configured `eden fsck` previously threw an exception when
trying to compute the return value.  It called `max(return_codes)` on an empty
return codes list, which would fail.  This changes the code to handle that
code specially and report a warning that there was nothing to check.

Reviewed By: chadaustin

Differential Revision: D14352112

fbshipit-source-id: 3815ef34a12834d642f3eee867dda6dc1117c2ef
2019-03-08 11:10:00 -08:00
Adam Simpkins
e28cceca9f minor clean up to some of the fsck code
Summary:
Update the fsck `check_all()` function to use the newer
`EdenInstance.get_checkouts()` API instead of the older, internal
`_get_directory_map()` method.

Reviewed By: chadaustin

Differential Revision: D14352113

fbshipit-source-id: f1ceae72747833d89d5afd11da585ba96b5615a4
2019-03-08 11:10:00 -08:00
Adam Simpkins
a350dd4c41 move the "eden doctor" tests to eden/cli/doctor/test/
Summary:
Previously the `eden doctor` tests were all in a single `doctor_test.py` file
and it was getting quite large and unwieldy (3000+ lines).

This moves the doctor tests from `eden/cli/test/` to `eden/cli/doctor/test/`
and splits up the various test case classes into their own modules, and the
various helper classes into modules in `eden/cli/doctor/test/lib/`

This doesn't have any functional code changes other than moving things around.

Reviewed By: chadaustin

Differential Revision: D14338814

fbshipit-source-id: 5373c7454567b4417241b4c85ec53d3ded29a8c9
2019-03-08 11:10:00 -08:00
Adam Simpkins
97494f0a22 change "eden doctor" to read /proc instead of using pgrep
Summary:
Update the "eden doctor" code to directly examine `/proc` when searching for
edenfs processes rather than calling `pgrep`.

This is a bit more efficient, it lets us accurately detect the command line
arguments.  In the deadlock scenario in T38417129 this likely would have
prevented `eden doctor` from hanging since it no longer attempts to read
`/proc/<pid>/cmdline` for any process other than `edenfs` itself.

This also fixes a minor bug where the code incorrectly warns about `pgrep`
failing when there are no `edenfs` processes running.

Reviewed By: strager

Differential Revision: D14255535

fbshipit-source-id: f5f40566b46b86201aa59f4554e6acf058337c5b
2019-03-08 11:10:00 -08:00
Matt Glazar
49f4c37b67 Add missing copyright notices
Summary: Internal Facebook infrastructure is nagging me about some files not having a Facebook copyright notice. Add a notice to these files to make the nagging stop.

Reviewed By: simpkins

Differential Revision: D14173944

fbshipit-source-id: 7234431224fcf4f86ea56ca2f9108f47ef959d87
2019-03-07 19:32:39 -08:00
Matt Glazar
388cd7455a Document how globs work
Summary:
I was thinking about teaching EdenFS' `globFiles` to follow symlinks. To help me think, I documented my understanding of how EdenFS currently handles glob patterns. Publish my notes, even if I decide to not change `globFiles`' behavior.

This document isn't meant to be thorough, so many definitions and nuances are omitted.

Reviewed By: simpkins

Differential Revision: D14288417

fbshipit-source-id: e78749e114224926c2673868854d068672e38cef
2019-03-07 14:20:57 -08:00
Adam Simpkins
4b36988315 add a custom translation for ENOTCONN
Summary:
Add a locale translation file that we can install to modify the error message
that most programs print for `ENOTCONN` errors.

Any I/O operations inside an unmounted FUSE mount will fail with `ENOTCONN`.
Many users don't really know what to do when they encounter this error.  This
alternate error message should hopefully help point them in the right
direction.

Reviewed By: wez, pixelb

Differential Revision: D14360858

fbshipit-source-id: 9d538ee675815f017160c3382e2919136367464f
2019-03-07 12:55:04 -08:00
Adam Simpkins
79f873f81c automatically create mount directories when necessary
Summary:
This updates `edenfs` to automatically create the mount point directory
if it does not exist.

Previously the `eden mount` CLI command would automatically create the mount
directory in the Python logic.  This adds similar logic to the C++ code, which
handles more situations.  In particular this makes it so that `eden start`
will now automatically create missing mount point directories.

Note that the C++ code does not create the `README_EDEN.txt` symlink inside
the mount point if it is missing.  We could move that functionality into the
C++ code in the future if needed.

Reviewed By: strager

Differential Revision: D14254699

fbshipit-source-id: bad5634f57fba6e7af3b6a3830eb51ac099b435e
2019-03-07 12:36:04 -08:00
Yedidya Feldblum
e245072bf7 Add assorted missing includes
Summary: [Eden] Add assorted missing `#include`s.

Reviewed By: swolchok

Differential Revision: D14293384

fbshipit-source-id: ccd61dde41a978bd3f82eb11cbe401cd51e7e056
2019-03-07 00:13:47 -08:00
Adam Simpkins
75b199385e perform overlay initialization in a separate thread
Summary:
Update `Overlay::initialization()` to perform the bulk of the initialization
logic in the GC thread.  We re-use the GC thread simply for convenience, since
it already exists and won't have any work to do until initialization has
completed anyway.

After an unclean shutdown this allows edenfs to start and perform the overlay
scans for all of its checkouts in parallel rather than serially.

Reviewed By: wez

Differential Revision: D14154868

fbshipit-source-id: c177cb9f950a6317fd7ea06888bd5b326a55ace7
2019-03-06 20:33:42 -08:00
Adam Simpkins
42b4ffd194 add an Overlay::initialize() function
Summary:
Add an Overlay::initialize() function, and consolidate all Overlay
initializtion logic in this function.  Previously some initialization was done
by the Overlay constructor, and some was done in `EdenMount::initialize()`

Overlay::initialize() returns a folly::SemiFuture as it may perform a
non-trivial amount of disk I/O.  However, at the moment it currently performs
all I/O in the current thread before it returns.  I plan to move this work to
a separate thread in a subsequent diff.

Reviewed By: strager

Differential Revision: D13981140

fbshipit-source-id: b59eaef88012a8e74fcb770a9c93ca3f9bde32a0
2019-03-06 20:33:42 -08:00
Adam Simpkins
4dc59b856b ensure that most thrift calls cannot access initializing mounts
Summary:
This updates the `EdenServer` class so that the existing `getMount()` and
`getMountPoints()` APIs only return mounts that have finished initializing.

These APIs are primarily used by the thrift interfaces.  In most cases the
callers did not intend to operate on mounts that were still initializing, and
doing so was unsafe.  The code could potentially dereference a null pointer if
it tried to access the mount's root inode before the root inode object had
been created.

New `getMountUnsafe()` and `getAllMountPoints()` APIs have been added for call
sites that explicitly want to be able to access mounts that may still be
initializing.  Currently the `listMounts()` thrift API is the only location
that needs this.

Reviewed By: strager

Differential Revision: D13981139

fbshipit-source-id: e6168d7a15694c79ca2bcc129dda46f82382e8e9
2019-03-06 20:33:42 -08:00
Adam Simpkins
b47184adc4 add a flag to report start-up success before finishing mounts
Summary:
Add a flag to tell edenfs to report successful start-up as soon as the thrift
server is running, without waiting for all mount points to finish being
remounted.

In the future I plan to have edenfs automatically perform an fsck scan of the
overlay for checkouts that were not shut down cleanly.  This may cause the
remount to take a significant amount of extra start-up time in some cases.
(This is already true today in some cases even with the simpler scan we do to
re-compute the max inode number.)

I think we will probably want to have systemd invoke edenfs with this option,
so that we do not time out during system start up if some mount points need to
be rescanned.

Reviewed By: strager

Differential Revision: D13522040

fbshipit-source-id: 6f183770c25efee34c4805c9bad42a9cce51039e
2019-03-06 20:33:41 -08:00
Matt Glazar
ce1c8019a0 Refactor MountPromiseDelegate and FailingMountDelegate
Summary:
In the future, I want some tests to mock PrivHelper::fuseUnmount. The existing classes for mocking PrivHelper::fuseMount, MountPromiseDelegate and FailingMountDelegate, work poorly for fuseUnmount.

Combine MountPromiseDelegate and FailingMountDelegate to create MockMountDelegate, which is more flexible and allows a mocking fuseUnmount to be implemented easily.

This diff should not change behavior.

Reviewed By: simpkins

Differential Revision: D14319712

fbshipit-source-id: 6eecf121e3b44f39cd5dffbeafaf0f3aab75cb76
2019-03-06 19:20:02 -08:00
Chad Austin
28c480cb03 use cpptoml from third-party
Summary: Switch to using cpptoml from third-party on all platforms.

Reviewed By: igorsugak

Differential Revision: D14351179

fbshipit-source-id: 183bedc7d27e9c0f9216f3d0cca58ada75ac74e7
2019-03-06 15:19:23 -08:00
Matt Glazar
51857c47dd Add test for mount state after takeover
Summary: Ensure that an EdenMount is RUNNING after it takes over an EdenMount from another process.

Reviewed By: simpkins

Differential Revision: D14178500

fbshipit-source-id: 2813b024b6815dc5d31f3e3bf89cffa98ad0f1c3
2019-03-05 17:32:46 -08:00
Matt Glazar
77e312595c Make FakeFuseMountDelegate public
Summary:
I want manipulate a FakeFuseMountDelegate in a test, but FakeFuseMountDelegate is private to FakePrivHelper.cpp. Make FakeFuseMountDelegate usable outside FakePrivHelper.cpp by putting its declaration in FakePrivHelper.h.

This diff should not change behavior.

Reviewed By: simpkins

Differential Revision: D14319711

fbshipit-source-id: d7af18c316f63febe1d60f6e5aadcd4f4827cca5
2019-03-05 16:21:24 -08:00
Adam Simpkins
dba6b4193c remove redundant cast to make pyre happy
Summary:
Pyre complains about this cast being redundant.  It was needed at one point
(in D9144139) to make either pyre or mypy happy, but now neither seem to need
it and pyre actually seems to complain about it.

Reviewed By: chadaustin

Differential Revision: D14319772

fbshipit-source-id: ed252763acfe9c3c6326c6712e30d2840080454c
2019-03-05 13:08:13 -08:00
Adam Simpkins
5abf0a6aed automatically recreate bind mount source directories when necessary
Summary:
Update `edenfs` to automatically create the bind mount source directories if
they are missing.  Previously Eden would report an error and would not be able
to mount the checkout if some of the bind mount source directories were
missing.

Reviewed By: strager

Differential Revision: D14253771

fbshipit-source-id: 87ad091ccf2c0f0f72aebb50437fd7680ddbfd1c
2019-03-04 19:57:01 -08:00
Adam Simpkins
2881b784de catch exceptions while running doctor checks during "eden rage"
Summary:
Update the `eden rage` code to catch any unexpected exceptions from the
`eden doctor` logic so that it can still generate the final rage report.

Having a report that is missing the doctor information is better than failing
to generate a rage report at all.  The traceback from the `eden doctor`
exception may also help diagnose whatever issue is causing problems.

Reviewed By: chadaustin

Differential Revision: D14255648

fbshipit-source-id: 365826f22ed933f80a3cd43ddd1d66009d7032fc
2019-03-04 19:53:13 -08:00
generatedunixname89002005289445
1678b9273e Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: shannonzhu

Differential Revision: D14305975

fbshipit-source-id: 7b54441dc846165fb12bfbe5339e4c917da463ec
2019-03-04 13:03:03 -08:00
Adam Simpkins
7d5623659a update "eden doctor" to report out-of-date working directories
Summary:
Make "eden doctor" check if the process's current working directory matches
the "$PWD" environment variable, and suggest that the user run "cd / && cd -"
if they do not match.

The most common cause of this is users that cd'ed into an Eden checkout
directory before Eden was running, and then started Eden but haven't updated
their working directory since.  In this shell they will still see the contents
of the underlying mount point directory itself and not the Eden checkout
contents that have been mounted on top of it.

Reviewed By: chadaustin

Differential Revision: D14249909

fbshipit-source-id: ecfc2a56180e3a6161940e9e1ec6d94663bddbc0
2019-03-04 12:55:59 -08:00
Rick Ratmansky
593f2f29ca Revert D14114164: [Folly] Remove include of glog from Range.h
Differential Revision:
D14114164

Original commit changeset: e227609e9214

fbshipit-source-id: 99d0fde58e512224915d7a00893ddf15c547dfba
2019-03-01 06:51:52 -08:00
Yedidya Feldblum
851e90c055 Remove include of glog from Range.h
Summary: [Folly] Remove include of `glog` from `Range.h`.

Reviewed By: lbrandy, Orvid

Differential Revision: D14114164

fbshipit-source-id: e227609e9214ab39ff272e44519d34f3047fe025
2019-03-01 01:43:08 -08:00
Yedidya Feldblum
92a8e3f59f Stop checking EventBase::runInEventBaseThread result
Summary:
[Folly] Stop checking `EventBase::runInEventBaseThread` result, as the function will soon be changed not to return any result.

It returned `false` when failing to enqueue a task. But it cannot really fail anyway besides allocation failure, unless in the `EventBase` destructor and while draining and the `AlwaysEnqueue` variant is called.

Reviewed By: andriigrynenko

Differential Revision: D14254969

fbshipit-source-id: a6a9199cbafa18b61488a240e4318ce946953f51
2019-02-28 02:36:15 -08:00
Chad Austin
015c45872b split privhelper and privhelper_base
Summary:
We're not that far from building privhelper on mode/mac but it does
require figuring out how to depend on osxfuse from the Buck build, so
bypass that by breaking the inodes target's dependency on privhelper's
<fuse_ioctl.h> include.

Reviewed By: strager

Differential Revision: D14218709

fbshipit-source-id: edbb2a21df06d6f2a4f860ef13718ad05d445e98
2019-02-27 19:06:00 -08:00
Chad Austin
c70c52529a fix some includes on @mode/mac
Summary: Fix some missing includes that showed up in my mode/mac builds of parts of Eden.

Reviewed By: simpkins, strager

Differential Revision: D14213572

fbshipit-source-id: 54e070e89afdfb8479abdaa122ba76ca1d2d9ba9
2019-02-27 14:55:21 -08:00
Adam Simpkins
01490a26da improve error messages if the hg import helper fails to start
Summary:
Throw a slightly nicer error message if the hg import helper exits before
returning a `CMD_STARTED` response or an error response.

When switching from the `hg_import_helper.py` script to the
`hg debugedenimporthelper` subcommand we are slightly more likely to encounter
errors during startup.  For instance, if the repository path was not a valid
repository the `hg_import_helper.py` code would send an error message back
that the `HgImporter.cpp` code could parse.  However, we unfortunately can't
catch errors loading the repository the same way when using an `hg`
subcommand.  If it fails to load the repository it will simply print an error
message to stderr and then bail out before it invokes the
`debugedenimporthelper` code.

Reviewed By: chadaustin

Differential Revision: D14222266

fbshipit-source-id: cd60e5a61725d45a816b74f63b9969b29ade2160
2019-02-27 13:46:36 -08:00
Matt Glazar
4568ff90b7 Factor EdenMount::unmount function
Summary:
EdenMount calls fuseMount, but EdenServer calls fuseUnmount. I think only one of EdenMount or EdenServer should call fuseMount/fuseUnmount. Splitting the responsibility is confusing.

Move the call to fuseUnmount into EdenMount by creating a member function called unmount.

This diff should not change behavior.

Reviewed By: simpkins

Differential Revision: D14115385

fbshipit-source-id: 845c4a87cdba9f270c0eacaf01916ad91c3b7c0e
2019-02-26 22:54:12 -08:00
Adam Simpkins
61856d0919 enable blocking mount initialization via fault injection
Summary:
Update `EdenMount::initialize()` to perform a fault injection check.  This
allows test code to inject delays and errors into the mount initialization
flow.

Reviewed By: strager

Differential Revision: D14079491

fbshipit-source-id: be80135b0833c8f0300104524473cc3e949fec34
2019-02-26 18:43:22 -08:00
Orvid King
c2944f20d8 Shift from the file descriptor overload of EventHandler to the NetworkSocket overload
Summary: The file descriptor overload will be going away.

Reviewed By: yfeldblum

Differential Revision: D14070240

fbshipit-source-id: 20a0248fd9840629e31a3274032b889b6bb5f8de
2019-02-23 10:47:42 -08:00
Adam Simpkins
21c5e34e33 move hg_import_helper.py back to bin/, update edenfs to find it
Summary:
This reverts the change in D14188312 that moved `hg_import_helper.py` from
`bin/` to `libexec/eden/`, and instead updates edenfs to look for
`hg_import_helper.py` at `../../bin/hg_import_helper.py`

We cannot remove `hg_import_helper.py` from `/usr/local/bin` without breaking
existing running `edenfs` daemons as they will continue to look for
`hg_import_helper.py` in this location.

Rather than keeping a copy in both `bin/` and `libexec/eden` it seems better
to simply update edenfs so that it can correctly find `hg_import_helper.py`
even when edenfs itself has been installed in `libexec/eden/`

Reviewed By: strager

Differential Revision: D14197390

fbshipit-source-id: 2845bd79343bc29af9d3acbacecac4501cdb9032
2019-02-22 19:49:45 -08:00
Chad Austin
b8dc8a80c3 only include selinux on linux
Summary: We should only attempt to include selinux on Linux, not macOS.

Reviewed By: strager

Differential Revision: D14181109

fbshipit-source-id: be47b7bdadc3409577fa114559e905214848ebd8
2019-02-22 16:14:48 -08:00
Zeyi Fan
8535c7fe69 rename MononokeBackingStore to MononokeHttpBackingStore
Summary: Rename `MononokeBackingStore` to `MononokeHttpBackingStore`. Also fixed some pre-existing issues regarding copying & constants.

Reviewed By: wez, strager

Differential Revision: D14140968

fbshipit-source-id: 832ce449167584e1684031655514bba7d1435e01
2019-02-22 12:22:00 -08:00
Mark Thomas
9218f35f45 rename and relocate eden and edenfs
Summary:
The Eden CLI tool is really a control program for `edenfs`.  Rename it to
`edenfsctl` to free up the `eden` name for future use.

The Eden daemon shouldn't really be on the user's path, and instead belongs in
`libexec`.

For transition compatibility, `eden` is symlinked to `edenfsctl`.

Reviewed By: simpkins

Differential Revision: D13888875

fbshipit-source-id: 435cc63e92b85b1f28b8691e4846fbcb05bc450e
2019-02-21 15:00:47 -08:00
Matthew Glazar
d8d5eafeee Delete accidentally-committed file
.pyre_configuration.local is a file specific to Facebook's
infrastructure. Committing this file to the public Eden repo was
unintentional. Delete this file to reduce confusion.
2019-02-21 13:45:00 -08:00
Matt Glazar
b75e6d69a2 Fix typo in log message
Summary:
Before:

E0220 22:59:26.395141 837143 EdenServiceHandler.cpp:285] Error :attempt to construct an AbsolutePath from a non-absolute string: ""

After:

E0220 22:58:22.064988 1898825 EdenServiceHandler.cpp:286] Error: attempt to construct an AbsolutePath from a non-absolute string: ""

Reviewed By: chadaustin

Differential Revision: D14077849

fbshipit-source-id: ea36151d8a87012cf6b3447883217e36a6de0992
2019-02-21 00:24:56 -08:00
Lee Howes
2ee4c1d8fd Replace futures::sleep with futures::sleepUnsafe
Summary:
futures::sleep returning a Future leads to continuations easily being run on
the Timekeeper's callback. The goal is to change the return type so that
futures::sleep returns a folly::SemiFuture.

This codemod is part of the first stage:
 * Migrate all call sites off of futures::sleep and onto futures::sleepUnsafe.

 This will be followed by:
  * Changing the return type of futures::sleep to folly::SemiFuture.
  * Migrating callers, where clearly safe such as when they follow with .via or
    .semi() from sleepUnsafe to sleep.
  * Migrating remaining callers.

Reviewed By: yfeldblum

Differential Revision: D14152623

fbshipit-source-id: bc6874e4320e4a7352ac61b20d9750458e2cbbff
2019-02-20 21:37:15 -08:00
Matt Glazar
900ca6f88d Fix EdenMount leak with racing shutdown and destroy
Summary:
If EdenMount::shutdown is in progress and EdenMount::destroy is called [1], the EdenMount object won't ever be deleted. A comment in EdenMount::destroy claims that EdenMount::shutdown will delete the EdenMount object, but the comment is wrong:

    case State::SHUTTING_DOWN:
      // Nothing else to do.  shutdown() will destroy us when it completes.
      return;

This leak is probably benign, but the leak checker can cause tests to fail spuriously. I think the leak currently can't happen for EdenServer's mounts, but in the future the leak might occur and cause problems.

Make EdenMount::shutdown delete the EdenMount if EdenMount::destroy was called. This fixes the leak.

[1] EdenMount::destroy is called by EdenMountDeleter when the last std::shared_ptr<EdenMount> is destroyed.

Reviewed By: simpkins

Differential Revision: D14015024

fbshipit-source-id: 39a0ba78bb00afb5f0363fe5c74dbec00f9d68e3
2019-02-20 14:01:04 -08:00