IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 4, 2009, 3:34:50 PM (17 years ago)
Author:
jhoblitt
Message:

cleanup system call retrying

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r24327 r24329  
    17361736    foreach my $inst (@$locations) {
    17371737        my $path = URI->new($inst)->path;
    1738         chmod $mode, $path
    1739             or $log->logdie("chmod() failed: $!");
     1738
     1739        _retry(sub { chmod($mode, $path) })
     1740            or $log->logdie("can not chmod() $path: $!");
     1741
    17401742        # XXX I'm assuming that it's OK to fsync() a filehandle that's only
    17411743        # open for reading?  Opening as w/rw here can fail if the chmod removes
    17421744        # write permissions.
    1743         my $fh = IO::File->new($path, "r")
    1744             or $log->logdie("open() of $path failed: $!");;
     1745        my $fh;
     1746        _retry(sub { open($fh, '<', $path) })
     1747            or $log->logdie("can not open() $path: $!");
     1748
    17451749        # fsync(3c)
    1746         $fh->sync;
    1747         close ($fh)
    1748             or $log->logdie("close() failed: $!");
     1750        _retry(sub { $fh->sync() })
     1751            or $log->logdie("can not sync() $path: $!");
     1752
     1753        _retry(sub { close($fh) })
     1754            or $log->logdie("can not close() $path: $!");
    17491755    }
    17501756
     
    19921998        unless ($mode == 0775) {
    19931999            $log->error("$storage_path has the wrong permissions of: 0", sprintf("%o", $mode));
    1994             _retry(sub { chmod(0775, $storage_path) }) or die "can't chmod $storage_path: $!";
     2000            _retry(sub { chmod(0775, $storage_path) })
     2001                or $log->logdie("can not chmod() $storage_path: $!");
    19952002        }
    19962003
     
    20242031
    20252032    # perl's open() can't do an O_CREAT | O_EXCL
    2026     die "file $path already exists" if (-e $path);
     2033    # XXX is it possible to tell if this system call failed?
     2034    -e $path
     2035        and $log->logdie("file $path already exists");
    20272036
    20282037    my $fh;
    2029     die "can not open $path: $!"
    2030         unless (_retry(sub { open($fh, '>', $path) }));
     2038    _retry(sub { open($fh, '>', $path) })
     2039        or $log->logdie("can not open() $path: $!");
    20312040
    20322041    # chmod before fsync() to make sure the changed perms hit the disk too
    2033     die "can not chmod $path: $!"
    2034         unless (_retry(sub { chmod(0664, $path) }));
    2035 
    2036     die "can not sync $path: $!"
    2037         unless (_retry(sub { $fh->sync() }));
    2038 
    2039     die "can not close $path: $!"
    2040         unless (_retry(sub { close($fh) }));
     2042    _retry(sub { chmod(0664, $path) })
     2043        or $log->logdie("can not chmod() $path: $!");
     2044
     2045    _retry(sub { $fh->sync() })
     2046        or $log->logdie("can not sync() $path: $!");
     2047
     2048    _retry(sub { close($fh) })
     2049        or $log->logdie("can not close() $path: $!");
    20412050
    20422051    return $path;
Note: See TracChangeset for help on using the changeset viewer.