Merge pull request #114 from ifireball/tunable-fetches
Allow tuning fetch timeouts from config.php
This commit is contained in:
commit
2f76e8583d
|
@ -30,6 +30,36 @@
|
||||||
|
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define a constant if not already defined
|
||||||
|
*
|
||||||
|
* @param string $name The constant name.
|
||||||
|
* @param mixed $value The constant value.
|
||||||
|
* @access public
|
||||||
|
* @return boolean True if defined successfully or not.
|
||||||
|
*/
|
||||||
|
function define_default($name, $value) {
|
||||||
|
// Note: performence freaks should define everything in
|
||||||
|
// config.php becasue if will make defined() run much faster,
|
||||||
|
// see comment by 'tris+php at tfconsulting dot com dot au'
|
||||||
|
// here:
|
||||||
|
// http://www.php.net/manual/en/function.defined.php#89886
|
||||||
|
defined($name) or define($name, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
///// Some defaults that you can override in config.php //////
|
||||||
|
|
||||||
|
define_default('FEED_FETCH_TIMEOUT', 45);
|
||||||
|
// How may seconds to wait for response when requesting feed from a site
|
||||||
|
define_default('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_default('FILE_FETCH_TIMEOUT', 45);
|
||||||
|
// Default timeout when fetching files from remote sites
|
||||||
|
define_default('FILE_FETCH_CONNECT_TIMEOUT', 15);
|
||||||
|
// How many seconds to wait for initial response from website when
|
||||||
|
// fetching files from remote sites
|
||||||
|
|
||||||
if (DB_TYPE == "pgsql") {
|
if (DB_TYPE == "pgsql") {
|
||||||
define('SUBSTRING_FOR_DATE', 'SUBSTRING_FOR_DATE');
|
define('SUBSTRING_FOR_DATE', 'SUBSTRING_FOR_DATE');
|
||||||
} else {
|
} else {
|
||||||
|
@ -308,8 +338,8 @@
|
||||||
array("If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T', $timestamp)));
|
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_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT);
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : 45);
|
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT);
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("safe_mode"));
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("safe_mode"));
|
||||||
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
|
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
|
||||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
|
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
|
||||||
|
|
|
@ -286,7 +286,8 @@
|
||||||
$force_refetch = isset($_REQUEST["force_refetch"]);
|
$force_refetch = isset($_REQUEST["force_refetch"]);
|
||||||
|
|
||||||
$feed_data = fetch_file_contents($fetch_url, false,
|
$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,
|
||||||
$force_refetch ? 0 : max($last_updated_timestamp, $cache_timestamp));
|
$force_refetch ? 0 : max($last_updated_timestamp, $cache_timestamp));
|
||||||
|
|
||||||
if ($debug_enabled) {
|
if ($debug_enabled) {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<?php # This file has been generated at: Thu Mar 28 10:05:39 MSK 2013
|
<?php # This file has been generated at: Mon Apr 1 18:30:54 IDT 2013
|
||||||
define('GENERATED_CONFIG_CHECK', 26);
|
define('GENERATED_CONFIG_CHECK', 26);
|
||||||
$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', 'CHECK_FOR_NEW_VERSION', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'CONFIG_VERSION'); ?>
|
$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', 'CHECK_FOR_NEW_VERSION', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'CONFIG_VERSION'); ?>
|
||||||
|
|
Loading…
Reference in New Issue