Browse Source

Restore behaviour of checking for control socket file and re-creating it

Dinit 0.16.x, after starting a "starts-rwfs"-marked service, will check
whether the control socket file still exists even if it has already
managed to create the control socket. If it doesn't exist the socket
will be closed and then re-created.

This behavior was removed since, but since this may lead to surprise
boot failures if services are not configured correctly, I am restoring
the behaviour.

See #148
Davin McCall 1 year ago
parent
commit
19c832af6c
2 changed files with 7 additions and 5 deletions
  1. 3 0
      doc/manpages/dinit-service.5.m4
  2. 4 5
      src/dinit.cc

+ 3 - 0
doc/manpages/dinit-service.5.m4

@@ -482,6 +482,9 @@ This prompts Dinit to attempt to create its control socket, if it has not alread
 and similarly log boot time to the system \fBwtmp\fR(5) database (if supported) if not yet done.
 This option may be specified on multiple services, which may be useful if the wtmp database becomes
 writable at a different stage than the control socket location becomes writable, for example.
+If the control socket has already been created, this option currently causes Dinit to check that
+the socket "file" still exists and re-create it if not. It is not recommended to rely on this
+behaviour.
 .TP
 \fBstarts\-log\fR
 This service starts the system log daemon.

+ 4 - 5
src/dinit.cc

@@ -786,7 +786,8 @@ static void control_socket_cb(eventloop_t *loop, int sockfd) noexcept
     }
 }
 
-static void control_socket_ready() noexcept {
+static void control_socket_ready() noexcept
+{
     if (!control_socket_open || socket_ready_fd < 0) {
         return;
     }
@@ -802,10 +803,8 @@ static void control_socket_ready() noexcept {
 // Callback when the root filesystem is read/write:
 void rootfs_is_rw() noexcept
 {
-    if (!control_socket_open) {
-        open_control_socket(true);
-        control_socket_ready();
-    }
+    open_control_socket(true);
+    control_socket_ready();
     if (!log_is_syslog) {
         setup_external_log();
     }