From bea3dbb77574cb5b4274c318b01443d640d5c87b Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 7 Dec 2003 18:25:09 +0000 Subject: - Patch 0185 by Jeremy: made it possible to automatically disable modules when under heave load. --- includes/common.inc | 3 --- includes/module.inc | 12 +++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index 337090710..842279a91 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -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"); - } } } diff --git a/includes/module.inc b/includes/module.inc index 787f072f2..a3e8bbb13 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -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; } -- cgit v1.2.3