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

Support requests, bug reports, etc. go here. Dedicated servers / VDS hosting only
User avatar
sleeper_service
Bear Rating Overlord
Bear Rating Overlord
Posts: 884
Joined: 30 Mar 2013, 23:50
Location: Dallas, Texas

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

Postby sleeper_service » 29 May 2013, 04:16

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 ;)

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

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

Postby fox » 29 May 2013, 07:38

Yeah, this makes sense. :)


Return to “Support”

Who is online

Users browsing this forum: No registered users and 12 guests