mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
6f60c48ea8
Summary: Requiring that callers ensure that ObjectFetchContext outlives the asynchronous result is a burden and a memory-safety risk. Without Rust's borrow checker, we can't feel confident this is safe under all error and timeout conditions. It also requires we use folly::collectAll and collectAllSafe, which means that an error during fanout has to wait until the fanout completes before we can report the error to our caller. Moreover, tying the ObjectFetchContext's lifetime to the FUSE/NFS/Thrift/etc. request's lifetime gives us incorrect statistics about how long the request takes. I consider this an API design mistake (on my part). Correct the situation by decoupling ObjectFetchContext from RequestContext, and begin reference-counting ObjectFetchContext. This does increase the number of atomic RMW operations, but we can alleviate those where they matter by manually checking *Future::isReady() before calling .then*. Reviewed By: xavierd Differential Revision: D40744706 fbshipit-source-id: 5baf654f6d65790ed0cafb45c0bc7f2aaa8ecec2
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "eden/fs/inodes/RequestContext.h"
|
|
|
|
namespace facebook::eden {
|
|
|
|
class NfsRequestContext : public RequestContext {
|
|
public:
|
|
/**
|
|
* Constructs a new NfsRequestContext. The context should live for the
|
|
* duration of the NFS request.
|
|
* `startRequest` should be called at the beginning and `finishRequest` at the
|
|
* end of the request. The `causeDetail` is copied as is and thus the lifetime
|
|
* of the underlying string must exceed the lifetime of the NfsRequestContext.
|
|
* The caller is responsible for ensuring this.
|
|
*/
|
|
explicit NfsRequestContext(
|
|
uint32_t xid,
|
|
std::string_view causeDetail,
|
|
ProcessAccessLog& processAccessLog);
|
|
|
|
NfsRequestContext(const NfsRequestContext&) = delete;
|
|
NfsRequestContext& operator=(const NfsRequestContext&) = delete;
|
|
NfsRequestContext(NfsRequestContext&&) = delete;
|
|
NfsRequestContext& operator=(NfsRequestContext&&) = delete;
|
|
|
|
uint32_t getXid() const {
|
|
return xid_;
|
|
}
|
|
|
|
private:
|
|
uint32_t xid_;
|
|
};
|
|
|
|
} // namespace facebook::eden
|