From: Davin McCall Date: Sat, 29 Jun 2019 03:41:38 +0000 (+1000) Subject: Re-create control socket file node if it disappears. X-Git-Tag: v0.5.2~3 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1a682f27306d19c29476f262e00de86409609895;p=oweals%2Fdinit.git Re-create control socket file node if it disappears. In case something is mounted over /dev (or wherever the control socket lives) it will become inaccessible. When a starts-rwfs service starts, check the socket node still exists and if not, close the socket and re-open. Cherry-picked from development branch. --- diff --git a/src/dinit.cc b/src/dinit.cc index 93809df..1bff5dc 100644 --- a/src/dinit.cc +++ b/src/dinit.cc @@ -660,6 +660,17 @@ void rootfs_is_rw() noexcept // once the socket has been successfully opened, further calls have no effect. static void open_control_socket(bool report_ro_failure) noexcept { + if (control_socket_open) { + struct stat stat_buf; + if (stat(control_socket_path, &stat_buf) != 0 && errno == ENOENT) { + // Looks like our control socket has disappeared from the filesystem. Close our control + // socket and re-create it: + control_socket_io.deregister(event_loop); + close(control_socket_io.get_watched_fd()); + control_socket_open = false; // now re-open below + } + } + if (! control_socket_open) { const char * saddrname = control_socket_path; size_t saddrname_len = strlen(saddrname);