Changeset 13555

Show
Ignore:
Timestamp:
02/22/12 16:59:44 (1 year ago)
Author:
mbrevda
Message:

atempt to remove lock if no active prosses is found

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.10/backup/functions.inc/class.backup.php

    r13484 r13555  
    109109     
    110110    //TODO: use 'c+' once the project require php > 5.2.8 
    111      
    112111    if (file_exists($this->lock_file)) { 
    113       return false; 
    114     } else { 
    115       $this->lock = fopen($this->lock_file, 'x+'); 
    116     } 
     112      //get pid that set the lock and ensure its still running 
     113      $pid = file_get_contents($this->lock_file); 
     114       
     115      exec(fpbx_which('ps') . ' h ' . $pid, $ret, $status); 
     116      //exit code ($status) will be 0 if running, or 1 if pid not found 
     117      if ($status === 0) { 
     118        return false; 
     119      } else { 
     120        //if we dont see the prosses running, remove the lock 
     121        unlink($this->lock_file); 
     122      } 
     123    } 
     124     
     125    $this->lock = fopen($this->lock_file, 'x+'); 
     126 
    117127     
    118128    if (flock($this->lock, LOCK_EX | LOCK_NB)) { 
     129      fwrite($this->lock, getmypid()); 
    119130      return true; 
    120131    } else {