Merge pull request #42 from salimane/upstream

Avoid working with dirty worker ids
This commit is contained in:
Chris Boulton 2012-03-05 00:33:47 -08:00
commit 37e148b23c

View File

@ -95,7 +95,7 @@ class Resque_Worker
*/
public static function find($workerId)
{
if(!self::exists($workerId)) {
if(!self::exists($workerId) || false === strpos($workerId, ":")) {
return false;
}
@ -447,6 +447,7 @@ class Resque_Worker
$workerPids = $this->workerPids();
$workers = self::all();
foreach($workers as $worker) {
if (is_object($worker)) {
list($host, $pid, $queues) = explode(':', (string)$worker, 3);
if($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) {
continue;
@ -455,6 +456,7 @@ class Resque_Worker
$worker->unregisterWorker();
}
}
}
/**
* Return an array of process IDs for all of the Resque workers currently