Page 1 of 1

update_daemon2.php reports "error: Can't create lockfile"

Posted: 29 May 2013, 04:16
by sleeper_service
after commit commit 1d7658969352ee73dd94baf3cea15364dd303786, update_daemon2.php won't run, it always reports error: Can't create lockfile. Maybe another daemon is already running.

after digging around in functions.php a bit, I *believe* that there's a logic error in the latest commit.

with that commit, it checks to see if flock is available && file exists, if that fails, it skips the test block, and hits "return true" ie, if flock exsts and the file does NOT exist, then it hits the default 'return true'.

my php is a bit rusty, but moving the file_exists check up above the function_exists test, it works. ie

Code: Select all

  function file_is_locked($filename) {
    if (file_exists(LOCK_DIRECTORY . "/$filename")) {
      if (function_exists('flock')) {
        $fp = @fopen(LOCK_DIRECTORY . "/$filename", "r");
        if ($fp) {
          if (flock($fp, LOCK_EX | LOCK_NB)) {
            flock($fp, LOCK_UN);
            fclose($fp);
            return false;
          }
          fclose($fp);
          return true;
        } else {
          return false;
        }
      }
      return true; // consider the file always locked and skip the test
    } else {
      return false;
    }
  }


don't beat me too hard if I got it wrong ;)

Re: update_daemon2.php reports "error: Can't create lockfile

Posted: 29 May 2013, 07:38
by fox
Yeah, this makes sense. :)