mirror of
https://github.com/idanoo/php-resque
synced 2025-07-01 13:42:22 +00:00
avoid working with dirty worker ids
This commit is contained in:
parent
4700375d25
commit
5b24b471dc
1 changed files with 10 additions and 8 deletions
|
@ -95,7 +95,7 @@ class Resque_Worker
|
||||||
*/
|
*/
|
||||||
public static function find($workerId)
|
public static function find($workerId)
|
||||||
{
|
{
|
||||||
if(!self::exists($workerId)) {
|
if(!self::exists($workerId) || false === strpos($workerId, ":")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,6 +447,7 @@ class Resque_Worker
|
||||||
$workerPids = $this->workerPids();
|
$workerPids = $this->workerPids();
|
||||||
$workers = self::all();
|
$workers = self::all();
|
||||||
foreach($workers as $worker) {
|
foreach($workers as $worker) {
|
||||||
|
if (is_object($worker)) {
|
||||||
list($host, $pid, $queues) = explode(':', (string)$worker, 3);
|
list($host, $pid, $queues) = explode(':', (string)$worker, 3);
|
||||||
if($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) {
|
if($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -455,6 +456,7 @@ class Resque_Worker
|
||||||
$worker->unregisterWorker();
|
$worker->unregisterWorker();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array of process IDs for all of the Resque workers currently
|
* Return an array of process IDs for all of the Resque workers currently
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue