mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Minor ForkClient
improvements
- Use a `constexpr inline` string constant for the forkserver env var - Add annotation for the comms channel mutex PiperOrigin-RevId: 335395005 Change-Id: Ic058c19c3704f182aa7ed7b8e8964b2fc5082800
This commit is contained in:
parent
569c7d84b0
commit
b74cf8839b
|
@ -20,8 +20,6 @@
|
|||
|
||||
namespace sandbox2 {
|
||||
|
||||
const char kForkServerDisableEnv[] = "SANDBOX2_NOFORKSERVER";
|
||||
|
||||
pid_t ForkClient::SendRequest(const ForkRequest& request, int exec_fd,
|
||||
int comms_fd, int user_ns_fd, pid_t* init_pid) {
|
||||
// Acquire the channel ownership for this request (transaction).
|
||||
|
|
|
@ -17,34 +17,35 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/base/thread_annotations.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
|
||||
namespace sandbox2 {
|
||||
|
||||
// Envvar indicating that this process should not start the fork-server.
|
||||
ABSL_CONST_INIT extern const char kForkServerDisableEnv[];
|
||||
constexpr inline char kForkServerDisableEnv[] = "SANDBOX2_NOFORKSERVER";
|
||||
|
||||
class Comms;
|
||||
class ForkRequest;
|
||||
|
||||
class ForkClient {
|
||||
public:
|
||||
explicit ForkClient(Comms* comms) : comms_(comms) {}
|
||||
|
||||
ForkClient(const ForkClient&) = delete;
|
||||
ForkClient& operator=(const ForkClient&) = delete;
|
||||
|
||||
explicit ForkClient(Comms* comms) : comms_(comms) {}
|
||||
|
||||
// Sends the fork request over the supplied Comms channel.
|
||||
pid_t SendRequest(const ForkRequest& request, int exec_fd, int comms_fd,
|
||||
int user_ns_fd = -1, pid_t* init_pid = nullptr);
|
||||
|
||||
private:
|
||||
// Comms channel connecting with the ForkServer. Not owned by the object.
|
||||
Comms* comms_;
|
||||
Comms* comms_ ABSL_GUARDED_BY(comms_mutex_);
|
||||
// Mutex locking transactions (requests) over the Comms channel.
|
||||
absl::Mutex comms_mutex_;
|
||||
};
|
||||
|
||||
} // namespace sandbox2
|
||||
|
||||
#endif // SANDBOXED_API_SANDBOX2_FORK_CLIENT_H_
|
||||
|
|
Loading…
Reference in New Issue
Block a user