function background_process_ass_check_process in Background Process 7.2
Same name and namespace in other branches
- 8 background_process_ass/background_process_ass.module \background_process_ass_check_process()
- 6 background_process_ass/background_process_ass.module \background_process_ass_check_process()
- 7 background_process_ass/background_process_ass.module \background_process_ass_check_process()
Check if process is really running.
Parameters
$process: Process object
$server_status: Server status data
Return value
boolean TRUE if running, FALSE if not.
1 call to background_process_ass_check_process()
- background_process_ass_auto_unlock in background_process_ass/
background_process_ass.module - Unlock locked processes that aren't really running.
File
- background_process_ass/
background_process_ass.module, line 224 - @todo Implement admin interface. @todo Fix runtime check of running process.
Code
function background_process_ass_check_process($process, $server_status, $path) {
$active = TRUE;
// Is status reliable?
if ($server_status && $server_status['status']['Current Timestamp'] > $process
->getStartTime()) {
// Check if process is in the server status
if (!empty($server_status['connections'])) {
$active = FALSE;
foreach ($server_status['connections'] as $conn) {
if ($conn['M'] == 'R') {
// We cannot rely on the server status, assume connection is still
// active, and bail out.
watchdog('bg_process', 'Found reading state ...', array(), WATCHDOG_WARNING);
$active = TRUE;
break;
}
// Empty connections, skip them
if ($conn['M'] == '.' || $conn['M'] == '_') {
continue;
}
if ($conn['VHost'] == $process->http_host && strpos($conn['Request'], 'POST ' . $path) === 0) {
$active = TRUE;
break;
}
}
}
}
return $active;
}