Diff for /loncom/LONCAPA.pm between versions 1.29 and 1.31

version 1.29, 2009/10/29 03:23:52 version 1.31, 2011/05/14 16:12:53
Line 103  sub unescape { Line 103  sub unescape {
     return $str;      return $str;
 }  }
   
 $match_domain     = $LONCAPA::domain_re     = qr{[\w\-.]+};  $match_domain     = $LONCAPA::domain_re     = qr{[[:alnum:]\-.]+};
 $match_not_domain = $LONCAPA::not_domain_re = qr{[^\w\-.]+};  $match_not_domain = $LONCAPA::not_domain_re = qr{[^[:alnum:]\-.]+};
 sub clean_domain {  sub clean_domain {
     my ($domain) = @_;      my ($domain) = @_;
     $domain =~ s/$match_not_domain//g;      $domain =~ s/$match_not_domain//g;
Line 155  sub clean_handle { Line 155  sub clean_handle {
     return $handle;      return $handle;
 }  }
   
   #
   # -- Ensure another process for same filesystem action is not running.
   #    lond uses for: apachereload; loncron uses for: lciptables
   #
   
   sub try_to_lock {
       my ($lockfile)=@_;
       my $currentpid;
       my $lastpid;
       # Do not manipulate lock file as root
       if ($>==0) {
           return 0;
       }
       # Try to generate lock file.
       # Wait 3 seconds.  If same process id is in
       # lock file, then assume lock file is stale, and
       # go ahead.  If process id's fluctuate, try
       # for a maximum of 10 times.
       for (0..10) {
           if (-e $lockfile) { 
               open(LOCK,"<$lockfile");
               $currentpid=<LOCK>;
               close LOCK;
               if ($currentpid==$lastpid) {
                   last;
               }
               sleep 3;
               $lastpid=$currentpid;
           } else {
               last;
           }
           if ($_==10) {
               return 0;
           }
       }
       open(LOCK,">$lockfile");
       print LOCK $$;
       close LOCK;
       return 1;
   }
   
 # -------------------------------------------- Return path to profile directory  # -------------------------------------------- Return path to profile directory
   
 sub propath {  sub propath {

Removed from v.1.29  
changed lines
  Added in v.1.31


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>