Changeset 20046
- Timestamp:
- Oct 10, 2008, 11:42:59 AM (18 years ago)
- Location:
- trunk/Nebulous-Server
- Files:
-
- 2 edited
-
Changes (modified) (1 diff)
-
lib/Nebulous/Server.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Changes
r20031 r20046 26 26 temporary table instead of directly on the mountedvol table 27 27 - change neb-admin to properly cleanup it's semaphore file 28 - retry system call failures 28 29 29 30 0.15 Thu Sep 11 13:00:59 HST 2008 -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r19956 r20046 1 1 # Copyright (c) 2004-2008 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.8 8 2008-10-07 20:30:45jhoblitt Exp $3 # $Id: Server.pm,v 1.89 2008-10-10 21:42:59 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 28 28 __PACKAGE__->mk_accessors(qw( log sql config )); 29 29 30 use constant SUBPATH_DEPTH => 2; 30 use constant SUBPATH_DEPTH => 2; 31 use constant NFS_RETRIES => 100; 31 32 32 33 sub new { … … 1367 1368 my $storage_filename = $self->_generate_storage_filename($key, $ins_id); 1368 1369 unless (-d $storage_path) { 1369 mkpath($storage_path, 0, 0775)1370 _retry(sub { mkpath(@_) }, $storage_path, 0, 0775) 1370 1371 or die "can't create storage path: $storage_path"; 1371 1372 } 1372 1373 # check to make sure at least the parent directory has the proper 1373 1374 # permissions 1374 my $mode = (stat($storage_path))[2] & 07777;1375 my $mode = [_retry(sub { stat($storage_path) } )]->[2] & 07777; 1375 1376 unless ($mode == 0775) { 1376 1377 $log->error("$storage_path has the wrong permissions of: %04o", $mode); 1377 chmod(0775, $storage_path) or die "can't chmod $storage_path: $!";1378 _retry(sub { chmod(0775, $storage_path) }) or die "can't chmod $storage_path: $!"; 1378 1379 } 1379 1380 … … 1408 1409 my $fh; 1409 1410 die "can not open $path: $!" 1410 unless ( open($fh, '>', $path));1411 unless (_retry(sub { open($fh, '>', $path) })); 1411 1412 1412 1413 # chmod before fsync() to make sure the changed perms hit the disk too 1413 1414 die "can not chmod $path: $!" 1414 unless ( chmod 0664, $path);1415 unless (_retry(sub { chmod(0664, $path) })); 1415 1416 1416 1417 die "can not flush $path: $!" … … 1421 1422 1422 1423 die "can not close $path: $!" 1423 unless ( close($fh));1424 unless (_retry(sub { close($fh) })); 1424 1425 1425 1426 return $path; … … 1455 1456 } 1456 1457 1458 sub _retry 1459 { 1460 my $func = shift; 1461 1462 my @ret; 1463 for (my $i = 0; $i < NFS_RETRIES; $i++) { 1464 eval { 1465 @ret = $func->(@_); 1466 }; 1467 if ($@) { 1468 die $@; 1469 sleep 1; 1470 next; 1471 } 1472 1473 last; 1474 } 1475 1476 # if the loop ended and $@ is set, rethrow the error 1477 if ($@) { 1478 die $@; 1479 } 1480 1481 return @ret; 1482 } 1483 1457 1484 1458 1485 sub DESTROY
Note:
See TracChangeset
for help on using the changeset viewer.
