mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
0c3d6232e3
Summary: This adds a new class which listens on a Unix domain socket for clients that wish to gracefully take over Eden's FUSE mount points. The goal is to eventually enable graceful restart functionality for eden. It would be nice if we could use the existing thrift server socket for this, but thrift doesn't provide low-enough level APIs so that we can send credentials and file descriptors over the socket using SCM_CREDENTIALS and SCM_RIGHTS. Using our own separate socket is the easiest way to accomplish this instead. For now eden just listens on this socket and logs a message when a client connects; this diff does not yet contain logic for performing mount point takeover. Reviewed By: bolinfest Differential Revision: D5827752 fbshipit-source-id: 928e541efa2546cb612da2699ff0bd822bafaad5
63 lines
1.5 KiB
C++
63 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2016-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include <folly/io/async/AsyncServerSocket.h>
|
|
#include <memory>
|
|
|
|
#include "eden/fs/utils/PathFuncs.h"
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
class TakeoverData;
|
|
class TakeoverHandler;
|
|
|
|
/**
|
|
* A helper class that listens on a unix domain socket for clients that
|
|
* wish to perform graceful takeover of this EdenServer's mount points.
|
|
*/
|
|
class TakeoverServer : private folly::AsyncServerSocket::AcceptCallback {
|
|
public:
|
|
explicit TakeoverServer(
|
|
folly::EventBase* eventBase,
|
|
AbsolutePathPiece socketPath,
|
|
TakeoverHandler* handler);
|
|
virtual ~TakeoverServer() override;
|
|
|
|
void start();
|
|
|
|
TakeoverHandler* getTakeoverHandler() const {
|
|
return handler_;
|
|
}
|
|
|
|
private:
|
|
class ConnHandler;
|
|
|
|
folly::EventBase* getEventBase() const {
|
|
return eventBase_;
|
|
}
|
|
|
|
// AcceptCallback methods
|
|
void connectionAccepted(
|
|
int fd,
|
|
const folly::SocketAddress& clientAddr) noexcept override;
|
|
void acceptError(const std::exception& ex) noexcept override;
|
|
|
|
void connectionDone(ConnHandler* handler);
|
|
|
|
folly::EventBase* eventBase_{nullptr};
|
|
TakeoverHandler* handler_{nullptr};
|
|
AbsolutePath socketPath_;
|
|
folly::AsyncServerSocket::UniquePtr socket_;
|
|
};
|
|
} // namespace eden
|
|
} // namespace facebook
|