Skip to content

Commit

Permalink
Merge commit 'solfo/master'
Browse files Browse the repository at this point in the history
Conflicts:

	lib/Combust/Control.pm
  • Loading branch information
abh committed Oct 12, 2008
2 parents 42ad3c5 + cf75aa3 commit d11d64f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
1 change: 1 addition & 0 deletions bin/cmysql
Expand Up @@ -94,6 +94,7 @@ else {
else {
close(RDR);
print WTR "[client]\npassword=$passwd\n";
print WTR "default-character-set=utf8\n";
close(WTR);
exit 0;
}
Expand Down
16 changes: 16 additions & 0 deletions bin/diff_cpan_arch
@@ -0,0 +1,16 @@
#!/bin/bash

do_diff() {
while [ $# -ge 2 ]; do
diff -u --label $1 --label $2 \
<( cd $1 ; find . -name \*.pm | sort | xargs md5sum ) \
<( cd $2 ; find . -name \*.pm | sort | xargs md5sum )
shift
done
}

cd $CBROOTLOCAL/cpan/lib/perl5

do_diff *-*


3 changes: 1 addition & 2 deletions lib/Combust/Control.pm
Expand Up @@ -425,10 +425,9 @@ sub redirect {

my $url_escaped = uri_escape($url);

# TODO: don't we end up double escaping here?
my $data = <<EOH;
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD><TITLE>Redirect Found</TITLE></HEAD><BODY><A HREF="$url_escaped">here</A>.<P></BODY></HTML>
<HTML><HEAD><TITLE>Redirect...</TITLE></HEAD><BODY>The document has moved <A HREF="$url_escaped">here</A>.<P></BODY></HTML>
EOH

$self->request->header_out('Content-Length' => length($data));
Expand Down
2 changes: 2 additions & 0 deletions lib/Combust/Logger.pm
Expand Up @@ -37,6 +37,7 @@ our $saywarn = 0;
our $done_syslog;
our $LogToFile;
our $ShowExitBanner;
our %Count;

my @orig_argv;

Expand Down Expand Up @@ -76,6 +77,7 @@ sub logconfig {

sub _syslog {
my $type = shift;
++$Count{$type};
return unless $do_syslog or $type eq 'alert';
_openlog() unless $opened;
syslog($type, "%s", $_) for (split /\r?\n/, $_[0]);
Expand Down
30 changes: 24 additions & 6 deletions lib/Combust/RoseDB.pm
Expand Up @@ -81,7 +81,7 @@ sub ping {
my $up = $dbh && $dbh->ping;
my $new_thread_id = $up && $dbh->{mysql_thread_id};

if ($thread_id) {
if ($thread_id) { # Last check connection was ok
unless ($up) {
$self->dbh(undef); # Force re-connect
$dbh = eval { local $SIG{__DIE__}; $self->dbh };
Expand All @@ -96,24 +96,42 @@ sub ping {
return DB_BOUNCED;
}
}
elsif ( defined $thread_id ) {
elsif ( defined $thread_id ) { # Last check connection was down
if ($up) {
$self->combust_thread_id($new_thread_id);
Combust::Logger::logwarn( "Reconnected database connection to '" . $self->type . "'\n" );
return DB_BOUNCED;
}
}
else {
else { # First time through
if ($up) {
$self->combust_thread_id($new_thread_id);
return $dbh->{auto_reconnects_ok} ? DB_BOUNCED : DB_UP;
if ( $dbh->{auto_reconnects_ok} ) {
Combust::Logger::logwarn( "Bounced database connection to '" . $self->type . "'\n" );
return DB_BOUNCED;
}
else {
return DB_UP;
}
}
else {
$self->dbh(undef); # Force re-connect
$dbh = eval { local $SIG{__DIE__}; $self->dbh };
$up = $dbh && $dbh->ping;
if ($up) {
$new_thread_id = $dbh->{mysql_thread_id};
$self->combust_thread_id($new_thread_id);
Combust::Logger::logwarn( "Bounced database connection to '" . $self->type . "'\n" );
return DB_BOUNCED;
}
}
}

$self->combust_thread_id(0); # Signal connection as down
$self->combust_thread_id(0); # Signal connection as down
$self->dbh(undef); # Force re-connect

Combust::Logger::logwarn( "Lost database connection to '" . $self->type . "'\n" )
if $thread_id or !defined($thread_id);
if ($thread_id or !defined($thread_id));

return DB_DOWN;
}
Expand Down

0 comments on commit d11d64f

Please sign in to comment.