You are here

function background_process_ass_check_process in Background Process 8

Same name and namespace in other branches
  1. 6 background_process_ass/background_process_ass.module \background_process_ass_check_process()
  2. 7.2 background_process_ass/background_process_ass.module \background_process_ass_check_process()
  3. 7 background_process_ass/background_process_ass.module \background_process_ass_check_process()

Implements to Check if process is really running.

1 call to background_process_ass_check_process()
background_process_ass_auto_unlock in background_process_ass/background_process_ass.module
Implements to Unlock locked processes that aren't really running.

File

background_process_ass/background_process_ass.module, line 147
Implements Background Process Ass Module. @todo Implement admin interface. @todo Fix runtime check of running process.

Code

function background_process_ass_check_process($process, $server_status, $path) {
  $active = TRUE;
  if ($server_status && $server_status['status']['Current Timestamp'] > $process->start) {
    if (!empty($server_status['connections'])) {
      $active = FALSE;
      foreach ($server_status['connections'] as $conn) {
        if ($conn['M'] == 'R') {

          // We cannot rely on the server status.
          \Drupal::logger('bg_process')
            ->warning('Found reading state ...', []);
          $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;
}