From 70f32a2994501c1fb5259d13e29838e89b342867 Mon Sep 17 00:00:00 2001 From: phl0 Date: Mon, 20 May 2024 09:52:20 +0200 Subject: [PATCH] Stop subsequent up/downloads on timeout --- application/controllers/Lotw.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 680fd18d1..dd6d2387b 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -320,18 +320,28 @@ class Lotw extends CI_Controller { $result = curl_exec($ch); if(curl_errno($ch)){ - echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Failed - ".curl_strerror(curl_errno($ch))."
"; + echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Failed - ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).")
"; $this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed"); - continue; + if (curl_errno($ch) == 28) { // break on timeout + echo "Timeout reached. Stopping subsequent uploads.
"; + break; + } else { + continue; + } } $pos = strpos($result, ""); if ($pos === false) { // Upload of TQ8 Failed for unknown reason - echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Failed - ".curl_strerror(curl_errno($ch))."
"; + echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Failed - ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).")
"; $this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed"); - continue; + if (curl_errno($ch) == 28) { // break on timeout + echo "Timeout reached. Stopping subsequent uploads.
"; + break; + } else { + continue; + } } else { // Upload of TQ8 was successfull @@ -681,8 +691,11 @@ class Lotw extends CI_Controller { curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); $content = curl_exec($ch); if(curl_errno($ch)){ - $result = "LoTW download failed for user ".$data['user_lotw_name'].": ".curl_strerror(curl_errno($ch))."."; - continue; + $result = "LoTW download failed for user ".$data['user_lotw_name'].": ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).")."; + if (curl_errno($ch) == 28) { // break on timeout + $result .= "
Timeout reached. Stopping subsequent downloads."; + break; + } } file_put_contents($file, $content); if (file_get_contents($file, false, null, 0, 39) != "ARRL Logbook of the World Status Report") { @@ -769,7 +782,7 @@ class Lotw extends CI_Controller { ini_set('memory_limit', '-1'); $this->loadFromFile($file); } else { - print "LoTW download failed for user ".$data['user_lotw_name'].": ".curl_strerror(curl_errno($ch))."."; + print "LoTW download failed for user ".$data['user_lotw_name'].": ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).")."; } } else { if (!is_writable(dirname($file))) {