IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20046


Ignore:
Timestamp:
Oct 10, 2008, 11:42:59 AM (18 years ago)
Author:
jhoblitt
Message:

retry system call failures

Location:
trunk/Nebulous-Server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/Changes

    r20031 r20046  
    2626      temporary table instead of directly on the mountedvol table
    2727    - change neb-admin to properly cleanup it's semaphore file
     28    - retry system call failures
    2829
    29300.15 Thu Sep 11 13:00:59 HST 2008
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r19956 r20046  
    11# Copyright (c) 2004-2008  Joshua Hoblitt
    22#
    3 # $Id: Server.pm,v 1.88 2008-10-07 20:30:45 jhoblitt Exp $
     3# $Id: Server.pm,v 1.89 2008-10-10 21:42:59 jhoblitt Exp $
    44
    55package Nebulous::Server;
     
    2828__PACKAGE__->mk_accessors(qw( log sql config ));
    2929
    30 use constant SUBPATH_DEPTH => 2;
     30use constant SUBPATH_DEPTH  => 2;
     31use constant NFS_RETRIES    => 100;
    3132
    3233sub new {
     
    13671368        my $storage_filename = $self->_generate_storage_filename($key, $ins_id);
    13681369        unless (-d $storage_path) {
    1369             mkpath($storage_path, 0, 0775)
     1370            _retry(sub { mkpath(@_) }, $storage_path, 0, 0775)
    13701371                or die "can't create storage path: $storage_path";
    13711372        }
    13721373        # check to make sure at least the parent directory has the proper
    13731374        # permissions
    1374         my $mode = (stat($storage_path))[2] & 07777;
     1375        my $mode = [_retry(sub { stat($storage_path) } )]->[2] & 07777;
    13751376        unless ($mode == 0775) {
    13761377            $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: $!";
    13781379        }
    13791380
     
    14081409    my $fh;
    14091410    die "can not open $path: $!"
    1410         unless (open($fh, '>', $path));
     1411        unless (_retry(sub { open($fh, '>', $path) }));
    14111412
    14121413    # chmod before fsync() to make sure the changed perms hit the disk too
    14131414    die "can not chmod $path: $!"
    1414         unless (chmod 0664, $path);
     1415        unless (_retry(sub { chmod(0664, $path) }));
    14151416
    14161417    die "can not flush $path: $!"
     
    14211422
    14221423    die "can not close $path: $!"
    1423         unless (close($fh));
     1424        unless (_retry(sub { close($fh) }));
    14241425
    14251426    return $path;
     
    14551456}
    14561457
     1458sub _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
    14571484
    14581485sub DESTROY
Note: See TracChangeset for help on using the changeset viewer.