Skip to content

Commit 174a546

Browse files
dkulpclaude
andcommitted
fix(boot): drop the redundant auto-bootDelay network poll
In auto bootDelay mode, handleBootDelay() polled up to 5 seconds for an NTP-capable interface before postNetwork's concurrent audio/network threads even started -- serial dead time on every boot, and a flat 5s loss on a box with no network at all (which then paid the link-wait timeout again anyway). The poll was load-bearing when it was added: waitForInterfacesUp() then bailed out instantly if no interface had link yet, so a fast-booting board could skip the IP/NTP wait before its NIC came up. Since the June rework, waitForInterfacesUp() itself waits up to half its timeout for link before deciding anything, and handleTimeSyncWait() re-checks for an NTP-capable interface after that wait -- so the pre-poll's verdict was computed and then discarded. Verified on a Pi 5 booting with the network not yet up: the in-function link wait catches it (3s) and the time-sync path proceeds normally. Also give announceIPAddresses() a bounded wait for an address: the boot IP wait can time out with the DHCP lease landing moments later, and the announce service previously assumed the address was already there and silently skipped announcing. It runs off fppd's critical path, so waiting there is free. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 21fb472 commit 174a546

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/boot/FPPINIT.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,11 @@ int main(int argc, char* argv[]) {
371371
removeDummyInterface();
372372
checkWLANInterface();
373373
removeDummyInterface();
374-
waitForInterfacesUp(100, true); // wait for an IP (needed for the time-sync wait); boot path may recover a dead USB adapter
374+
// Wait for an actual IP, not just link: fppd starts right after
375+
// this service and needs the address in place (socket binds,
376+
// MultiSync), and the time-sync wait below may need the network
377+
// too. The boot path may also recover a dead USB adapter.
378+
waitForInterfacesUp(100, true);
375379
// A wedged USB adapter has queued a reboot. Everything below is
376380
// setup for a boot that is about to end, and this service is on
377381
// fppd's dependency chain -- overrunning its start timeout here

src/boot/FPPINIT_Network.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -755,26 +755,15 @@ void handleBootDelay() {
755755
unlink(delayFile.c_str());
756756
unlink(skipFile.c_str());
757757
} else if (i == -1) {
758-
// Auto mode: check if we have any network interfaces that could get NTP
759-
// If not, skip the time wait entirely and clean up flag file now
760-
761-
// On a Pi5, it takes about 4.1s from when fppinit is called to when eth0
762-
// will report a link up. Since we want to wait for NTP if the network is
763-
// available, we need to wait
764-
const auto processor_count = std::thread::hardware_concurrency();
765-
if (processor_count > 2) {
766-
int count = 0;
767-
while (!hasNetworkInterfaceForNTP() && count < 50) {
768-
std::this_thread::sleep_for(std::chrono::milliseconds(100));
769-
count++;
770-
}
771-
if (!hasNetworkInterfaceForNTP()) {
772-
printf("FPP - No network interface found, skipping boot delay\n");
773-
unlink(delayFile.c_str());
774-
unlink(skipFile.c_str());
775-
return;
776-
}
777-
}
758+
// Auto mode: nothing to wait on here. The is-there-an-NTP-capable-network
759+
// decision and the quick SNTP set both happen in handleTimeSyncWait(),
760+
// which runs on the network thread after waitForInterfacesUp() has
761+
// already waited for link/IP properly. This used to pre-poll up to 5s
762+
// for an interface, but that only serialized boot ahead of the
763+
// concurrent audio/network threads and its verdict was recomputed
764+
// later anyway. Just clean up any stale flag files.
765+
unlink(delayFile.c_str());
766+
unlink(skipFile.c_str());
778767
}
779768
}
780769

@@ -1193,6 +1182,13 @@ void announceIPAddresses() {
11931182
return;
11941183
}
11951184
std::string announce = buildIPAnnounceString();
1185+
// postNetwork's IP wait can time out with the DHCP lease landing moments
1186+
// later; this service is off fppd's critical path, so give the address a
1187+
// bounded chance to appear rather than silently skipping the announcement.
1188+
for (int i = 0; announce.empty() && i < 75; ++i) {
1189+
std::this_thread::sleep_for(std::chrono::milliseconds(200));
1190+
announce = buildIPAnnounceString();
1191+
}
11961192
if (announce.empty()) {
11971193
printf("FPP - announceIP: no usable IP address to announce\n");
11981194
return;

0 commit comments

Comments
 (0)