summaryrefslogtreecommitdiff
path: root/init/firmware_handler.cpp
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2017-06-30 12:58:39 -0700
committerTom Cherry <tomcherry@google.com>2017-07-05 16:41:11 -0700
commit0f296e06d6a4c26e7886b98964057ddbc9070c6e (patch)
treecdb8d55474f611e4f25889cd0e782abdface88b8 /init/firmware_handler.cpp
parentc70bf5836c1d6b734af270ed7b3b8a9b425b83b9 (diff)
ueventd: don't double fork firmware handlers
ueventd may be asked to handle firmware during the time critical coldboot process. If we double fork to avoid needing to reap the firmware handler, then we may add significant delay to this process, as the first child may not get scheduled quickly enough for waitpid() to complete without delay. Bug: 63081260 Test: boot bullhead and sailfish, check that firmwares are loaded, no zombie ueventd processes remain, and no new errors are shown Change-Id: I2bac3b1fbc3a58557a00326e491c104656db27ae
Diffstat (limited to 'init/firmware_handler.cpp')
-rw-r--r--init/firmware_handler.cpp23
1 files changed, 4 insertions, 19 deletions
diff --git a/init/firmware_handler.cpp b/init/firmware_handler.cpp
index 8cd5cc5f9..860b30bc2 100644
--- a/init/firmware_handler.cpp
+++ b/init/firmware_handler.cpp
@@ -110,31 +110,16 @@ void HandleFirmwareEvent(const Uevent& uevent) {
if (uevent.subsystem != "firmware" || uevent.action != "add") return;
// Loading the firmware in a child means we can do that in parallel...
- // We double fork instead of waiting for these processes.
- pid_t pid = fork();
+ auto pid = fork();
if (pid == -1) {
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) {
- Timer t;
- ProcessFirmwareEvent(uevent);
- LOG(INFO) << "loading " << uevent.path << " took " << t;
- _exit(EXIT_SUCCESS);
- }
-
+ Timer t;
+ ProcessFirmwareEvent(uevent);
+ LOG(INFO) << "loading " << uevent.path << " took " << t;
_exit(EXIT_SUCCESS);
}
-
- waitpid(pid, nullptr, 0);
}
} // namespace init