Skip to content

Commit f7130d2

Browse files
sroettgercopybara-github
authored andcommitted
Move Sandbox2RPCChannel constructors and destructor out-of-line.
Move the definitions of Sandbox2RPCChannel's constructors and destructor from the header file to the source file so that the unique_ptr destructor knows the size of the comms class. PiperOrigin-RevId: 966519206 Change-Id: I65bee2a2f354b6b9d8f78ffd25c30e2270072985
1 parent 4a607e2 commit f7130d2

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

sandboxed_api/sandbox2_rpcchannel.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@
4545
namespace sapi {
4646
using sapi::file_util::fileops::FDCloser;
4747

48+
Sandbox2RPCChannel::Sandbox2RPCChannel(sandbox2::Comms* comms, pid_t pid)
49+
: comms_(comms), pid_(pid) {}
50+
51+
Sandbox2RPCChannel::Sandbox2RPCChannel(std::unique_ptr<sandbox2::Comms> comms,
52+
pid_t pid)
53+
: owned_comms_(std::move(comms)), comms_(owned_comms_.get()), pid_(pid) {}
54+
55+
Sandbox2RPCChannel::~Sandbox2RPCChannel() = default;
56+
4857
absl::Status Sandbox2RPCChannel::Call(const FuncCall& call, uint32_t tag,
4958
FuncRet* ret, v::Type exp_type) {
5059
RecursiveMutexLock lock(mutex_);

sandboxed_api/sandbox2_rpcchannel.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <cstddef>
2424
#include <cstdint>
2525
#include <memory>
26-
#include <utility>
2726

2827
#include "absl/base/optimization.h"
2928
#include "absl/base/thread_annotations.h"
@@ -105,8 +104,8 @@ namespace sapi {
105104
// Comms channel.
106105
class Sandbox2RPCChannel : public RPCChannel {
107106
public:
108-
explicit Sandbox2RPCChannel(sandbox2::Comms* comms, pid_t pid)
109-
: comms_(comms), pid_(pid) {}
107+
explicit Sandbox2RPCChannel(sandbox2::Comms* comms, pid_t pid);
108+
~Sandbox2RPCChannel() override;
110109

111110
// Calls a function.
112111
absl::Status Call(const FuncCall& call, uint32_t tag, FuncRet* ret,
@@ -165,8 +164,8 @@ class Sandbox2RPCChannel : public RPCChannel {
165164
static constexpr size_t kMaxCallbacks = 64;
166165
static constexpr size_t kTrampolineSize = 16;
167166

168-
explicit Sandbox2RPCChannel(std::unique_ptr<sandbox2::Comms> comms, pid_t pid)
169-
: owned_comms_(std::move(comms)), comms_(owned_comms_.get()), pid_(pid) {}
167+
explicit Sandbox2RPCChannel(std::unique_ptr<sandbox2::Comms> comms,
168+
pid_t pid);
170169

171170
// Marks the memory as initialized (used with MSAN).
172171
absl::Status MarkMemoryInit(void* addr, size_t size);

0 commit comments

Comments
 (0)