Loading init/firmware_handler.cpp +4 −19 Original line number Original line Diff line number Diff line Loading @@ -110,19 +110,9 @@ void HandleFirmwareEvent(const Uevent& uevent) { if (uevent.subsystem != "firmware" || uevent.action != "add") return; if (uevent.subsystem != "firmware" || uevent.action != "add") return; // Loading the firmware in a child means we can do that in parallel... // Loading the firmware in a child means we can do that in parallel... // We double fork instead of waiting for these processes. auto pid = fork(); pid_t pid = fork(); if (pid == -1) { if (pid == -1) { PLOG(ERROR) << "could not fork to process firmware event for " << uevent.firmware; PLOG(ERROR) << "could not fork to process firmware event for " << uevent.firmware; return; } if (pid == 0) { pid = fork(); if (pid == -1) { PLOG(ERROR) << "could not fork a sceond time to process firmware event for " << uevent.firmware; _exit(EXIT_FAILURE); } } if (pid == 0) { if (pid == 0) { Timer t; Timer t; Loading @@ -130,11 +120,6 @@ void HandleFirmwareEvent(const Uevent& uevent) { LOG(INFO) << "loading " << uevent.path << " took " << t; LOG(INFO) << "loading " << uevent.path << " took " << t; _exit(EXIT_SUCCESS); _exit(EXIT_SUCCESS); } } _exit(EXIT_SUCCESS); } waitpid(pid, nullptr, 0); } } } // namespace init } // namespace init Loading init/ueventd.cpp +7 −0 Original line number Original line Diff line number Diff line Loading @@ -268,6 +268,13 @@ int ueventd_main(int argc, char** argv) { cold_boot.Run(); cold_boot.Run(); } } // We use waitpid() in ColdBoot, so we can't ignore SIGCHLD until now. signal(SIGCHLD, SIG_IGN); // Reap and pending children that exited between the last call to waitpid() and setting SIG_IGN // for SIGCHLD above. while (waitpid(-1, nullptr, WNOHANG) > 0) { } uevent_listener.Poll([&device_handler](const Uevent& uevent) { uevent_listener.Poll([&device_handler](const Uevent& uevent) { HandleFirmwareEvent(uevent); HandleFirmwareEvent(uevent); device_handler.HandleDeviceEvent(uevent); device_handler.HandleDeviceEvent(uevent); Loading Loading
init/firmware_handler.cpp +4 −19 Original line number Original line Diff line number Diff line Loading @@ -110,19 +110,9 @@ void HandleFirmwareEvent(const Uevent& uevent) { if (uevent.subsystem != "firmware" || uevent.action != "add") return; if (uevent.subsystem != "firmware" || uevent.action != "add") return; // Loading the firmware in a child means we can do that in parallel... // Loading the firmware in a child means we can do that in parallel... // We double fork instead of waiting for these processes. auto pid = fork(); pid_t pid = fork(); if (pid == -1) { if (pid == -1) { PLOG(ERROR) << "could not fork to process firmware event for " << uevent.firmware; PLOG(ERROR) << "could not fork to process firmware event for " << uevent.firmware; return; } if (pid == 0) { pid = fork(); if (pid == -1) { PLOG(ERROR) << "could not fork a sceond time to process firmware event for " << uevent.firmware; _exit(EXIT_FAILURE); } } if (pid == 0) { if (pid == 0) { Timer t; Timer t; Loading @@ -130,11 +120,6 @@ void HandleFirmwareEvent(const Uevent& uevent) { LOG(INFO) << "loading " << uevent.path << " took " << t; LOG(INFO) << "loading " << uevent.path << " took " << t; _exit(EXIT_SUCCESS); _exit(EXIT_SUCCESS); } } _exit(EXIT_SUCCESS); } waitpid(pid, nullptr, 0); } } } // namespace init } // namespace init Loading
init/ueventd.cpp +7 −0 Original line number Original line Diff line number Diff line Loading @@ -268,6 +268,13 @@ int ueventd_main(int argc, char** argv) { cold_boot.Run(); cold_boot.Run(); } } // We use waitpid() in ColdBoot, so we can't ignore SIGCHLD until now. signal(SIGCHLD, SIG_IGN); // Reap and pending children that exited between the last call to waitpid() and setting SIG_IGN // for SIGCHLD above. while (waitpid(-1, nullptr, WNOHANG) > 0) { } uevent_listener.Poll([&device_handler](const Uevent& uevent) { uevent_listener.Poll([&device_handler](const Uevent& uevent) { HandleFirmwareEvent(uevent); HandleFirmwareEvent(uevent); device_handler.HandleDeviceEvent(uevent); device_handler.HandleDeviceEvent(uevent); Loading