- Made slave handling more fault tollerant, and slightly higher performing.

This commit is contained in:
JT Smith 2007-03-07 19:22:45 +00:00
parent 3a8bd77cde
commit 0ceb0f68e3
2 changed files with 6 additions and 2 deletions

View file

@ -3,6 +3,7 @@
processing twice as fast.
- Made Weather Data asset more fault tollerant.
- Made CS related upgrades more fault tollerant.
- Made slave handling more fault tollerant, and slightly higher performing.
- Enhanced HTTP caching directives.
- fix: Fixing bad link on the Event page to the search engine. Added a new
Event template variable called urlSearch to handle it. (perlDreamer Consulting, LLC)

View file

@ -183,17 +183,20 @@ Returns a random slave database handler, if one is defined, otherwise it returns
sub dbSlave {
my $self = shift;
unless (exists $self->{_slave}) {
my @slaves = ();
foreach (1..3) {
my $slave = $self->config->get("dbslave".$_);
if (exists $slave->{dsn}) {
push(@{$self->{_slave}},WebGUI::SQL->connect($self, $slave->{dsn},$slave->{user},$slave->{pass}));
push (@slaves, $slave);
}
}
my $slave = $slaves[rand @slaves];
$self->{_slave} = WebGUI::SQL->connect($self, $slave->{dsn},$slave->{user},$slave->{pass});
}
if ($self->var("adminOn") || !exists $self->{_slave}) {
return $self->db;
} else {
return $self->{_slave}->[rand @{$self->{_slave}}];
return $self->{_slave};
}
}