Commit bea3dbb7 authored by Dries's avatar Dries

- Patch 0185 by Jeremy: made it possible to automatically disable modules when
  under heave load.
parent 71eac6dd
......@@ -6,6 +6,7 @@ Drupal x.x.x, xxxx-xx-xx
* made it possible to disable the "comment viewing controls".
- performance:
* improved module loading when serving cached pages.
* made it possible to automatically disable modules when under heavy load.
* made it possible to automatically disable blocks when under heavy load.
- theme system:
* made all theme functions start with 'theme_'.
......
......@@ -299,7 +299,8 @@ CREATE TABLE [dbo].[system] (
[name] [varchar] (255) NOT NULL ,
[type] [varchar] (255) NOT NULL ,
[description] [varchar] (255) NOT NULL ,
[status] [int] NOT NULL
[status] [int] NOT NULL ,
[throttle] [smallint] NOT NULL ,
[bootstrap] [int] NOT NULL
) ON [PRIMARY]
GO
......@@ -487,10 +488,10 @@ INSERT INTO system VALUES ('modules/node.module','node','module','',1,0);
INSERT INTO system VALUES ('modules/page.module','page','module','',1,0);
INSERT INTO system VALUES ('modules/story.module','story','module','',1,0);
INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1,0);
INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1,0);
INSERT INTO system VALUES ('themes/xtemplate/xtemplate.theme','xtemplate','theme','Internet explorer, Netscape, Opera',1,0);
INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-10-27";');
INSERT INTO variable(name,value) VALUES('theme_default','s:6:"marvin";');
INSERT INTO variable(name,value) VALUES('theme_default','s:9:"xtemplate";');
INSERT INTO users(uid,name,mail,rid) VALUES(0,'','','1');
......
......@@ -427,6 +427,7 @@ CREATE TABLE system (
type varchar(255) NOT NULL default '',
description varchar(255) NOT NULL default '',
status int(2) NOT NULL default '0',
throttle tinyint(1) DEFAULT '0' NOT NULL,
bootstrap int(2) NOT NULL default '0',
PRIMARY KEY (filename)
) TYPE=MyISAM;
......@@ -570,11 +571,11 @@ INSERT INTO system VALUES ('modules/node.module','node','module','',1,0);
INSERT INTO system VALUES ('modules/page.module','page','module','',1,0);
INSERT INTO system VALUES ('modules/story.module','story','module','',1,0);
INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1,0);
INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1,0);
INSERT INTO system VALUES ('themes/xtemplate/xtemplate.theme','xtemplate','theme','Internet explorer, Netscape, Opera',1,0);
INSERT INTO users (uid, name, mail, rid) VALUES ('0', '', '', '1');
REPLACE variable SET name='update_start', value='s:10:"2003-10-27;"';
REPLACE variable SET name='theme_default', value='s:6:"marvin";';
REPLACE variable SET name='theme_default', value='s:9:"xtemplate";';
REPLACE blocks SET module = 'user', delta = '0', status = '1';
REPLACE blocks SET module = 'user', delta = '1', status = '1';
......
......@@ -423,6 +423,7 @@ CREATE TABLE system (
type varchar(255) NOT NULL default '',
description varchar(255) NOT NULL default '',
status integer NOT NULL default '0',
throttle smallint NOT NULL default '0',
bootstrap integer NOT NULL default '0',
PRIMARY KEY (filename)
);
......@@ -568,10 +569,10 @@ INSERT INTO system VALUES ('modules/node.module','node','module','',1,0);
INSERT INTO system VALUES ('modules/page.module','page','module','',1,0);
INSERT INTO system VALUES ('modules/story.module','story','module','',1,0);
INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1,0);
INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1,0);
INSERT INTO system VALUES ('themes/xtemplate/xtemplate.theme','xtemplate','theme','Internet explorer, Netscape, Opera',1,0);
INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-10-27";');
INSERT INTO variable(name,value) VALUES('theme_default','s:6:"marvin";');
INSERT INTO variable(name,value) VALUES('theme_default','s:9:"xtemplate";');
INSERT INTO users(uid,name,mail,rid) VALUES(0,'','', '1');
INSERT INTO blocks(module,delta,status) VALUES('user', '0', '1');
......
......@@ -129,9 +129,6 @@ function throttle($type, $rate) {
watchdog("warning", "throttle: '". getenv("REMOTE_ADDR") ."' exceeded submission rate - $throttle->type");
die(message_throttle());
}
else {
watchdog($type, "throttle");
}
}
}
......
......@@ -50,13 +50,19 @@ function module_list($refresh = 0, $bootstrap = 0) {
if (!$list) {
$list = array("admin" => "admin", "system" => "system", "user" => "user", "watchdog" => "watchdog");
$result = db_query("SELECT name, filename, bootstrap FROM {system} WHERE type = 'module' AND status = '1' ORDER BY name");
$result = db_query("SELECT name, filename, throttle, bootstrap FROM {system} WHERE type = 'module' AND status = '1' ORDER BY name");
while ($module = db_fetch_object($result)) {
if (file_exists($module->filename)) {
if ($bootstrap) {
/*
** Determine the current throttle status and see if module should be
** loaded based on server load. We have to directly access the
** throttle variables as the throttle.module may not be loaded yet.
*/
$throttle = (variable_get("throttle_enable", 0) && $module->throttle && (variable_get("throttle_level", 0) >= 5));
if ($bootstrap && !$throttle) {
$list[$module->name] = array("name"=> $module->name, "bootstrap" => $module->bootstrap, "filename" => $module->filename);
}
else {
else if (!$throttle) {
$list[$module->name] = $module->name;
include_once $module->filename;
}
......
......@@ -40,7 +40,7 @@ function block_help($section = "admin/help#block") {
$output = t("Controls the boxes that are displayed around the main content.");
break;
case 'admin/system/block':
$output = t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the choosen theme. They are created by <b>active</b> Drupal modules. In order to view a block it must be enabled. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. The custom checkbox lets your users hide the block using their account setting. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the %createblock link in the menu to the left. Edit and delete links will become active below for these customized blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the %throttle.", array("%createblock" => l(t("new block"), "admin/system/block/add"), "%throttle" => l(t("throttle configuration page"), "admin/system/modules/throttle")));
$output = t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the choosen theme. They are created by <b>active</b> Drupal modules. In order to view a block it must be enabled. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. The custom checkbox lets your users hide the block using their account setting. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the %createblock link in the menu to the left. Edit and delete links will become active below for these customized blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the %throttle after having enabled the throttle module.", array("%createblock" => l(t("new block"), "admin/system/block/add"), "%throttle" => l(t("throttle configuration page"), "admin/system/modules/throttle")));
break;
case 'admin/system/block/add':
$output = t("Here you can create a custom content block. Once you have created this block you must make it active, and give it a place on the page using %overview. The title is used when displaying the block. The description is used in the \"block\" column on the %overview page. If you are going to place PHP code in the block, and you have <b>create php content</b> permission (see the %permission page) you <b>must</b> change the type to PHP to make your code active.", array("%overview" => l(t("blocks"), "admin/system/block"), "%permission" => l(t("permissions"), "admin/user/permission")));
......
......@@ -40,7 +40,7 @@ function block_help($section = "admin/help#block") {
$output = t("Controls the boxes that are displayed around the main content.");
break;
case 'admin/system/block':
$output = t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the choosen theme. They are created by <b>active</b> Drupal modules. In order to view a block it must be enabled. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. The custom checkbox lets your users hide the block using their account setting. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the %createblock link in the menu to the left. Edit and delete links will become active below for these customized blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the %throttle.", array("%createblock" => l(t("new block"), "admin/system/block/add"), "%throttle" => l(t("throttle configuration page"), "admin/system/modules/throttle")));
$output = t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the choosen theme. They are created by <b>active</b> Drupal modules. In order to view a block it must be enabled. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. The custom checkbox lets your users hide the block using their account setting. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the %createblock link in the menu to the left. Edit and delete links will become active below for these customized blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the %throttle after having enabled the throttle module.", array("%createblock" => l(t("new block"), "admin/system/block/add"), "%throttle" => l(t("throttle configuration page"), "admin/system/modules/throttle")));
break;
case 'admin/system/block/add':
$output = t("Here you can create a custom content block. Once you have created this block you must make it active, and give it a place on the page using %overview. The title is used when displaying the block. The description is used in the \"block\" column on the %overview page. If you are going to place PHP code in the block, and you have <b>create php content</b> permission (see the %permission page) you <b>must</b> change the type to PHP to make your code active.", array("%overview" => l(t("blocks"), "admin/system/block"), "%permission" => l(t("permissions"), "admin/user/permission")));
......
......@@ -13,7 +13,7 @@ function system_help($section = "admin/help#system") {
$output = t("Select which themes are available to your users and specify the default theme.");
break;
case 'admin/system/modules':
$output = t("Modules are plugins for Drupal that extend its core functionality. Here you can select which modules are enabled. On the left hand side click on the name of the module for their individual configurations. Once a module is enabled, you will need to grant %permissions to users.", array("%permissions" => l(t("permissions"), "admin/user/permission")));
$output = t("Modules are plugins for Drupal that extend its core functionality. Here you can select which modules are enabled. Click on the name of the module in the navigation menu for their individual configuration pages. Once a module is enabled, new %permissions might be made available. Modules can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the %throttle after having enabled the throttle module.", array("%permissions" => l(t("permissions"), "admin/user/permission"), "%throttle" => l(t("throttle configuration page"), "admin/system/modules/throttle")));
break;
case 'admin/system/filters':
$output = t("Filters fit between the raw text in a node and the HTML output. They allow you to replace text selectively. Uses include automatic conversion of emoticons into graphics and filtering HTML content from users' submissions.");
......@@ -193,7 +193,7 @@ function system_save_settings($edit = array()) {
if ($edit["type"]) {
db_query("UPDATE {system} SET status = '0' WHERE type = '%s'", $edit["type"]);
foreach ($edit["status"] as $filename => $status) {
db_query("UPDATE {system} SET status = %d WHERE filename = '$filename'", $status);
db_query("UPDATE {system} SET status = %d, throttle = %d WHERE filename = '$filename'", $status, $edit["throttle"]["$filename"]);
}
if ($edit["type"] == "theme") {
variable_set("theme_default", $edit["theme_default"]);
......@@ -281,7 +281,7 @@ function system_listing($type, $directory, $required = array()) {
$files = system_dirscan($directory, "\.$type$");
// Extract current files from database.
$result = db_query("SELECT filename, type, status FROM {system} WHERE type = '%s'", $type);
$result = db_query("SELECT filename, type, status, throttle FROM {system} WHERE type = '%s'", $type);
while ($file = db_fetch_object($result)) {
if (is_object($files[$file->filename])) {
foreach ($file as $key => $value) {
......@@ -293,7 +293,9 @@ function system_listing($type, $directory, $required = array()) {
ksort($files);
if ($type == "module") {
$header = array(t("name"), t("description"), t("status"));
$header = array(t("name"), t("description"), t("status"), t("throttle"));
// the throttle mechanism requires additional modules always be enabled
$throttle_required = array_merge($required, array("modules/statistics.module", "modules/throttle.module"));
}
else {
$header = array(t("name"), t("description"), t("enable"), t("default"));
......@@ -326,10 +328,13 @@ function system_listing($type, $directory, $required = array()) {
// Update the contents of the system table:
db_query("DELETE FROM {system} WHERE filename = '%s' AND type = '%s'", $filename, $type);
db_query("INSERT INTO {system} (name, description, type, filename, status, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d)", $info->name, $info->description, $type, $filename, $file->status, $bootstrap);
db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $info->name, $info->description, $type, $filename, $file->status, $file->throttle, $bootstrap);
$row = array($info->name, $info->description, array("data" => (in_array($filename, $required) ? form_hidden("status][$filename", 1) . t("required") : form_checkbox("", "status][$filename", 1, $file->status)), "align" => "center"));
if ($type == "theme") {
if ($type == "module") {
$row[] = array("data" => (in_array($filename, $throttle_required) ? form_hidden("throttle][$filename", 0) . t("required") : form_checkbox(NULL, "throttle][$filename", 1, $file->throttle, NULL, variable_get("throttle_enable", 0) ? NULL : array("disabled" => "disabled"))), "align" => "center");
}
else if ($type == "theme") {
$row[] = array("data" => form_radio("","theme_default",$info->name,(variable_get("theme_default",0) == $info->name) ? 1 : 0), "align" => "center");
}
$rows[] = $row;
......
......@@ -13,7 +13,7 @@ function system_help($section = "admin/help#system") {
$output = t("Select which themes are available to your users and specify the default theme.");
break;
case 'admin/system/modules':
$output = t("Modules are plugins for Drupal that extend its core functionality. Here you can select which modules are enabled. On the left hand side click on the name of the module for their individual configurations. Once a module is enabled, you will need to grant %permissions to users.", array("%permissions" => l(t("permissions"), "admin/user/permission")));
$output = t("Modules are plugins for Drupal that extend its core functionality. Here you can select which modules are enabled. Click on the name of the module in the navigation menu for their individual configuration pages. Once a module is enabled, new %permissions might be made available. Modules can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the %throttle after having enabled the throttle module.", array("%permissions" => l(t("permissions"), "admin/user/permission"), "%throttle" => l(t("throttle configuration page"), "admin/system/modules/throttle")));
break;
case 'admin/system/filters':
$output = t("Filters fit between the raw text in a node and the HTML output. They allow you to replace text selectively. Uses include automatic conversion of emoticons into graphics and filtering HTML content from users' submissions.");
......@@ -193,7 +193,7 @@ function system_save_settings($edit = array()) {
if ($edit["type"]) {
db_query("UPDATE {system} SET status = '0' WHERE type = '%s'", $edit["type"]);
foreach ($edit["status"] as $filename => $status) {
db_query("UPDATE {system} SET status = %d WHERE filename = '$filename'", $status);
db_query("UPDATE {system} SET status = %d, throttle = %d WHERE filename = '$filename'", $status, $edit["throttle"]["$filename"]);
}
if ($edit["type"] == "theme") {
variable_set("theme_default", $edit["theme_default"]);
......@@ -281,7 +281,7 @@ function system_listing($type, $directory, $required = array()) {
$files = system_dirscan($directory, "\.$type$");
// Extract current files from database.
$result = db_query("SELECT filename, type, status FROM {system} WHERE type = '%s'", $type);
$result = db_query("SELECT filename, type, status, throttle FROM {system} WHERE type = '%s'", $type);
while ($file = db_fetch_object($result)) {
if (is_object($files[$file->filename])) {
foreach ($file as $key => $value) {
......@@ -293,7 +293,9 @@ function system_listing($type, $directory, $required = array()) {
ksort($files);
if ($type == "module") {
$header = array(t("name"), t("description"), t("status"));
$header = array(t("name"), t("description"), t("status"), t("throttle"));
// the throttle mechanism requires additional modules always be enabled
$throttle_required = array_merge($required, array("modules/statistics.module", "modules/throttle.module"));
}
else {
$header = array(t("name"), t("description"), t("enable"), t("default"));
......@@ -326,10 +328,13 @@ function system_listing($type, $directory, $required = array()) {
// Update the contents of the system table:
db_query("DELETE FROM {system} WHERE filename = '%s' AND type = '%s'", $filename, $type);
db_query("INSERT INTO {system} (name, description, type, filename, status, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d)", $info->name, $info->description, $type, $filename, $file->status, $bootstrap);
db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $info->name, $info->description, $type, $filename, $file->status, $file->throttle, $bootstrap);
$row = array($info->name, $info->description, array("data" => (in_array($filename, $required) ? form_hidden("status][$filename", 1) . t("required") : form_checkbox("", "status][$filename", 1, $file->status)), "align" => "center"));
if ($type == "theme") {
if ($type == "module") {
$row[] = array("data" => (in_array($filename, $throttle_required) ? form_hidden("throttle][$filename", 0) . t("required") : form_checkbox(NULL, "throttle][$filename", 1, $file->throttle, NULL, variable_get("throttle_enable", 0) ? NULL : array("disabled" => "disabled"))), "align" => "center");
}
else if ($type == "theme") {
$row[] = array("data" => form_radio("","theme_default",$info->name,(variable_get("theme_default",0) == $info->name) ? 1 : 0), "align" => "center");
}
$rows[] = $row;
......
......@@ -62,7 +62,8 @@
"2003-10-27" => "update_70",
"2003-11-17" => "update_71",
"2003-11-27" => "update_72",
"2003-12-03" => "update_73"
"2003-12-03" => "update_73",
"2003-12-06" => "update_74"
);
function update_32() {
......@@ -585,6 +586,10 @@ function update_73() {
}
}
function update_74() {
update_sql("ALTER TABLE {system} ADD throttle tinyint(1) NOT NULL DEFAULT '0'");
}
/*
** System functions
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment