Revert "init: Rename 'cgroups_activated' into 'fifo'"
Revert commit 9c61dad67e06a17d1ee44bbb931d412cd98a2212 in preparation of
introducing a second interprocess communication channel.
Bug: 213617178
Change-Id: I2959a3902a1b994cca2ac99855be1fc60d63bcbb
Signed-off-by: Bart Van Assche <bvanassche@google.com>
diff --git a/init/service.cpp b/init/service.cpp
index c260c07..331cd88 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -506,7 +506,8 @@
}
// Enters namespaces, sets environment variables, writes PID files and runs the service executable.
-void Service::RunService(const std::vector<Descriptor>& descriptors, InterprocessFifo fifo) {
+void Service::RunService(const std::vector<Descriptor>& descriptors,
+ InterprocessFifo cgroups_activated) {
if (auto result = EnterNamespaces(namespaces_, name_, mount_namespace_); !result.ok()) {
LOG(FATAL) << "Service '" << name_ << "' failed to set up namespaces: " << result.error();
}
@@ -528,11 +529,11 @@
// Wait until the cgroups have been created and until the cgroup controllers have been
// activated.
- Result<uint8_t> byte = fifo.Read();
+ Result<uint8_t> byte = cgroups_activated.Read();
if (!byte.ok()) {
LOG(ERROR) << name_ << ": failed to read from notification channel: " << byte.error();
}
- fifo.Close();
+ cgroups_activated.Close();
if (!*byte) {
LOG(FATAL) << "Service '" << name_ << "' failed to start due to a fatal error";
_exit(EXIT_FAILURE);
@@ -597,8 +598,11 @@
return {};
}
- InterprocessFifo fifo;
- OR_RETURN(fifo.Initialize());
+ InterprocessFifo cgroups_activated;
+
+ if (Result<void> result = cgroups_activated.Initialize(); !result.ok()) {
+ return result;
+ }
if (Result<void> result = CheckConsole(); !result.ok()) {
return result;
@@ -656,11 +660,11 @@
if (pid == 0) {
umask(077);
- fifo.CloseWriteFd();
- RunService(descriptors, std::move(fifo));
+ cgroups_activated.CloseWriteFd();
+ RunService(descriptors, std::move(cgroups_activated));
_exit(127);
} else {
- fifo.CloseReadFd();
+ cgroups_activated.CloseReadFd();
}
if (pid < 0) {
@@ -689,7 +693,7 @@
limit_percent_ != -1 || !limit_property_.empty();
errno = -createProcessGroup(proc_attr_.uid, pid_, use_memcg);
if (errno != 0) {
- Result<void> result = fifo.Write(0);
+ Result<void> result = cgroups_activated.Write(0);
if (!result.ok()) {
return Error() << "Sending notification failed: " << result.error();
}
@@ -713,7 +717,7 @@
LmkdRegister(name_, proc_attr_.uid, pid_, oom_score_adjust_);
}
- if (Result<void> result = fifo.Write(1); !result.ok()) {
+ if (Result<void> result = cgroups_activated.Write(1); !result.ok()) {
return Error() << "Sending cgroups activated notification failed: " << result.error();
}