Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 409c6eec authored by Alex Vakulenko's avatar Alex Vakulenko
Browse files

Make init process create PDX sockets for services

To help us control the creation of PDX sockets and properly labeling
them for SELinux, let the init process create sockets for us based on
the settings specified in .rc files for service processes.

For (test) services that are meant to be started manually from command
line (e.g. test services), keep the old functionality as an option so
that UDS endpoint can be created in a way that it automatically creates
the socket in the service itself.

Bug: 35220925
Test: `m -j32` succeeds. Ran sailfish in VR mode and made sure all the
      services (surfaceflinger, performanced, sensord, bufferhub).
      `m -j32 checkbuild` succeeds as well.

Change-Id: Ief733b41b534cea19b1bea31de76b06051aa50ab
parent 585e32fa
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ cc_binary {
        "pdx_benchmarks.cpp",
    ],
    shared_libs: [
        "libbase",
        "libchrome",
        "libcutils",
        "liblog",
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ cc_library_static {
        "service_endpoint.cpp",
    ],
    static_libs: [
        "libcutils",
        "libbase",
        "libpdx",
    ],
}
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ ChannelEventSet::ChannelEventSet() {
  const int flags = EFD_CLOEXEC | EFD_NONBLOCK;
  LocalHandle epoll_fd, event_fd;

  if (!SetupHandle(epoll_create(1), &epoll_fd, "epoll") ||
  if (!SetupHandle(epoll_create1(EPOLL_CLOEXEC), &epoll_fd, "epoll") ||
      !SetupHandle(eventfd(0, flags), &event_fd, "event")) {
    return;
  }
+2 −1
Original line number Diff line number Diff line
@@ -107,7 +107,8 @@ class Endpoint : public pdx::Endpoint {
  };

  // This class must be instantiated using Create() static methods above.
  Endpoint(const std::string& endpoint_path, bool blocking);
  Endpoint(const std::string& endpoint_path, bool blocking,
           bool use_init_socket_fd = true);

  Endpoint(const Endpoint&) = delete;
  void operator=(const Endpoint&) = delete;
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ ServiceDispatcher::ServiceDispatcher() {
    return;
  }

  epoll_fd_.Reset(epoll_create(1));  // Size arg is ignored, but must be > 0.
  epoll_fd_.Reset(epoll_create1(EPOLL_CLOEXEC));
  if (!epoll_fd_) {
    ALOGE("Failed to create epoll fd because: %s\n", strerror(errno));
    return;
Loading