Changeset 24329 for trunk/Nebulous-Server
- Timestamp:
- Jun 4, 2009, 3:34:50 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/Nebulous-Server/lib/Nebulous/Server.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r24327 r24329 1736 1736 foreach my $inst (@$locations) { 1737 1737 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 1740 1742 # XXX I'm assuming that it's OK to fsync() a filehandle that's only 1741 1743 # open for reading? Opening as w/rw here can fail if the chmod removes 1742 1744 # 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 1745 1749 # 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: $!"); 1749 1755 } 1750 1756 … … 1992 1998 unless ($mode == 0775) { 1993 1999 $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: $!"); 1995 2002 } 1996 2003 … … 2024 2031 2025 2032 # 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"); 2027 2036 2028 2037 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: $!"); 2031 2040 2032 2041 # 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: $!"); 2041 2050 2042 2051 return $path;
Note:
See TracChangeset
for help on using the changeset viewer.
