コード例 #1
0
 /**
  * Judge the current task
  *
  * @return updated task
  */
 function judge()
 {
     static $binfile = '';
     static $last_compilation_status = -1;
     static $last_compileroutput = '';
     if (!$this->last_task_is_simlar()) {
         onlinejudge_clean_temp_dir();
         $files = $this->create_temp_files();
         $binfile = $this->compile($files);
         $last_compilation_status = $this->task->status;
         $last_compileroutput = $this->task->compileroutput;
     } else {
         // reuse results of last compilation
         $this->task->status = $last_compilation_status;
         $this->task->compileroutput = $last_compileroutput;
     }
     if ($this->task->status == ONLINEJUDGE_STATUS_COMPILATION_OK && !$this->task->compileonly) {
         $this->run_in_sandbox($binfile);
     }
     return $this->task;
 }
コード例 #2
0
$plugin_version = get_config('local_onlinejudge', 'version');
while (!$forcestop) {
    judge_all_unjudged();
    if ($options['once']) {
        break;
    }
    //Check interval is 5 seconds
    // TODO: definable by admin
    sleep(5);
    if ($plugin_version < get_config('local_onlinejudge', 'version')) {
        verbose('Plugin was upgraded.');
        break;
    }
}
verbose('Clean temp files.');
onlinejudge_clean_temp_dir(false);
// Clean full tree of temp dir
verbose('Judge daemon exits.');
fclose($LOCK);
/**
 * Return one unjudged task and set it status as JUDGING
 *
 * @return an unjudged task or null;
 */
function get_one_unjudged_task()
{
    global $CFG, $DB, $LOCK;
    $task = null;
    flock($LOCK, LOCK_EX);
    // try locking, but ignore if not available (eg. on NFS and FAT)
    try {