/[fuse.before_github]/perl/trunk/examples/rmount.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /perl/trunk/examples/rmount.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 18 by mszeredi, Thu Nov 11 14:44:15 2004 UTC revision 19 by dpavlin, Tue Dec 27 12:47:00 2005 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl -w
2    
3    # This example needs some work before it can support threads.
4  use strict;  use strict;
5  use Net::SSH 'sshopen2';  use Net::SSH 'sshopen2';
6  use IPC::Open2;  use IPC::Open2;
# Line 49  sub netlink { Line 50  sub netlink {
50          my ($str) = Dumper(\@_)."\n";          my ($str) = Dumper(\@_)."\n";
51          $str = sprintf("%08i\n%s",length($str),$str);          $str = sprintf("%08i\n%s",length($str),$str);
52          while(1) { # retry as necessary          while(1) { # retry as necessary
                 my ($sig) = $SIG{ALRM};  
53                  my ($VAR1);                  my ($VAR1);
54                  $VAR1 = undef;                  $VAR1 = undef;
55                  eval {                  eval {
56                          $SIG{ALRM} = sub { die "timeout\n" };                          local $SIG{ALRM} = sub { die "timeout\n" };
57                          alarm 10;                          alarm 10;
58                          print WRITER $str;                          print WRITER $str;
59                          my ($len, $data);                          my ($len, $data);
60                          if(read(READER,$len,9) == 9) {                          $data = '';
61                                  read(READER,$data,$len-length($data),length($data))                          if(sysread(READER,$len,9) == 9) {
62                                    sysread(READER,$data,$len-length($data),length($data))
63                                          while(length($data) < $len);                                          while(length($data) < $len);
64                                  eval $data;                                  eval $data;
65                          }                          }
66                            alarm 0;
67                  };                  };
                 alarm 0;  
                 $SIG{ALRM} = $sig;  
68                  if(defined $VAR1) {                  if(defined $VAR1) {
69                          return wantarray ? @{$VAR1} : $$VAR1[0];                          return wantarray ? @{$VAR1} : $$VAR1[0];
70                  }                  }

Legend:
Removed from v.18  
changed lines
  Added in v.19

  ViewVC Help
Powered by ViewVC 1.1.26