Lines 57-62
Link Here
|
57 |
|
57 |
|
58 |
use Config; |
58 |
use Config; |
59 |
use File::Spec; |
59 |
use File::Spec; |
|
|
60 |
use File::Basename; |
60 |
use Time::Local; |
61 |
use Time::Local; |
61 |
use Sys::Hostname (); # don't import hostname() into this namespace! |
62 |
use Sys::Hostname (); # don't import hostname() into this namespace! |
62 |
use Fcntl; |
63 |
use Fcntl; |
Lines 1551-1556
Link Here
|
1551 |
|
1552 |
|
1552 |
########################################################################### |
1553 |
########################################################################### |
1553 |
|
1554 |
|
|
|
1555 |
# bug 5612: work around for bugs in Berkeley db 4.2 |
1556 |
# |
1557 |
# on 4.2 having the __db.[DBNAME] file will cause an loop that will never finish |
1558 |
# on 4.3+ the loop will timeout after 301 open attempts, but we will still |
1559 |
# be unable to open the database. This workaround solves both problems. |
1560 |
# |
1561 |
sub avoid_db_file_locking_bug { |
1562 |
my $path = shift; |
1563 |
|
1564 |
my $db_tmp_file = '__db.'.basename($path); |
1565 |
my $db_tmp_file_match = $db_tmp_file . '.'; |
1566 |
|
1567 |
my $parentdir = dirname($path); |
1568 |
|
1569 |
# The db bug is actually more pervasive then orignally thought we can also have __db.[DBNAME].* as well. |
1570 |
|
1571 |
opendir(my $sa_db_dir_fh, $parentdir); |
1572 |
while(my $test_filename = readdir($sa_db_dir_fh)) { |
1573 |
# If the file is __db.[DBNAME] or the file is __db.[DBNAME].* (glob) then we need to remove it |
1574 |
# we use substr here as its slightly fater then using a regex |
1575 |
|
1576 |
my $newtest = substr($test_filename,0,length($db_tmp_file_match)); |
1577 |
|
1578 |
if ( substr($test_filename,0,length($db_tmp_file_match)) eq $db_tmp_file_match || $test_filename eq $db_tmp_file ) { |
1579 |
my $db_tmpfile = untaint_file_path( File::Spec->catfile($parentdir,$test_filename) ); |
1580 |
|
1581 |
dbg("Berkeley DB bug work-around: cleaning tmp file $db_tmpfile"); |
1582 |
if (!unlink($db_tmpfile)) { |
1583 |
die "cannot remove Berkeley DB tmp file $db_tmpfile: $!\n"; |
1584 |
} |
1585 |
} |
1586 |
} |
1587 |
closedir($sa_db_dir_fh); |
1588 |
} |
1589 |
|
1590 |
########################################################################### |
1591 |
|
1554 |
1; |
1592 |
1; |
1555 |
|
1593 |
|
1556 |
=back |
1594 |
=back |