diff --git a/src/Environment/environment_ctrl.cxx b/src/Environment/environment_ctrl.cxx index 7e7c8cdbe..d47f8e2d6 100644 --- a/src/Environment/environment_ctrl.cxx +++ b/src/Environment/environment_ctrl.cxx @@ -323,11 +323,9 @@ FGMetarEnvironmentCtrl::FGMetarEnvironmentCtrl () fetch_elapsed( 9999.0 ), proxy_host( fgGetNode("/sim/presets/proxy/host", true) ), proxy_port( fgGetNode("/sim/presets/proxy/port", true) ), - proxy_auth( fgGetNode("/sim/presets/proxy/authentication", true) ) -#if defined(ENABLE_THREADS) && ENABLE_THREADS - ,_error_dt( 0.0 ), + proxy_auth( fgGetNode("/sim/presets/proxy/authentication", true) ), + _error_dt( 0.0 ), _error_count( 0 ) -#endif { #if defined(ENABLE_THREADS) && ENABLE_THREADS thread = new MetarThread(this); @@ -548,11 +546,13 @@ FGMetarEnvironmentCtrl::fetch_data( const string &icao ) } catch (const sg_io_exception& e) { SG_LOG( SG_GENERAL, SG_WARN, "Error fetching live weather data: " << e.getFormattedMessage().c_str() ); +#if defined(ENABLE_THREADS) && ENABLE_THREADS if (_error_count++ >= 3) { SG_LOG( SG_GENERAL, SG_WARN, "Stop fetching data permanently."); thread->cancel(); thread->join(); } +#endif result.m = NULL; } diff --git a/src/Environment/environment_ctrl.hxx b/src/Environment/environment_ctrl.hxx index 69e5b79ea..bb3460484 100644 --- a/src/Environment/environment_ctrl.hxx +++ b/src/Environment/environment_ctrl.hxx @@ -249,11 +249,11 @@ private: */ friend void metar_cleanup_handler( void* ); +#endif // ENABLE_THREADS int _error_count; double _dt; double _error_dt; -#endif // ENABLE_THREADS }; #endif // _ENVIRONMENT_CTRL_HXX