Skip to content

Commit

Permalink
Merge branch 'salimane-upstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
pilif committed Feb 14, 2012
2 parents 048b78b + ec5cadb commit 67aece0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/Resque/Worker.php
Expand Up @@ -53,7 +53,7 @@ class Resque_Worker
* @var Resque_Job Current job, if any, being processed by this worker.
*/
private $currentJob = null;

/**
* @var int Process ID of child worker processes.
*/
Expand Down Expand Up @@ -105,7 +105,7 @@ public static function exists($workerId)
*/
public static function find($workerId)
{
if(!self::exists($workerId)) {
if(!self::exists($workerId) || false === strpos($workerId, ":")) {
return false;
}

Expand Down Expand Up @@ -489,12 +489,14 @@ public function pruneDeadWorkers()
$workerPids = $this->workerPids();
$workers = self::all();
foreach($workers as $worker) {
list($host, $pid, $queues) = explode(':', (string)$worker, 3);
if($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) {
continue;
if (is_object($worker)) {
list($host, $pid, $queues) = explode(':', (string)$worker, 3);
if($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) {
continue;
}
$this->log('Pruning dead worker: ' . (string)$worker, self::LOG_VERBOSE);
$worker->unregisterWorker();
}
$this->log('Pruning dead worker: ' . (string)$worker, self::LOG_VERBOSE);
$worker->unregisterWorker();
}
}

Expand Down

0 comments on commit 67aece0

Please sign in to comment.