From 8401101d5051c4ccad140fc4b062fa9c780d06d9 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Mon, 1 Apr 2013 15:08:21 +0300 Subject: Moved hard-coded fetch timeout values into config file to allow site-level tuning --- config.php-dist | 21 +++++++++++++++++++++ include/functions.php | 4 ++-- include/rssfuncs.php | 3 ++- include/sanity_config.php | 4 ++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/config.php-dist b/config.php-dist index 6561ecbd4..72320bc5f 100644 --- a/config.php-dist +++ b/config.php-dist @@ -163,6 +163,27 @@ // These two options enable SMTP authentication when sending // outgoing mail. Only used with SMTP_HOST + // ************************************** + // *** Update proces tuning settings *** + // ************************************** + + define('FEED_FETCH_TIMEOUT', 45); + // How may seconds to wait for response when requesting feed from a site + // You may need to decease this if you see errors like "MySQL server + // has gone away" pop up in your feed update logs after fetching feeds + // from slow websites + + define('FEED_FETCH_NO_CACHE_TIMEOUT', 15); + // How may seconds to wait for response when requesting feed from a + // site when that feed wasn't cached before + + define('FILE_FETCH_TIMEOUT', 45); + // Default timeout when fetching files from remote sites + + define('FILE_FETCH_CONNECT_TIMEOUT', 15); + // How many seconds to wait for initial response from website when + // fetching files from remote sites + // *************************************** // *** Other settings (less important) *** // *************************************** diff --git a/include/functions.php b/include/functions.php index b9c30c6ce..fa63c9baa 100644 --- a/include/functions.php +++ b/include/functions.php @@ -306,8 +306,8 @@ array("If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T', $timestamp))); } - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : 15); - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : 45); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("safe_mode")); curl_setopt($ch, CURLOPT_MAXREDIRS, 20); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 3bce14d33..5c37b7523 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -284,7 +284,8 @@ } $feed_data = fetch_file_contents($fetch_url, false, - $auth_login, $auth_pass, false, $no_cache ? 15 : 45, + $auth_login, $auth_pass, false, + $no_cache ? FEED_FETCH_NO_CACHE_TIMEOUT : FEED_FETCH_TIMEOUT, max($last_updated_timestamp, $cache_timestamp)); if ($debug_enabled) { diff --git a/include/sanity_config.php b/include/sanity_config.php index 9b28e46af..d6be42f26 100644 --- a/include/sanity_config.php +++ b/include/sanity_config.php @@ -1,3 +1,3 @@ - +$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'SINGLE_USER_MODE', 'SIMPLE_UPDATE_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'FORCE_ARTICLE_PURGE', 'PUBSUBHUBBUB_HUB', 'PUBSUBHUBBUB_ENABLED', 'SPHINX_ENABLED', 'SPHINX_INDEX', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SESSION_CHECK_ADDRESS', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'SMTP_HOST', 'SMTP_PORT', 'SMTP_LOGIN', 'SMTP_PASSWORD', 'FEED_FETCH_TIMEOUT', 'FEED_FETCH_NO_CACHE_TIMEOUT', 'FILE_FETCH_TIMEOUT', 'FILE_FETCH_CONNECT_TIMEOUT', 'CHECK_FOR_NEW_VERSION', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'CONFIG_VERSION'); ?> -- cgit v1.2.3