Fix: timeout 2s sur nmcli dans get_config_sqlite pour eviter blocage

Si nmcli est lent ou bloque, on garde la valeur DB au lieu de
freezer toutes les pages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
PaulVua
2026-03-17 18:12:15 +01:00
parent c83f8396aa
commit 2949c78b56

View File

@@ -67,13 +67,11 @@ if ($type == "get_config_sqlite") {
}
// Detect real WiFi status from wlan0 (DB value may be stale)
$wlan0_conn = trim(shell_exec("nmcli -t -f GENERAL.CONNECTION device show wlan0 2>/dev/null | cut -d: -f2"));
if (!empty($wlan0_conn) && $wlan0_conn !== '--') {
// Use timeout to prevent blocking if nmcli hangs
$wlan0_conn = trim(shell_exec("timeout 2 nmcli -t -f GENERAL.CONNECTION device show wlan0 2>/dev/null | cut -d: -f2"));
if ($wlan0_conn !== null && $wlan0_conn !== '' && $wlan0_conn !== '--') {
$is_hotspot = (stripos($wlan0_conn, 'hotspot') !== false);
$real_status = $is_hotspot ? 'hotspot' : 'connected';
} else {
$real_status = 'disconnected';
}
// Update DB if out of sync
if (isset($result['WIFI_status']) && $result['WIFI_status'] !== $real_status) {
@@ -81,6 +79,8 @@ if ($type == "get_config_sqlite") {
$update_stmt->execute([$real_status]);
}
$result['WIFI_status'] = $real_status;
}
// If timeout or nmcli fails, keep DB value as-is
// Return JSON response
header('Content-Type: application/json');