IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18463


Ignore:
Timestamp:
Jul 10, 2008, 1:21:27 PM (18 years ago)
Author:
jhoblitt
Message:

retry all calls to open()

Location:
trunk/Nebulous
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/Changes

    r18455 r18463  
    11Revision history for Nebulous
     2
     30.10
     4    - retry all calls to open()
    25
    360.09 Wed Jul  9 16:36:27 HST 2008
  • trunk/Nebulous/lib/Nebulous/Client.pm

    r18455 r18463  
    11# Copyright (c) 2004-2008  Joshua Hoblitt
    22#
    3 # $Id: Client.pm,v 1.56 2008-07-10 02:38:58 jhoblitt Exp $
     3# $Id: Client.pm,v 1.57 2008-07-10 23:21:27 jhoblitt Exp $
    44
    55package Nebulous::Client;
     
    171171    $log->debug( "URI is: $uri" );
    172172
    173     # XXX this is a attempt to work around some sort of nasty NFS bug where
    174     # occasionally stat()/open() on a file on an NFS mounted filesystem will
    175     # fail EVEN THOU THE FILE ACTUALLY EXISTS.
    176     #
    177     #  The instance file attempting to be opened should always exist as it was
    178     #  created by the Nebulous server.
    179173    my $fh;
    180     for (my $i = 0; $i < 10; $i++) {
    181         eval {
    182             $fh = _open_uri( $uri, '+<' );
    183         };
    184         if ($@ =~ qr/file doesn't exist/) {
    185             $self->set_err($@);
    186             sleep 1;
    187         } else {
    188             last;
    189         }
    190     }
     174    eval {
     175        $fh = _open_uri( $uri, '+<' );
     176    };
    191177    $log->logdie( $@ ) if $@;
    192178
  • trunk/Nebulous/lib/Nebulous/Util.pm

    r17845 r18463  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Util.pm,v 1.12 2008-05-29 03:59:30 jhoblitt Exp $
     3# $Id: Util.pm,v 1.13 2008-07-10 23:21:27 jhoblitt Exp $
    44
    55package Nebulous::Util;
     
    7070    my ( $path, $flags ) = @_;
    7171
    72     die "can't open file $path: file doesn't exist"
    73         unless -e $path;
    74     CORE::open( my $fh, $flags, $path )
    75         or die "can't open file $path: $!";
    76 
     72    # XXX this is a attempt to work around some sort of nasty NFS bug where
     73    # occasionally stat()/open() on a file on an NFS mounted filesystem will
     74    # fail EVEN THOU THE FILE ACTUALLY EXISTS.
     75    #
     76    # The instance file attempting to be opened should always exist as it was
     77    # created by the Nebulous server.
     78    my $fh;
     79    for (my $i = 0; $i < 60; $i++) {
     80        eval {
     81            die "can't open file $path: file doesn't exist"
     82                unless -e $path;
     83            CORE::open($fh, $flags, $path)
     84                or die "can't open file $path: $!";
     85        };
     86        if ($@ =~ qr/file doesn't exist/) {
     87            sleep 1;
     88            next;
     89        }
     90        if ($@) {
     91            die $@;
     92        }
     93
     94        last;
     95    }
     96   
    7797    return $fh;
    7898}
Note: See TracChangeset for help on using the changeset viewer.