diff options
author | Elliott Hughes <enh@google.com> | 2015-04-25 02:57:36 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-04-25 02:57:36 +0000 |
commit | 52e5e55cac4e630e4eac59c387815aa307194540 (patch) | |
tree | 929ee7e8458134c5427a1a9b456cbeeabeb7788c | |
parent | 799d8a165ba2b7a14274996bba56a627f278e2a3 (diff) | |
parent | 0a4f0be2aaf697ca4b0938b31fc19bb007e87d0d (diff) | |
download | system_core-52e5e55cac4e630e4eac59c387815aa307194540.zip system_core-52e5e55cac4e630e4eac59c387815aa307194540.tar.gz system_core-52e5e55cac4e630e4eac59c387815aa307194540.tar.bz2 |
am 0a4f0be2: am df5d4482: Merge "Clean up property service initialization."
* commit '0a4f0be2aaf697ca4b0938b31fc19bb007e87d0d':
Clean up property service initialization.
-rw-r--r-- | init/init.cpp | 56 | ||||
-rw-r--r-- | init/property_service.cpp | 14 |
2 files changed, 27 insertions, 43 deletions
diff --git a/init/init.cpp b/init/init.cpp index dccd6a2..4ed23b6 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -603,14 +603,16 @@ void execute_one_command() { } } -static int wait_for_coldboot_done_action(int nargs, char **args) -{ - int ret; - INFO("wait for %s\n", COLDBOOT_DONE); - ret = wait_for_file(COLDBOOT_DONE, COMMAND_RETRY_TIMEOUT); - if (ret) +static int wait_for_coldboot_done_action(int nargs, char **args) { + Timer t; + + NOTICE("Waiting for %s...\n", COLDBOOT_DONE); + if (wait_for_file(COLDBOOT_DONE, COMMAND_RETRY_TIMEOUT)) { ERROR("Timed out waiting for %s\n", COLDBOOT_DONE); - return ret; + } + + NOTICE("Waiting for %s took %.2fs.\n", COLDBOOT_DONE, t.duration()); + return 0; } /* @@ -832,22 +834,6 @@ static void process_kernel_cmdline(void) import_kernel_cmdline(1, import_kernel_nv); } -static int property_service_init_action(int nargs, char **args) -{ - /* read any property files on system or data and - * fire up the property service. This must happen - * after the ro.foo properties are set above so - * that /data/local.prop cannot interfere with them. - */ - start_property_service(); - if (get_property_set_fd() < 0) { - ERROR("start_property_service() failed\n"); - exit(1); - } - - return 0; -} - static int queue_property_triggers_action(int nargs, char **args) { queue_all_property_triggers(); @@ -856,7 +842,7 @@ static int queue_property_triggers_action(int nargs, char **args) return 0; } -void selinux_init_all_handles(void) +static void selinux_init_all_handles(void) { sehandle = selinux_android_file_context_handle(); selinux_android_set_sehandle(sehandle); @@ -1054,12 +1040,15 @@ int main(int argc, char** argv) { signal_init(); property_load_boot_defaults(); + start_property_service(); init_parse_config_file("/init.rc"); action_for_each_trigger("early-init", action_add_queue_tail); + // Queue an action that waits for coldboot done so we know ueventd has set up all of /dev... queue_builtin_action(wait_for_coldboot_done_action, "wait_for_coldboot_done"); + // ... so that we can start queuing up actions that require stuff from /dev. queue_builtin_action(mix_hwrng_into_linux_rng_action, "mix_hwrng_into_linux_rng"); queue_builtin_action(keychord_init_action, "keychord_init"); queue_builtin_action(console_init_action, "console_init"); @@ -1070,7 +1059,6 @@ int main(int argc, char** argv) { // Repeat mix_hwrng_into_linux_rng in case /dev/hw_random or /dev/random // wasn't ready immediately after wait_for_coldboot_done queue_builtin_action(mix_hwrng_into_linux_rng_action, "mix_hwrng_into_linux_rng"); - queue_builtin_action(property_service_init_action, "property_service_init"); // Don't mount filesystems or start core system services in charger mode. char bootmode[PROP_VALUE_MAX]; @@ -1083,26 +1071,19 @@ int main(int argc, char** argv) { // Run all property triggers based on current state of the properties. queue_builtin_action(queue_property_triggers_action, "queue_property_triggers"); - // TODO: why do we only initialize ufds after execute_one_command and restart_processes? size_t fd_count = 0; struct pollfd ufds[3]; ufds[fd_count++] = { .fd = get_signal_fd(), .events = POLLIN, .revents = 0 }; - bool property_set_fd_init = false; + ufds[fd_count++] = { .fd = get_property_set_fd(), .events = POLLIN, .revents = 0 }; + // TODO: can we work out when /dev/keychord is first accessible and open this fd then? bool keychord_fd_init = false; - for (;;) { + while (true) { if (!waiting_for_exec) { execute_one_command(); restart_processes(); } - if (!property_set_fd_init && get_property_set_fd() > 0) { - ufds[fd_count].fd = get_property_set_fd(); - ufds[fd_count].events = POLLIN; - ufds[fd_count].revents = 0; - fd_count++; - property_set_fd_init = true; - } if (!keychord_fd_init && get_keychord_fd() > 0) { ufds[fd_count].fd = get_keychord_fd(); ufds[fd_count].events = POLLIN; @@ -1124,8 +1105,11 @@ int main(int argc, char** argv) { bootchart_sample(&timeout); - int nr = poll(ufds, fd_count, timeout); + int nr = TEMP_FAILURE_RETRY(poll(ufds, fd_count, timeout)); if (nr <= 0) { + if (nr == -1) { + ERROR("poll failed: %s\n", strerror(errno)); + } continue; } diff --git a/init/property_service.cpp b/init/property_service.cpp index 8544951..94c5fd9 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -519,14 +519,14 @@ void load_all_props() { } void start_property_service() { - int fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM, 0666, 0, 0, NULL); - if (fd == -1) return; - - fcntl(fd, F_SETFD, FD_CLOEXEC); - fcntl(fd, F_SETFL, O_NONBLOCK); + property_set_fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, + 0666, 0, 0, NULL); + if (property_set_fd == -1) { + ERROR("start_property_service socket creation failed: %s\n", strerror(errno)); + exit(1); + } - listen(fd, 8); - property_set_fd = fd; + listen(property_set_fd, 8); } int get_property_set_fd() { |